Skip to content

Commit

Permalink
Merge pull request #3548 from alphagov/steps-cleanup
Browse files Browse the repository at this point in the history
Clean up Cucumber feature test suite
  • Loading branch information
csutter authored Nov 4, 2024
2 parents d8c75e4 + b798378 commit 5a6b1ac
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 348 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@
select item, from:
end

When(/^I enter "([^"]*)" for "([^"]*)"$/) do |text, field|
fill_in field, with: text
end

When(/^I enter "([^"]*)" for "([^"]*)" under "([^"]*)"$/) do |text, field, fieldset|
within_fieldset(fieldset) do
fill_in field, with: text
Expand Down
165 changes: 0 additions & 165 deletions features/step_definitions/filtering_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,10 @@
visit finder_path("mosw-reports")
end

And(/there is a zero results message$/) do
expect(page).to have_content("no matching results")
end

And(/there is not a zero results message$/) do
expect(page).to_not have_content("no matching results")
end

And(/the page title contains both keywords$/) do
expect(page).to have_title "Keyword1 Keyword2 - News and communications - GOV.UK"
end

And(/the page title contains only Keyword2$/) do
expect(page).to have_title "Keyword2 - News and communications - GOV.UK"
end

And(/the page title contains no keywords$/) do
expect(page).to have_title "News and communications - GOV.UK"
end

And(/the page title is updated$/) do
expect(page).to have_title "#{@keyword_search} - Ministry of Silly Walks reports - GOV.UK"
end
Expand Down Expand Up @@ -168,50 +152,6 @@
visit finder_path("aaib-reports", topic: "c58fdadd-7743-46d6-9629-90bb3ccc4ef0")
end

When(/^I view the all content finder with a manual filter$/) do
topic_taxonomy_has_taxons
content_store_has_all_content_finder
stub_organisations_registry_request
stub_world_locations_api_request
stub_topical_events_api_request
stub_people_registry_request
stub_manuals_registry_request

stub_request(:get, DocumentHelper::SEARCH_ENDPOINT)
.with(query: hash_including(q: "Replacing bristles"))
.to_return(body: all_content_results_json)

stub_request(:get, DocumentHelper::SEARCH_ENDPOINT)
.with(query: hash_including(
filter_manual: "/guidance/care-and-use-of-a-nimbus-2000",
q: "Replacing bristles",
)).to_return(body: all_content_manuals_results_json)

stub_request(:get, DocumentHelper::SEARCH_V2_ENDPOINT)
.with(query: hash_including(q: "Replacing bristles"))
.to_return(body: all_content_results_json)

stub_request(:get, DocumentHelper::SEARCH_V2_ENDPOINT)
.with(query: hash_including(
filter_manual: "/guidance/care-and-use-of-a-nimbus-2000",
q: "Replacing bristles",
)).to_return(body: all_content_manuals_results_json)

visit finder_path("search/all", manual: "/guidance/care-and-use-of-a-nimbus-2000", q: "Replacing bristles")
end

When(/^I view the all content finder$/) do
topic_taxonomy_has_taxons
content_store_has_all_content_finder
stub_organisations_registry_request
stub_world_locations_api_request
stub_people_registry_request
stub_manuals_registry_request
stub_search_api_request_with_all_content_results

visit finder_path("search/all")
end

When(/^I view a list of services$/) do
topic_taxonomy_has_taxons
content_store_has_services_finder
Expand Down Expand Up @@ -266,17 +206,6 @@
expect(page).to have_content("2005 to 2010 Labour government")
end

Then(/^I can see documents which have government metadata$/) do
within ".finder-results .gem-c-document-list__item:nth-child(1)" do
expect(page).to have_content("Updated:")
expect(page).to have_css('dl time[datetime="2007-02-14"]')

expect(page).to have_content("News Story")

expect(page).to have_content("Ministry of Justice")
end
end

Then(/^I see the atom feed$/) do
expect(page).to have_selector("id", text: "tag:www.dev.gov.uk,2005:/restrictions-on-usage-of-spells-within-school-grounds")
expect(page).to have_selector("updated", text: "2017-12-30T10:00:00+00:00")
Expand Down Expand Up @@ -323,11 +252,6 @@
apply_date_filter
end

When(/^I use a collection of documents exist that can be filtered by checkbox filter$/) do
visit_cma_cases_finder
apply_date_filter
end

Then(/^I only see documents with matching dates$/) do
assert_cma_cases_are_filtered_by_date
end
Expand Down Expand Up @@ -430,12 +354,6 @@
stub_rummager_with_cma_cases
end

Given(/^a finder with metadata with a topic param set exists$/) do
stub_taxonomy_api_request
stub_content_store_with_cma_cases_finder_with_metadata_with_topic_param
stub_rummager_with_cma_cases
end

When(/^I can see that the finder metadata is present$/) do
visit "/cma-cases"

Expand Down Expand Up @@ -585,10 +503,6 @@
expect(page).to have_css("#order", text: "A-Z")
end

Then(/^I see most relevant order selected$/) do
expect(page).to have_select("order", selected: "Relevance")
end

Then(/^I see (.*) order selected$/) do |label|
expect(page).to have_select("order", selected: label)
end
Expand All @@ -602,10 +516,6 @@
end
end

And(/^I select a taxon$/) do
select("Taxon_1", from: "Topic")
end

