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 87f3c67
Show file tree
Hide file tree
Showing 2 changed files with 63 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
When I draft a new editionable topical event called "Test editionable 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
When I draft a new editionable topical event called "Test editionable 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
When I draft a new editionable topical event called "Test editionable 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
43 changes: 43 additions & 0 deletions features/step_definitions/editionable_topical_events_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Given(/^a social media service "([^"]*)" exists$/) do |name|
create(:social_media_service, name:)
end

When(/^I draft a new editionable topical event called "([^"]*)"$/) do |title|
begin_drafting_worldwide_organisation(title:, world_location:)
click_button "Save and go to document summary"
end

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

0 comments on commit 87f3c67

Please sign in to comment.