From 88f502236af0083e5b6cd845244dca8d588f24c5 Mon Sep 17 00:00:00 2001 From: Anton Ilin Date: Sat, 1 Feb 2014 00:21:27 +0200 Subject: [PATCH 1/6] Fix arguments for hevercardable helper We should pass person object to the hovecrardable helper. In the current case `this` is the status message, not the status author. So, let's pass `author` instead of `this`. --- app/assets/templates/reshare_tpl.jst.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/templates/reshare_tpl.jst.hbs b/app/assets/templates/reshare_tpl.jst.hbs index b528bfc55..ef7b821f2 100644 --- a/app/assets/templates/reshare_tpl.jst.hbs +++ b/app/assets/templates/reshare_tpl.jst.hbs @@ -13,7 +13,7 @@ {{#with root}}
- {{author.name}} + {{author.name}} - From 0d9cf0fd6b77c09c617df98cc0c7fc6845076af1 Mon Sep 17 00:00:00 2001 From: Anton Ilin Date: Sat, 1 Feb 2014 12:19:09 +0200 Subject: [PATCH 2/6] Tests for hovercard in reshares Coverage with tests is necessary for every feature --- features/desktop/hovercards.feature | 14 +++++++++++++- features/step_definitions/hovercard_steps.rb | 6 ++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/features/desktop/hovercards.feature b/features/desktop/hovercards.feature index 54a63b4ab..c692d21e9 100644 --- a/features/desktop/hovercards.feature +++ b/features/desktop/hovercards.feature @@ -8,9 +8,11 @@ Feature: Hovercards Given a user named "Bob Jones" with email "bob@bob.bob" And "bob@bob.bob" has a public post with text "public stuff" And a user named "Alice" with email "alice@alice.alice" + And "alice@alice.alice" has a public post with text "alice public stuff" + And the post with text "public stuff" is reshared by "alice@alice.alice" + And the post with text "alice public stuff" is reshared by "bob@bob.bob" And I sign in as "alice@alice.alice" - Scenario: Hovercards on the main stream Given I am on "bob@bob.bob"'s page Then I should see "public stuff" within ".stream_element" @@ -18,3 +20,13 @@ Feature: Hovercards Then I should see a hovercard When I deactivate the first hovercard Then I should not see a hovercard + + Scenario: Hovercards on the main stream in reshares + When I am on "bob@bob.bob"'s page + Then I should see "alice public stuff" within ".reshare" + When I activate hovercard for "Alice" within ".reshare" + Then I should not see a hovercard + When I am on "alice@alice.alice"'s page + Then I should see "public stuff" within ".reshare" + When I activate hovercard for "Bob Jones" within ".reshare" + Then I should see a hovercard diff --git a/features/step_definitions/hovercard_steps.rb b/features/step_definitions/hovercard_steps.rb index 949f41722..64d7a0fcd 100644 --- a/features/step_definitions/hovercard_steps.rb +++ b/features/step_definitions/hovercard_steps.rb @@ -13,3 +13,9 @@ end Then(/^I should not see a hovercard$/) do page.should_not have_css '#hovercard' end + +When (/^I activate hovercard for "([^"]*)" within "([^"]*)"$/) do |name, selector| + with_scope(selector) do + page.execute_script("$('.author').filter(function(index){return $(this).text() === \"#{name}\";}).trigger('mouseenter');") + end +end From e2ce10a9b22065c4d2b881c23b165c469460bdcb Mon Sep 17 00:00:00 2001 From: Anton Ilin Date: Thu, 6 Mar 2014 22:36:38 +0200 Subject: [PATCH 3/6] Use capybara hover method in the hovercard steps Let's use methods provided by capybara whenever possible. --- features/step_definitions/hovercard_steps.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/step_definitions/hovercard_steps.rb b/features/step_definitions/hovercard_steps.rb index 64d7a0fcd..8ba54759e 100644 --- a/features/step_definitions/hovercard_steps.rb +++ b/features/step_definitions/hovercard_steps.rb @@ -1,5 +1,5 @@ When(/^I activate the first hovercard$/) do - page.execute_script("$('.hovercardable').first().trigger('mouseenter');") + first('.hovercardable').hover end Then(/^I should see a hovercard$/) do @@ -16,6 +16,6 @@ end When (/^I activate hovercard for "([^"]*)" within "([^"]*)"$/) do |name, selector| with_scope(selector) do - page.execute_script("$('.author').filter(function(index){return $(this).text() === \"#{name}\";}).trigger('mouseenter');") + find(".author", text: name).hover end end From 870f2e2ae8fc7eac14c6d7d381834c4c5bb5506e Mon Sep 17 00:00:00 2001 From: Anton Ilin Date: Thu, 6 Mar 2014 22:51:47 +0200 Subject: [PATCH 4/6] Make step name more logical --- features/desktop/hovercards.feature | 4 ++-- features/step_definitions/hovercard_steps.rb | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/features/desktop/hovercards.feature b/features/desktop/hovercards.feature index c692d21e9..bff57517e 100644 --- a/features/desktop/hovercards.feature +++ b/features/desktop/hovercards.feature @@ -24,9 +24,9 @@ Feature: Hovercards Scenario: Hovercards on the main stream in reshares When I am on "bob@bob.bob"'s page Then I should see "alice public stuff" within ".reshare" - When I activate hovercard for "Alice" within ".reshare" + When I hover "Alice" within ".reshare" Then I should not see a hovercard When I am on "alice@alice.alice"'s page Then I should see "public stuff" within ".reshare" - When I activate hovercard for "Bob Jones" within ".reshare" + When I hover "Bob Jones" within ".reshare" Then I should see a hovercard diff --git a/features/step_definitions/hovercard_steps.rb b/features/step_definitions/hovercard_steps.rb index 8ba54759e..28ee6cb22 100644 --- a/features/step_definitions/hovercard_steps.rb +++ b/features/step_definitions/hovercard_steps.rb @@ -3,7 +3,7 @@ When(/^I activate the first hovercard$/) do end Then(/^I should see a hovercard$/) do - page.should have_css '#hovercard' + page.should have_css('#hovercard') end When(/^I deactivate the first hovercard$/) do @@ -11,10 +11,10 @@ When(/^I deactivate the first hovercard$/) do end Then(/^I should not see a hovercard$/) do - page.should_not have_css '#hovercard' + page.should_not have_css('#hovercard') end -When (/^I activate hovercard for "([^"]*)" within "([^"]*)"$/) do |name, selector| +When (/^I hover "([^"]*)" within "([^"]*)"$/) do |name, selector| with_scope(selector) do find(".author", text: name).hover end From 81278fa61a75afe88f311f036ca1b200a1b754d3 Mon Sep 17 00:00:00 2001 From: Anton Ilin Date: Fri, 7 Mar 2014 11:28:02 +0200 Subject: [PATCH 5/6] Make feature consistent with other features. Actually, I just trying to make this feature pass. --- features/desktop/hovercards.feature | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/features/desktop/hovercards.feature b/features/desktop/hovercards.feature index bff57517e..631bce618 100644 --- a/features/desktop/hovercards.feature +++ b/features/desktop/hovercards.feature @@ -22,11 +22,11 @@ Feature: Hovercards Then I should not see a hovercard Scenario: Hovercards on the main stream in reshares - When I am on "bob@bob.bob"'s page - Then I should see "alice public stuff" within ".reshare" + Given I am on "bob@bob.bob"'s page + Then I should see "public stuff" within ".stream_element" When I hover "Alice" within ".reshare" Then I should not see a hovercard When I am on "alice@alice.alice"'s page - Then I should see "public stuff" within ".reshare" + Then I should see "public stuff" within ".stream_element" When I hover "Bob Jones" within ".reshare" Then I should see a hovercard From 68f2ce56faf25b2c7c687cee7ea2c44d7a040353 Mon Sep 17 00:00:00 2001 From: Anton Ilin Date: Fri, 7 Mar 2014 14:45:02 +0200 Subject: [PATCH 6/6] Check user name presence instead It seems that loading of stream is not completed before trying to activate hovercard. I do not want to add explicit pause to the scenarion. Let's check link presence before activating hovercard. --- features/desktop/hovercards.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/desktop/hovercards.feature b/features/desktop/hovercards.feature index 631bce618..7b5885829 100644 --- a/features/desktop/hovercards.feature +++ b/features/desktop/hovercards.feature @@ -23,10 +23,10 @@ Feature: Hovercards Scenario: Hovercards on the main stream in reshares Given I am on "bob@bob.bob"'s page - Then I should see "public stuff" within ".stream_element" + Then I should see "Alice" within ".stream_element" When I hover "Alice" within ".reshare" Then I should not see a hovercard When I am on "alice@alice.alice"'s page - Then I should see "public stuff" within ".stream_element" + Then I should see "Bob Jones" within ".stream_element" When I hover "Bob Jones" within ".reshare" Then I should see a hovercard