Skip to content

Commit

Permalink
Add system and request tests
Browse files Browse the repository at this point in the history
  • Loading branch information
deborahchua committed Feb 12, 2025
1 parent 42b9cb3 commit 8f719f0
Show file tree
Hide file tree
Showing 2 changed files with 145 additions and 0 deletions.
18 changes: 18 additions & 0 deletions spec/requests/corporate_information_page_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
RSpec.describe "Corporate Information Page" do
before do
content_store_has_example_item("/government/organisations/government-digital-service/about", schema: :corporate_information_page)
content_store_has_example_item("/government/organisations/government-digital-service/about/our-governance", schema: :corporate_information_page)
end

describe "GET show" do
it "returns 200" do
get "/government/organisations/government-digital-service/about"

expect(response).to have_http_status(:ok)

get "/government/organisations/government-digital-service/about/our-governance"

expect(response).to have_http_status(:ok)
end
end
end
127 changes: 127 additions & 0 deletions spec/system/corporate_information_page_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
RSpec.describe "CorporateInformationPage" do
context "when visiting a Corporate Information page" do
before do
@content_store_response = GovukSchemas::Example.find("corporate_information_page", example_name: "corporate_information_page")
content_store_has_example_item("/government/organisations/department-of-health/about", schema: :corporate_information_page, example: :corporate_information_page)
visit "/government/organisations/department-of-health/about"
end

it "displays the title" do
within(".gem-c-heading") do
expect(page).to have_title("About us - Department of Health - GOV.UK")
expect(page).to have_css("h1", text: @content_store_response["title"])
end
end

it "displays the description" do
expect(page).to have_css("p", text: @content_store_response["description"])
end

it "displays the organisation logo" do
within(".gem-c-organisation-logo") do
expect(page).to have_css(".gem-c-organisation-logo__name", text: "Departmentof Health")
end
end

it "displays the brand colour if available" do
expect(page).to have_css(".department-of-health-brand-colour")
end

it "displays the contents list heading links" do
within(".app-c-contents-list-with-body") do
expect(page).to have_css("h2", text: "Contents")
expect(page).to have_link("Our responsibilities", href: "#our-responsibilities")
end
end

context "when corporate information is available" do
it "displays H2 link in contents list" do
within(".app-c-contents-list-with-body") do
expect(page).to have_link("Corporate information", href: "#corporate-information")
end
end

it "displays H2 in content" do
within(".gem-c-govspeak") do
expect(page).to have_css("h2", text: "Corporate information", id: "corporate-information")
end
end

context "when corporate information groups are available" do
it "displays the headings" do
within(".gem-c-govspeak") do
expect(page).to have_css("h3", text: "Access our information", id: "access-our-information")
expect(page).to have_css("h3", text: "Jobs and contracts", id: "jobs-and-contracts")
end
end

it "displays group links" do
within(".gem-c-govspeak") do
expect(page).to have_link("Transparency data", href: "/government/publications?departments%5B%5D=department-of-health&publication_type=transparency-data")
expect(page).to have_link("Jobs", href: "https://www.civilservicejobs.service.gov.uk/csr")
end
end
end

it "displays further information" do
within(".gem-c-govspeak") do
expect(page).to have_css("p", text: "Our Personal information charter explains how we treat your personal information.")
end
end
end

it "displays the back to top link" do
within(".app-c-contents-list-with-body__link-container") do
expect(page).to have_link("Contents", href: "#contents")
end
end
end

context "when visiting a Corporate Information page that does not have additional corporate information" do
before do
content_store_has_example_item("/government/organisations/department-of-health/about/our-governance", schema: :corporate_information_page, example: :corporate_information_page_without_description)
visit "/government/organisations/department-of-health/about/our-governance"
end

it "does not displays H2 link in contents list" do
within(".app-c-contents-list-with-body") do
expect(page).not_to have_link("Corporate information", href: "#corporate-information")
end
end

it "does not displays H2 in content" do
within(".gem-c-govspeak") do
expect(page).not_to have_css("h2", text: "Corporate information", id: "corporate-information")
end
end
end

context "when visiting a withdrawn Corporate Information page" do
before do
content_store_has_example_item("/government/organisations/department-for-work-pensions/about/welsh-language-scheme", schema: :corporate_information_page, example: "best-practice-welsh-language-scheme-withdrawn")
visit "/government/organisations/department-for-work-pensions/about/welsh-language-scheme"
end

it "displays the withdrawn notice" do
within(".govuk-notification-banner__content") do
expect(page).to have_css("h2.gem-c-notice__title", text: "This information page was withdrawn on 10 February 2018")

expect(page).to have_css("p", text: "This information has been withdrawn as it is out of date.")
end
end
end

context "when visiting a Corporate Information page which is translatable" do
before do
content_store_has_example_item("/government/organisations/department-for-work-pensions/about/welsh-language-scheme", schema: :corporate_information_page, example: "best-practice-welsh-language-scheme-withdrawn")
visit "/government/organisations/department-for-work-pensions/about/welsh-language-scheme"
end

it "displays the available translations" do
within(".gem-c-translation-nav") do
expect(page).to have_css(".gem-c-translation-nav__list-item", text: "English")
expect(page).to have_link("Cymraeg", href: "/government/organisations/department-for-work-pensions/about/welsh-language-scheme.cy")
end
end
end
end

0 comments on commit 8f719f0

Please sign in to comment.