Add tests for liking and unliking posts
This commit is contained in:
parent
2328f64d56
commit
2b6ca180ce
4 changed files with 60 additions and 9 deletions
40
features/desktop/likes.feature
Normal file
40
features/desktop/likes.feature
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
@javascript
|
||||||
|
Feature: Liking posts
|
||||||
|
In order to show my appreciation
|
||||||
|
As a friendly person
|
||||||
|
I want to like their posts
|
||||||
|
|
||||||
|
Background:
|
||||||
|
Given following users exist:
|
||||||
|
| username | email |
|
||||||
|
| Bob Jones | bob@bob.bob |
|
||||||
|
| Alice Smith | alice@alice.alice |
|
||||||
|
And a user with email "bob@bob.bob" is connected with "alice@alice.alice"
|
||||||
|
And "bob@bob.bob" has a public post with text "I like unicorns"
|
||||||
|
And I sign in as "alice@alice.alice"
|
||||||
|
|
||||||
|
Scenario: Liking and unliking a post from the stream
|
||||||
|
When I am on the home page
|
||||||
|
Then I should see "Bob"
|
||||||
|
And I should see "I like unicorns"
|
||||||
|
When I like the post "I like unicorns" in the stream
|
||||||
|
Then I should see a ".likes" within "#main_stream .stream_element"
|
||||||
|
|
||||||
|
When I unlike the post "I like unicorns" in the stream
|
||||||
|
Then I should not see a ".likes" within "#main_stream .stream_element"
|
||||||
|
|
||||||
|
Scenario: Liking and unliking a post from a single post page
|
||||||
|
When I open the show page of the "I like unicorns" post
|
||||||
|
And I click to like the post
|
||||||
|
Then I should see a ".count" within "#single-post-interactions"
|
||||||
|
|
||||||
|
When I click to unlike the post
|
||||||
|
Then I should not see a ".count" within "#single-post-interactions"
|
||||||
|
|
||||||
|
Scenario: Someone likes my post
|
||||||
|
When I am on the home page
|
||||||
|
And I like the post "I like unicorns" in the stream
|
||||||
|
And I sign out
|
||||||
|
And I sign in as "bob@bob.bob"
|
||||||
|
And I am on the home page
|
||||||
|
Then I should see a ".likes" within "#main_stream .stream_element"
|
||||||
|
|
@ -12,4 +12,9 @@ end
|
||||||
|
|
||||||
And /^I click to delete the post/ do
|
And /^I click to delete the post/ do
|
||||||
find('.remove_post').click
|
find('.remove_post').click
|
||||||
end
|
end
|
||||||
|
|
||||||
|
And /^I click to (?:like|unlike) the post/ do
|
||||||
|
like_show_page_post
|
||||||
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
Then /^I like the post "([^"]*)"$/ do |post_text|
|
When /^I (?:like|unlike) the post "([^"]*)" in the stream$/ do |post_text|
|
||||||
like_post(post_text)
|
like_stream_post(post_text)
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^"([^"]*)" should be post (\d+)$/ do |post_text, position|
|
Then /^"([^"]*)" should be post (\d+)$/ do |post_text, position|
|
||||||
|
|
|
||||||
|
|
@ -88,18 +88,24 @@ module PublishingCukeHelpers
|
||||||
find(".stream_element", text: text)
|
find(".stream_element", text: text)
|
||||||
end
|
end
|
||||||
|
|
||||||
def like_post(post_text)
|
|
||||||
within_post(post_text) do
|
|
||||||
click_link 'Like'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def within_post(post_text)
|
def within_post(post_text)
|
||||||
within find_post_by_text(post_text) do
|
within find_post_by_text(post_text) do
|
||||||
yield
|
yield
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def like_stream_post(post_text)
|
||||||
|
within_post(post_text) do
|
||||||
|
find(:css, 'a.like').click
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def like_show_page_post
|
||||||
|
within("#single-post-actions") do
|
||||||
|
find(:css, 'a.like').click
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def stream_posts
|
def stream_posts
|
||||||
all('.stream_element')
|
all('.stream_element')
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue