diff --git a/features/editionable-topical-events.feature b/features/editionable-topical-events.feature new file mode 100644 index 00000000000..dd05a09ce9d --- /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 + 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 \ 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..c6a19b3a45d --- /dev/null +++ b/features/step_definitions/editionable_topical_events_steps.rb @@ -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 diff --git a/features/support/document_helper.rb b/features/support/document_helper.rb index 277812775e1..101571d5016 100644 --- a/features/support/document_helper.rb +++ b/features/support/document_helper.rb @@ -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 @@ -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"