Refactor saved state cucumber feature to be more consistent. (It was occasionally failing locally due to a timing issue.)
This commit is contained in:
parent
36a262a3ad
commit
59650c8104
3 changed files with 59 additions and 71 deletions
|
|
@ -1,56 +1,46 @@
|
|||
@javascript
|
||||
Feature: saved state
|
||||
Scenario: open aspects persist across sessions
|
||||
Given I am signed in
|
||||
And I have an aspect called "Open 1"
|
||||
|
||||
Background:
|
||||
Given I sign in
|
||||
And I have an aspect called "Closed 1"
|
||||
And I have an aspect called "Closed 2"
|
||||
|
||||
Scenario: open aspects persist across sessions
|
||||
Given I have an aspect called "Open 1"
|
||||
And I have an aspect called "Open 2"
|
||||
And I am on the aspects page
|
||||
And I go to the aspects page
|
||||
|
||||
When I follow "Open 1"
|
||||
And I follow "Open 2"
|
||||
Then aspect "Open 1" should be selected
|
||||
And aspect "Open 2" should be selected
|
||||
But aspect "Closed 1" should not be selected
|
||||
And aspect "Closed 2" should not be selected
|
||||
|
||||
Then I should have aspect "Open 1" "selected"
|
||||
Then I should have aspect "Open 2" "selected"
|
||||
Then I should have aspect "Closed 1" "not selected"
|
||||
Then I should have aspect "Closed 2" "not selected"
|
||||
|
||||
And I click on my name in the header
|
||||
And I follow "logout"
|
||||
|
||||
And I go to the new user session page
|
||||
|
||||
And I am signed in
|
||||
|
||||
When I sign out
|
||||
And I sign in
|
||||
Then I should be on the aspects page
|
||||
Then I should have aspect "Open 1" "selected"
|
||||
But I should have aspect "Open 2" "selected"
|
||||
But I should have aspect "Closed 1" "not selected"
|
||||
But I should have aspect "Closed 2" "not selected"
|
||||
And aspect "Open 1" should be selected
|
||||
And aspect "Open 2" should be selected
|
||||
But aspect "Closed 1" should not be selected
|
||||
And aspect "Closed 2" should not be selected
|
||||
|
||||
And I follow "All Aspects"
|
||||
Then I should have aspect "All Aspects" "selected"
|
||||
When I follow "All Aspects"
|
||||
Then aspect "All Aspects" should be selected
|
||||
|
||||
Scenario: home persists across sessions
|
||||
Given I am signed in
|
||||
And I have an aspect called "Closed 1"
|
||||
And I have an aspect called "Closed 2"
|
||||
And I am on the aspects page
|
||||
Given I am on the aspects page
|
||||
|
||||
When I follow "Closed 1"
|
||||
When I follow "All Aspects"
|
||||
|
||||
Then I should have aspect "All Aspects" "selected"
|
||||
Then I should have aspect "Closed 1" "not selected"
|
||||
Then I should have aspect "Closed 2" "not selected"
|
||||
|
||||
And I click on my name in the header
|
||||
And I follow "logout"
|
||||
|
||||
And I go to the new user session page
|
||||
|
||||
And I am signed in
|
||||
And I follow "All Aspects"
|
||||
Then aspect "All Aspects" should be selected
|
||||
But aspect "Closed 1" should not be selected
|
||||
And aspect "Closed 2" should not be selected
|
||||
|
||||
When I sign out
|
||||
And I sign in
|
||||
Then I should be on the aspects page
|
||||
Then I should have aspect "All Aspects" "selected"
|
||||
Then I should have aspect "Closed 1" "not selected"
|
||||
Then I should have aspect "Closed 2" "not selected"
|
||||
And aspect "All Aspects" should be selected
|
||||
But aspect "Closed 1" should not be selected
|
||||
And aspect "Closed 2" should not be selected
|
||||
|
|
|
|||
|
|
@ -9,11 +9,12 @@ Given /^I (?:am signed|sign) in as an? (\w+)$/ do |role|
|
|||
Given 'I am signed in'
|
||||
end
|
||||
|
||||
Given "I try to sign in" do
|
||||
Given "I am signed in"
|
||||
Given /^(?:I am signed in|I sign in)$/ do
|
||||
When %(I try to sign in)
|
||||
wait_until { page.has_content?(@me.diaspora_handle) }
|
||||
end
|
||||
|
||||
Given 'I am signed in' do
|
||||
When /^I try to sign in$/ do
|
||||
@me ||= Factory(:user_with_aspect, :getting_started => false)
|
||||
When %(I go to the new user session page)
|
||||
When %(I fill in "Username" with "#{@me.username}")
|
||||
|
|
@ -21,7 +22,6 @@ Given 'I am signed in' do
|
|||
When %(I press "Sign in")
|
||||
end
|
||||
|
||||
|
||||
When /^I sign in as "([^"]*)"$/ do |email|
|
||||
@me = User.find_by_email(email)
|
||||
@me.password ||= 'password'
|
||||
|
|
@ -37,4 +37,7 @@ When /^I put in my password in "([^"]*)"$/ do |field|
|
|||
When %(I fill in "#{field}" with "#{@me.password}")
|
||||
end
|
||||
|
||||
|
||||
When /^I (?:log|sign) out$/ do
|
||||
When 'I click on my name in the header'
|
||||
And 'I follow "logout"'
|
||||
end
|
||||
|
|
|
|||
|
|
@ -112,15 +112,11 @@ end
|
|||
Given /^I have no open aspects saved$/ do
|
||||
@me.aspects.update_all(:open => false)
|
||||
end
|
||||
Then /^I should have aspect "([^"]*)" "([^"]*)"$/ do |arg1, arg2|
|
||||
val = evaluate_script("$('a:contains(\"#{arg1}\")').parent('li').hasClass('selected');") #
|
||||
if arg2 == "selected"
|
||||
val.should == true
|
||||
elsif arg2 == "not selected"
|
||||
val.should == false
|
||||
else
|
||||
raise "Aspect state should either be 'selected' or 'not selected'"
|
||||
end
|
||||
|
||||
Then /^aspect "([^"]*)" should (not )?be selected$/ do |aspect_name, not_selected|
|
||||
link_is_selected = evaluate_script("$('a:contains(\"#{aspect_name}\")').parent('li').hasClass('selected');")
|
||||
expected_value = !not_selected
|
||||
link_is_selected.should == expected_value
|
||||
end
|
||||
|
||||
Given /^a user with email "([^"]*)" is connected with "([^"]*)"$/ do |arg1, arg2|
|
||||
|
|
@ -138,18 +134,17 @@ end
|
|||
Given /^a user with email "([^\"]*)" has posted a status message "([^\"]*)" in all aspects$/ do |arg1, arg2|
|
||||
user = User.where(:email => arg1).first
|
||||
status_message = user.build_post(:status_message, :text => arg2)
|
||||
def status_message.socket_to_user(a1, a2); end
|
||||
|
||||
def status_message.socket_to_user(a1, a2)
|
||||
;
|
||||
end
|
||||
|
||||
user.add_to_streams(status_message, user.aspects)
|
||||
status_message.save!
|
||||
bob = User.where(:email => "bob@bob.bob").first
|
||||
raise bob.visible_posts.inspect
|
||||
end
|
||||
|
||||
When /^I log out$/ do
|
||||
When "I click on my name in the header"
|
||||
When "I follow \"logout\""
|
||||
end
|
||||
|
||||
Given /^there is a user "([^\"]*)" who's tagged "([^\"]*)"$/ do |full_name, tag|
|
||||
username = full_name.gsub(/\W/, "").underscore
|
||||
Given "a user named \"#{full_name}\" with email \"#{username}@example.com\""
|
||||
|
|
|
|||
Loading…
Reference in a new issue