-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit audit trail: alphagov/government-frontend@76e9bd2#diff-6048e9f535fbd535b1c38ab5e387e5c6e0a485d411e9edbbbce9b111b40c25b7 (We have not copied the no-image tags yet, as they are not relevant for the take_part document type. We will bring in when a document type without images is ported over)
- Loading branch information
Showing
1 changed file
with
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
RSpec.describe "Meta Tags" do | ||
before do | ||
case_study = GovukSchemas::RandomExample.for_schema(frontend_schema: "take_part") do |random| | ||
random.merge!( | ||
"title" => "Zhe title", | ||
"withdrawn_notice" => {}, | ||
) | ||
random["links"]["available_translations"] = [] | ||
random | ||
end | ||
|
||
stub_content_store_has_item("/government/get-involved/take-part/some-page", case_study.to_json) | ||
end | ||
|
||
it "renders the correct meta tags for pages" do | ||
visit "/government/get-involved/take-part/some-page" | ||
|
||
expect(page).to have_css("meta[property='og:title'][content='Zhe title']", visible: false) | ||
end | ||
|
||
context "for pages with images" do | ||
before do | ||
case_study = GovukSchemas::RandomExample.for_schema(frontend_schema: "take_part") do |random| | ||
random["details"] = random["details"].merge( | ||
"image" => { | ||
"url" => "https://example.org/image.jpg", | ||
"alt_text" => "An accessible alt text", | ||
}, | ||
) | ||
random["links"]["available_translations"] = [] | ||
random | ||
end | ||
|
||
stub_content_store_has_item("/government/get-involved/take-part/some-page", case_study.to_json) | ||
end | ||
|
||
it "renders image tags" do | ||
visit "/government/get-involved/take-part/some-page" | ||
|
||
expect(page).to have_css("meta[name='twitter:card'][content='summary_large_image']", visible: false) | ||
expect(page).to have_css("meta[name='twitter:image'][content='https://example.org/image.jpg']", visible: false) | ||
expect(page).to have_css("meta[property='og:image'][content='https://example.org/image.jpg']", visible: false) | ||
end | ||
end | ||
end |