From 87f3c6780ef71e639e6410fe20b78d6a49e810ad Mon Sep 17 00:00:00 2001 From: JonathanHallam Date: Wed, 11 Dec 2024 16:29:31 +0000 Subject: [PATCH] Create feature tests for social media accounts There were none already so i've had to create them I've borrowed pretty heavily from when we did the worldwide org work! --- features/editionable-topical-events.feature | 20 +++++++++ .../editionable_topical_events_steps.rb | 43 +++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 features/editionable-topical-events.feature create mode 100644 features/step_definitions/editionable_topical_events_steps.rb diff --git a/features/editionable-topical-events.feature b/features/editionable-topical-events.feature new file mode 100644 index 00000000000..f73ad78a98c --- /dev/null +++ b/features/editionable-topical-events.feature @@ -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 \ No newline at end of file diff --git a/features/step_definitions/editionable_topical_events_steps.rb b/features/step_definitions/editionable_topical_events_steps.rb new file mode 100644 index 00000000000..2b7135d3c02 --- /dev/null +++ b/features/step_definitions/editionable_topical_events_steps.rb @@ -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