Skip to content

Commit

Permalink
Create feature tests for social media accounts
Browse files Browse the repository at this point in the history
There were none already so i've had to create them

I've borrowed pretty heavily from when we did the worldwide org work!
  • Loading branch information
JonathanHallam committed Dec 11, 2024
1 parent 75dfb28 commit 47bdf90
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
20 changes: 20 additions & 0 deletions features/editionable-topical-events.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Feature: Topical events
Scenario Outline: Adding a social media account to an editionable topical event
Given a social media service "Facebook" exists
Given a topical event called "Test editionable topical event" with summary "A topical event" and description "A topical event"
And I edit the editionable topical event "Test editionable topical event" adding the social media service of "Facebook" with title "Our Facebook page" at URL "https://www.social.gov.uk"
Then I should see the "Our Facebook page" social media site has been assigned to the editionable topical event "Test editionable topical event"

Scenario Outline: Editing a social media account to an editionable topical event
Given a social media service "Facebook" exists
Given a topical event called "Test editionable topical event" with summary "A topical event" and description "A topical event"
And I edit the editionable topical event "Test editionable topical event" adding the social media service of "Facebook" with title "Our Facebook page" at URL "https://www.social.gov.uk"
And I edit the editionable topical event "Test editionable topical event" changing the social media account with title "Our Facebook page" to "Our new Facebook page"
Then I should see the "Our new Facebook page" social media site has been assigned to the editionable topical event "Test editionable topical event"

Scenario Outline: Deleting a social media account assigned to an editionable topical event
Given a social media service "Facebook" exists
Given a topical event called "Test editionable topical event" with summary "A topical event" and description "A topical event"
And I edit the editionable topical event "Test editionable topical event" adding the social media service of "Facebook" with title "Our Facebook page" at URL "https://www.social.gov.uk"
And I edit the editionable topical event "Test editionable topical event" deleting the social media account with title "Our Facebook page"
Then I should see the editionable topical event "Test editionable topical event" has no social media accounts
34 changes: 34 additions & 0 deletions features/step_definitions/editionable_topical_events_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
And(/^I edit the topical event "([^"]*)" adding the social media service of "([^"]*)" with title "([^"]*)" at URL "([^"]*)"$/) do |title, social_media_service_name, social_media_title, social_media_url|
begin_editing_document(title)
click_link "Social media accounts"
click_link "Add new social media account"
select social_media_service_name, from: "Service (required)"
fill_in "URL (required)", with: social_media_url
fill_in "Title", with: social_media_title
click_button "Save"
end

And(/^I edit the topical event "([^"]*)" changing the social media account with title "([^"]*)" to "([^"]*)"$/) do |title, _old_social_media_title, new_social_media_title|
begin_editing_document(title)
click_link "Social media accounts"
click_link "Edit"
fill_in "Title", with: new_social_media_title
click_button "Save"
end

And(/^I edit the topical event "([^"]*)" deleting the social media account with title "([^"]*)"$/) do |title, _social_media_title|
begin_editing_document(title)
click_link "Social media accounts"
click_link "Delete"
click_button "Delete"
end

Then(/^I should see the "([^"]*)" social media site has been assigned to the topical event "([^"]*)"$/) do |social_media_title, title|
@topical_event = EditionableTopicalEvent.find_by(title:)
expect(@topical_event.social_media_accounts.first.title).to eq(social_media_title)
end

Then(/^I should see the topical event "([^"]*)" has no social media accounts$/) do |title|
@topical_event = EditionableTopicalEvent.find_by(title:)
expect(@topical_event.social_media_accounts).to be_empty
end
8 changes: 8 additions & 0 deletions features/support/document_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ def begin_drafting_worldwide_organisation(options)
fill_in_worldwide_organisation_fields(**options.slice(:world_location))
end

def begin_drafting_editionable_topical_event(options)
begin_drafting_document options.merge(type: "editionable_topical_event")

fill_in_editionable_topical_event_fields(**options.slice(:topical_event))
end

def pdf_attachment
Rails.root.join("features/fixtures/attachment.pdf")
end
Expand All @@ -131,6 +137,8 @@ def fill_in_worldwide_organisation_fields(world_location: "United Kingdom")
fill_in "Logo formatted name", with: "Logo\r\nformatted\r\nname\r\n"
end

def fill_in_editionable_topical_event_fields; end

def fill_in_news_article_fields(first_published: "2010-01-01", announcement_type: "News story")
select announcement_type, from: "News article type"
checkbox_label = "This document has previously been published on another website"
Expand Down

0 comments on commit 47bdf90

Please sign in to comment.