From d0fe59af697077d4c5d918836ada07f12cb270db Mon Sep 17 00:00:00 2001 From: Dan Hansen Date: Sat, 1 Oct 2011 15:28:02 -0500 Subject: [PATCH] add cucumber feature for photo lightbox change step to reflect element visibility --- app/views/layouts/_header.html.haml | 12 +++---- features/photo_lightbox.feature | 32 +++++++++++++++++++ features/step_definitions/custom_web_steps.rb | 13 +++++++- features/step_definitions/lightbox_steps.rb | 19 +++++++++++ 4 files changed, 69 insertions(+), 7 deletions(-) create mode 100644 features/photo_lightbox.feature create mode 100644 features/step_definitions/lightbox_steps.rb diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 84a136d39..63b6d8820 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -62,14 +62,14 @@ .footer_container .hashtags - #lightbox - #lightbox-content - = link_to "[x] close", '#', :id => 'lightbox-close-link' - %img#lightbox-image - #lightbox-imageset + #lightbox + #lightbox-content + = link_to "[x] close", '#', :id => 'lightbox-close-link' + %img#lightbox-image + #lightbox-imageset - #lightbox-backdrop + #lightbox-backdrop %ul#user_menu.dropdown %li diff --git a/features/photo_lightbox.feature b/features/photo_lightbox.feature new file mode 100644 index 000000000..a75b427bb --- /dev/null +++ b/features/photo_lightbox.feature @@ -0,0 +1,32 @@ +@javascript +Feature: viewing the photo lightbox + Background: + Given I am on the home page + And a user with username "bob" + + When I sign in as "bob@bob.bob" + And I am on the home page + + Given I expand the publisher + And I attach the file "spec/fixtures/button.png" to hidden element "file" within "#file-upload" + And I fill in "status_message_fake_text" with "Look at this dog" + And I press "Share" + And I wait for the ajax to finish + And I follow "Your Aspects" + + Scenario: viewing a photo + Then I should see an image attached to the post + And I press the attached image + Then I should see the photo lightbox + + Scenario: closing the lightbox by clicking the close link + Then I should see an image attached to the post + And I press the attached image + And I press the close lightbox link + Then I should not see the photo lightbox + + Scenario: closing the lightbox by clicking the backdrop + Then I should see an image attached to the post + And I press the attached image + And I press the lightbox backdrop + Then I should not see the photo lightbox diff --git a/features/step_definitions/custom_web_steps.rb b/features/step_definitions/custom_web_steps.rb index 84c60bc3d..1a0ca0922 100644 --- a/features/step_definitions/custom_web_steps.rb +++ b/features/step_definitions/custom_web_steps.rb @@ -111,7 +111,11 @@ end Then /^(?:|I )should not see a "([^\"]*)"(?: within "([^\"]*)")?$/ do |selector, scope_selector| with_scope(scope_selector) do - page.has_css?(selector).should be_false + if page.has_css?(selector) + find(:css, selector).visible?.should be_false + else + page.has_css?(selector).should be_false + end end end @@ -202,3 +206,10 @@ Then /^I follow Edit Profile in the same window$/ do And %(I follow "Edit Profile") end +Then 'I should see an image attached to the post' do + Then %{I should see a "img" within ".stream_element div.photo_attachments"} +end + +Then 'I press the attached image' do + Then %{I press the 1st "img" within ".stream_element div.photo_attachments"} +end \ No newline at end of file diff --git a/features/step_definitions/lightbox_steps.rb b/features/step_definitions/lightbox_steps.rb new file mode 100644 index 000000000..33497302f --- /dev/null +++ b/features/step_definitions/lightbox_steps.rb @@ -0,0 +1,19 @@ +Then 'I should see the photo lightbox' do + Then %{I should see a "img" within "#lightbox-imageset"} + And %{I should see a "#lightbox-backdrop" within "body"} + And %{I should see a "#lightbox-image" within "body"} +end + +Then 'I should not see the photo lightbox' do + Then %{I should not see a "img" within "#lightbox-imageset"} + And %{I should not see a "#lightbox-backdrop" within "body"} + And %{I should not see a "#lightbox-image" within "body"} +end + +Then 'I press the close lightbox link' do + find(:css, "#lightbox-close-link").click +end + +Then 'I press the lightbox backdrop' do + find(:css, "#lightbox-backdrop").click +end \ No newline at end of file