diff --git a/test/contracts/govuk_content_schemas_test.rb b/test/contracts/govuk_content_schemas_test.rb index a00ce205b..7a5b45c16 100644 --- a/test/contracts/govuk_content_schemas_test.rb +++ b/test/contracts/govuk_content_schemas_test.rb @@ -3,9 +3,10 @@ class GovukContentSchemasTest < ActionDispatch::IntegrationTest include GovukContentSchemaExamples - all_examples_for_supported_schemas.each do |content_item| - test "can successfully render #{content_item['base_path']} schema example" do + all_examples_for_supported_schemas.each_with_index do |content_item, index| + test "can successfully render #{content_item['document_type']} #{index} example" do stub_content_store_has_item(content_item["base_path"], content_item) + stub_parent_breadcrumbs(content_item, content_item["document_type"]) get content_item["base_path"] diff --git a/test/support/govuk_content_schema_examples.rb b/test/support/govuk_content_schema_examples.rb index ba8808216..e74dce25c 100644 --- a/test/support/govuk_content_schema_examples.rb +++ b/test/support/govuk_content_schema_examples.rb @@ -29,9 +29,16 @@ def govuk_content_schema_example(schema_name, example_name) GovukSchemas::Example.find(schema_name, example_name:) end + def stub_parent_breadcrumbs(document, schema) + parents = document.dig("links", "parent") + return if parents.nil? + + stub_content_store_has_item(parents.first["base_path"], document) if schema == "html_publication" + end + module ClassMethods def all_examples_for_supported_schemas - GovukSchemas::Example.find_all(supported_schemas) + supported_schemas.flat_map { |format| GovukSchemas::Example.find_all(format) } end def supported_schemas @@ -39,7 +46,6 @@ def supported_schemas case_study coming_soon html_publication - redirect statistics_announcement take_part topical_event_about_page