diff --git a/features/posts.feature b/features/posts.feature index 1c8f2e900..a37ca7b44 100644 --- a/features/posts.feature +++ b/features/posts.feature @@ -55,7 +55,7 @@ Feature: posting And I have turned off jQuery effects And I click "Mention" button And I expand the publisher in the modal window - And I append "I am eating a yogurt" to the publisher in the modal window + And I append "I am eating a yogurt" to the publisher And I press "Share" in the modal window And I follow "" Then I should "I am eating a yogurt" @@ -70,7 +70,7 @@ Feature: posting And I have turned off jQuery effects And I click "Mention" button And I expand the publisher in the modal window - And I append "I am eating a yogurt" to the publisher in the modal window + And I append "I am eating a yogurt" to the publisher And I follow "DidntPostTo" within "#publisher" in the modal window And I press "Share" in the modal window And I follow "" diff --git a/features/step_definitions/custom_web_steps.rb b/features/step_definitions/custom_web_steps.rb index e04352ea1..4cd048c53 100644 --- a/features/step_definitions/custom_web_steps.rb +++ b/features/step_definitions/custom_web_steps.rb @@ -11,13 +11,29 @@ And /^I expand the publisher$/ do ') end - When /^I append "([^"]*)" to the publisher$/ do |stuff| - script = <<-JS - $('#status_message_fake_text').val( - $('#status_message_fake_text').val() + '#{stuff}').keyup(); -JS - page.execute_script(script) + # Wait for the publisher to appear and all the elements to lay out + wait_until { evaluate_script("$('#status_message_fake_text').focus().length == 1") } + + # Write to the placeholder field and trigger a keyup to start the copy + page.execute_script <<-JS + $('#status_message_fake_text').val($('#status_message_fake_text').val() + '#{stuff}'); + $('#status_message_fake_text').keyup(); + JS + + # Wait until the text appears in the placeholder + wait_until do + evaluate_script("$('#status_message_fake_text').val().match(/#{stuff}/) != null") + end + + # WAIT FOR IT!... + + # Wait until the text copy is finished + wait_until do + evaluate_script <<-JS + $('#status_message_text').val() && ($('#status_message_text').val().match(/#{stuff}/) != null) + JS + end end And /^I hover over the post$/ do @@ -54,13 +70,13 @@ end When /^I press the first "([^"]*)"(?: within "([^"]*)")?$/ do |link_selector, within_selector| with_scope(within_selector) do - find(:css, link_selector).click + find(:css, link_selector).click end end -When /^I press the ([\d])(nd|rd|st|th) "([^\"]*)"(?: within "([^\"]*)")?$/ do |number,rd, link_selector, within_selector| +When /^I press the ([\d])(nd|rd|st|th) "([^\"]*)"(?: within "([^\"]*)")?$/ do |number, rd, link_selector, within_selector| with_scope(within_selector) do - find(:css, link_selector+":nth-child(#{number})").click + find(:css, link_selector+":nth-child(#{number})").click end end Then /^(?:|I )should see a "([^\"]*)"(?: within "([^\"]*)")?$/ do |selector, scope_selector|