And(/^I select a Person$/) do
check("Rufus Scrimgeour")
end
Expand Down Expand Up @@ -657,20 +567,11 @@
find("label", text: "Tracy Island")
end

And(/^I select a World Location$/) do
click_on("World location")
check("Azkaban")
end

And(/^I click button "([^"]*)" and select facet (.*)$/) do |button, facet|
click_on(button)
find("label", text: facet).click
end

And(/^I select facet (.*) in the already expanded "([^"]*)" section$/) do |facet, _button|
find("label", text: facet).click
end

When(/^I click the (.*) remove control$/) do |filter|
expect(page).to have_css(".govuk-frontend-supported")

Expand All @@ -688,18 +589,6 @@
fill_in "Search", with: "Keyword1 Keyword2\n"
end

And(/^I submit the form$/) do
page.execute_script("document.querySelector('.js-live-search-form').submit()")
end

Then(/^The keyword textbox is empty$/) do
expect(page).to have_field("Search", with: "")
end

Then(/^The keyword textbox only contains (.*)$/) do |filter|
expect(page).to have_field("Search", with: filter)
end

When(/^I use a checkbox filter and another disallowed filter$/) do
find("label", text: "Show open cases").click
fill_in("closed_date[from]", with: "1st November 2015")
Expand Down Expand Up @@ -746,18 +635,6 @@
expect(page).to have_content("Select at least one option")
end

When("I create an email subscription") do
within "#subscription-links-footer" do
click_link("Get emails")
end
end

Then("I should see results in the default group") do
within("#js-results .filtered-results__group") do
expect(page.all(".gem-c-document-list__item").size).to eq(9) # 9 results in fixture
end
end

Then("I should see results for scoped by the selected document type") do
expect(page).to have_text("3 results")
within("#js-results") do
Expand All @@ -770,26 +647,6 @@
end
end

Then("I see results grouped by primary facet value") do
within("#js-results") do
expect(page.all(".filtered-results__group").size).to eq(2)

within(".filtered-results__group:nth-child(1)") do
expect(page).to have_css("h2.filtered-results__facet-heading", text: "Aerospace")
end

within(".filtered-results__group:nth-child(2)") do
expect(page).to have_css("h2.filtered-results__facet-heading", text: "All businesses")
end
end
end

Then("I see results with top result") do
within("#js-results") do
expect(page.all(".gem-c-document-list__item--highlight").length).to eq(1)
end
end

Then("I should see all research and statistics") do
expect(page).to have_text("3 results")
within("#js-results") do
Expand All @@ -816,10 +673,6 @@
find_field("Search").send_keys key.to_sym
end

Then(/^I click "(.*)" to expand|collapse all facets/) do |link_text|
click_button(link_text)
end

Then(/^I should (see|not see) a "Skip to results" link$/) do |can_be_seen|
visibility = can_be_seen == "see"
expect(page).to have_css('[href="#js-results"]', visible: visibility)
Expand All @@ -836,21 +689,3 @@
And(/^I should not see an upcoming statistics facet tag$/) do
expect(page).to_not have_css("span.facet-tag__text", text: "Upcoming statistics")
end

Then(/^I can see results filtered by that manual$/) do
expect(page).to have_css(".finder-results .gem-c-document-list__item", count: 1)

within ".finder-results .gem-c-document-list__item:nth-child(1)" do
expect(page).to_not have_content("Restrictions on usage of spells within school grounds")
expect(page).to have_content("Replacing bristles in your Nimbus 2000")
end
end

Then(/^I see all content results$/) do
expect(page).to have_css(".finder-results .gem-c-document-list__item", count: 1)

within ".finder-results .gem-c-document-list__item:nth-child(1)" do
expect(page).to have_content("Restrictions on usage of spells within school grounds")
expect(page).to_not have_content("Replacing bristles in your Nimbus 2000")
end
end
20 changes: 0 additions & 20 deletions features/step_definitions/search_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,10 @@
stub_content_store_has_item("/search", schema: "special_route")
end

When(/^I search for an empty string$/) do
visit "/search?q="
end

When(/^I search for "([^"]*)" from "([^"]*)"$/) do |search_term, organisation|
visit "/search?q=#{search_term}&filter_organisations[]=#{organisation}"
end

When(/^I search for "([^"]*)" in manual "([^"]*)"$/) do |search_term, manual|
visit "/search?q=#{search_term}&filter_manual[]=#{manual}"
end

When(/^I search for "([^"]*)" from "(.*)" on the legacy json endpoint$/) do |search_term, organisation|
visit "/search.json?q=#{search_term}&filter_organisations[]=#{organisation}"
end

Then(/^I am able to set search terms$/) do
expect(page).to have_field("Search GOV.UK", with: "")
end

Given(/^the all content finder exists$/) do
topic_taxonomy_has_taxons([
FactoryBot.build(
Expand Down Expand Up @@ -52,10 +36,6 @@
expect(page.response_headers["Content-Type"]).to include(format)
end

Then(/^results are filtered with a facet tag of (.*)/) do |text|
expect(page).to have_selector("span[class='facet-tag__text']", text:)
end

When(/^I search for "([^"]*)" on the legacy search page$/) do |search_term|
visit "/search?q=#{search_term}"
end
Expand Down
Loading

0 comments on commit 5a6b1ac

Please sign in to comment.