Skip to content

Commit

Permalink
Add meta tags spec support and add to HelpPage spec
Browse files Browse the repository at this point in the history
  • Loading branch information
georges1996 committed Oct 17, 2024
1 parent 8a63fad commit 43a048b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
20 changes: 20 additions & 0 deletions spec/support/meta_tags.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
RSpec.shared_examples "it has meta tags" do |schema, base_path|
before do
example_doc = GovukSchemas::RandomExample.for_schema(frontend_schema: schema) do |random|
random.merge!(
"title" => "Zhe title",
"withdrawn_notice" => {},
)
random["links"]["available_translations"] = []
random
end

stub_content_store_has_item("#{base_path}/some-page", example_doc.to_json)
end

it "renders the correct meta tags for the title" do
visit "#{base_path}/some-page"

expect(page).to have_css("meta[property='og:title'][content='Zhe title']", visible: false)
end
end
6 changes: 4 additions & 2 deletions spec/system/help_page_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
RSpec.describe "HelpPage" do
it_behaves_like "it has meta tags", "help_page", "/help/about-govuk"

before do
content_store_has_example_item("/help/about-govuk", schema: "help_page", example: "about-govuk")
content_store_has_example_item("/help/cookie-details", schema: "help_page", example: "cookie-details")
content_store_has_example_item("/help/about-govuk", schema: :help_page, example: "about-govuk")
content_store_has_example_item("/help/cookie-details", schema: :help_page, example: "cookie-details")
end

context "when visiting 'help/:slug'" do
Expand Down

0 comments on commit 43a048b

Please sign in to comment.