Authentication steps test

This commit is contained in:
Will Marshall
2014-05-09 14:13:39 +10:00
parent 9241178fe2
commit 1297520051
4 changed files with 71 additions and 4 deletions

View File

@@ -12,6 +12,7 @@
%label{for: "email"} Email
%input.title.input-text{name: "email",
type: "email",
id: "email",
tabindex: 1,
"ng-model" => "spree_user.email"}
.row
@@ -19,6 +20,7 @@
%label{for: "password"} Password
%input.title.input-text{name: "password",
type: "password",
id: "password",
autocomplete: "off",
tabindex: 2,
"ng-model" => "spree_user.password"}
@@ -26,6 +28,7 @@
.large-12.columns
%input{name: "remember_me",
type: "checkbox",
id: "remember_me",
value: "1",
"ng-model" => "spree_user.remember_me"}
%label{for: "remember_me"} Remember Me

View File

@@ -8,6 +8,7 @@
%label{for: "email"} Your email
%input.title.input-text{name: "email",
type: "email",
id: "email",
tabindex: 1,
"ng-model" => "spree_user.email"}
%span.error{"ng-show" => "errors.email != null"}
@@ -17,6 +18,7 @@
%label{for: "password"} Choose a password
%input.title.input-text{name: "password",
type: "password",
id: "password",
autocomplete: "off",
tabindex: 2,
"ng-model" => "spree_user.password"}
@@ -24,9 +26,10 @@
{{ errors.password.join(' ') }}
.row
.large-12.columns
%label{for: "password"} Confirm password
%label{for: "password_confirmation"} Confirm password
%input.title.input-text{name: "password_confirmation",
type: "password",
id: "password_confirmation",
autocomplete: "off",
tabindex: 2,
"ng-model" => "spree_user.password_confirmation"}

View File

@@ -12,11 +12,47 @@ feature "Authentication", js: true do
describe "as large" do
before do
browse_as_large
open_login_modal
end
scenario "showing login" do
open_login_modal
page.should have_login_modal
end
scenario "failing to login" do
fill_in "Email", with: user.email
click_login_button
page.should have_content "Invalid email or password"
end
scenario "logging in successfully" do
fill_in "Email", with: user.email
fill_in "Password", with: user.password
click_login_button
page.should be_logged_in_as user
end
describe "signing up" do
before do
ActionMailer::Base.deliveries.clear
select_login_tab "Sign up"
end
scenario "Failing to sign up because password is too short" do
fill_in "Email", with: "test@foo.com"
fill_in "Choose a password", with: "short"
click_signup_button
page.should have_content "too short"
end
scenario "Signing up successfully" do
fill_in "Email", with: "test@foo.com"
fill_in "Choose a password", with: "test12345"
fill_in "Confirm password", with: "test12345"
click_signup_button
page.should have_content "Welcome! You have signed up successfully"
page.should be_logged_in_as "test@foo.com"
ActionMailer::Base.deliveries.last.subject.should =~ /Welcome to/
end
end
end
describe "as medium" do
before do
@@ -24,9 +60,7 @@ feature "Authentication", js: true do
end
scenario "showing login" do
open_off_canvas
binding.pry
open_login_modal
save_screenshot "/Users/willmarshall/Desktop/modal.png", :full => true
page.should have_login_modal
end
end

View File

@@ -8,6 +8,20 @@ module UIComponentHelper
page.driver.resize(1280, 800)
end
def click_login_button
click_button "Log in"
end
def click_signup_button
click_button "Sign up now"
end
def select_login_tab(text)
within ".login-modal" do
find("a", text: text).click
end
end
def open_login_modal
find("a", text: "LOG IN").click
end
@@ -19,6 +33,19 @@ module UIComponentHelper
def have_login_modal
have_selector ".login-modal"
end
def be_logged_in_as(user_or_email)
if user_or_email.is_a? Spree::User
have_content user_or_email.email
else
have_content user_or_email
end
end
def be_logged_out
have_content "LOG IN"
end
def open_active_table_row
find("hub:first-child .active_table_row:first-child").click()
end