Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds a smoke test for Publisher to test the entire journey from creating a new piece of content through to unpublishing. Specifically, three separate scenarios create a new draft `Place` on the draft stack, publish this draft to the live stack, before finally proceeding to unpublish the content. One of the requirements this smoke test needs to fulfil is to ensure that multiple runs of Smokey can operate in parallel, which is important as it means that we need to dynamically generate the slug we're specifying for the content we're creating (done using `SecureRandom.hex`). Another complication has been that because we're using separate scenarios to encapsulate the main steps of the test (create draft, publish to live, unpublish), we have had to introduce state which can be shared across these scenarios. Specifically, the state being shared is the unique piece of content that we have created in any one test run (`Smokey test draft place #{SecureRandom.hex}`), so that each scenario of the test can work from where the previous scenario left off. This can be seen by the global variable `$smokey_run_id` in the new `Given` block `I have the smokey run identifier`. I'm aware that [chaining scenarios together can make them difficult to maintain](https://specflow.org/challenges/chain-of-dependent-scenarios), however having each of these steps as a separate scenarios feels to me to be the most sensible approach, whilst the single global variable could also be of use to future tests which need to satisfy a similar requirement. This test will not run on existing production and will not run on the new replatformed production when it's ready, as it has been given the tag `@replatformingnotproduction` (where the Smokey run for each environment by Concourse will exclude tags matching `@replatformingnot<environment>`).
- Loading branch information
1 parent
3c51ad0
commit fd0e410
Showing
3 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
When "I go to add an artefact" do | ||
click_on "Add artefact" | ||
expect(page).to have_content("New artefact") | ||
end | ||
|
||
When "I create a draft place" do | ||
fill_in "Title", with: publication_title | ||
fill_in "Slug", with: parameterize(publication_title) | ||
select "Place", from: "Format" | ||
click_button "Save and go to item" | ||
end | ||
|
||
When "I preview the draft place" do | ||
click_on "Preview" | ||
|
||
wait_until do | ||
visit page.current_url | ||
page.has_no_text?(:all, /not found/i) | ||
end | ||
end | ||
|
||
When "I should see that the content has been published" do | ||
expect(page).to have_content(publication_title) | ||
expect(page.current_path).to eq(publication_path) | ||
expect(page).to_not have_content("GOV.UK Publisher") | ||
end | ||
|
||
When /I search for the content in category "([^"]*)"/ do |status| | ||
select "Nobody", from: "Assignee" | ||
fill_in "Keyword", with: publication_title | ||
select "Place", from: "Format" | ||
click_button "Filter publications" | ||
click_link status | ||
end | ||
|
||
When "I go to the content from the search results" do | ||
click_link publication_title | ||
end | ||
|
||
When "I request 2nd pair of eyes" do | ||
click_on "2nd pair of eyes" | ||
click_on "Send to 2nd pair of eyes" | ||
end | ||
|
||
When "I skip the review" do | ||
click_on "Skip review" | ||
|
||
within "#skip_review_form" do | ||
click_on "Skip review" | ||
end | ||
|
||
wait_until { find('span[title="Status"]').text == "Ready" } | ||
end | ||
|
||
When "I publish the draft" do | ||
click_on "Publish" | ||
click_on "Send to publish" | ||
end | ||
|
||
When "I view the published content on live" do | ||
click_on "View this on the GOV.UK website" | ||
|
||
wait_until do | ||
visit_path publication_url | ||
page.has_no_text?(:all, /not found/i) | ||
end | ||
end | ||
|
||
When /I go to the "([^"]*)" section/ do |section| | ||
click_link section | ||
end | ||
|
||
When "I unpublish the edition" do | ||
accept_alert do | ||
click_button "Unpublish" | ||
end | ||
end | ||
|
||
When "I should see that the content has been unpublished" do | ||
expect(page).to have_content("Content unpublished") | ||
|
||
wait_until do | ||
visit_path publication_url | ||
page.has_text?(:all, /gone/i) | ||
end | ||
end | ||
|
||
def parameterize(str) | ||
str.downcase.gsub(/\s/,'-') | ||
end | ||
|
||
def publication_title | ||
@publication_title ||= "Smokey test draft place #{$smokey_run_id}" | ||
@publication_title | ||
end | ||
|
||
def publication_path | ||
@publication_path ||= "/#{parameterize(publication_title)}" | ||
@publication_path | ||
end | ||
|
||
def publication_url | ||
@publication_url ||= "#{ENV['GOVUK_WEBSITE_ROOT']}#{publication_path}" | ||
@publication_url | ||
end | ||
|
||
def page_contains_no_error?(error) | ||
visit page.current_url | ||
|
||
if page.has_no_content?(error) | ||
return true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters