From 396acd2f81e3b6f82cdf5f41e29bf8265ee95f98 Mon Sep 17 00:00:00 2001 From: Andy Sellick Date: Wed, 30 May 2018 13:27:32 +0000 Subject: [PATCH] Remove contents list component - update contents list with body component and other references to use contents list component from gem - update tests --- .../components/_contents-list.scss | 70 ------- .../helpers/_contents-list-helper.scss | 25 --- .../components/print/_contents-list.scss | 19 -- app/assets/stylesheets/print.scss | 1 - app/helpers/contents_list_helper.rb | 19 -- .../_contents-list-with-body.html.erb | 2 +- app/views/components/_contents-list.html.erb | 79 -------- app/views/components/docs/contents-list.yml | 191 ------------------ app/views/content_items/guide.html.erb | 2 +- .../content_items/html_publication.html.erb | 2 +- .../contents_list_component_test.rb | 123 ----------- .../contents_list_with_body_test.rb | 4 +- test/helpers/contents_list_helper_test.rb | 78 ------- .../corporate_information_page_test.rb | 2 +- test/integration/detailed_guide_test.rb | 4 +- test/integration/document_collection_test.rb | 6 +- test/integration/guide_test.rb | 2 +- test/integration/html_publication_test.rb | 2 +- test/integration/specialist_document_test.rb | 8 +- test/integration/statistical_data_set_test.rb | 2 +- .../topical_event_about_page_test.rb | 4 +- test/integration/working_group_test.rb | 2 +- test/test_helper.rb | 4 +- 23 files changed, 23 insertions(+), 628 deletions(-) delete mode 100644 app/assets/stylesheets/components/_contents-list.scss delete mode 100644 app/assets/stylesheets/components/helpers/_contents-list-helper.scss delete mode 100644 app/assets/stylesheets/components/print/_contents-list.scss delete mode 100644 app/helpers/contents_list_helper.rb delete mode 100644 app/views/components/_contents-list.html.erb delete mode 100644 app/views/components/docs/contents-list.yml delete mode 100644 test/components/contents_list_component_test.rb delete mode 100644 test/helpers/contents_list_helper_test.rb diff --git a/app/assets/stylesheets/components/_contents-list.scss b/app/assets/stylesheets/components/_contents-list.scss deleted file mode 100644 index 5cd94a33f..000000000 --- a/app/assets/stylesheets/components/_contents-list.scss +++ /dev/null @@ -1,70 +0,0 @@ -@import "helpers/contents-list-helper"; - -.app-c-contents-list { - // Always render the contents list above a - // back to contents link - position: relative; - margin-bottom: $gutter-two-thirds; - z-index: 1; - background: $white; - box-shadow: 0 20px 15px -10px $white; -} - -.app-c-contents-list--no-underline { - .app-c-contents-list__link { - text-decoration: none; - - &:hover, - &:focus, - &:active { - text-decoration: underline; - } - } -} - -.app-c-contents-list__link { - .app-c-contents-list__list-item--parent > & { - font-weight: bold; - } -} - -.app-c-contents-list__list-item { - padding-top: $gutter-one-third; - line-height: 1.3; - list-style-type: none; - - @include media(tablet) { - padding-top: $gutter-one-quarter; - } -} - -.app-c-contents-list__list-item--dashed { - $contents-spacing: $gutter-half + 10; - margin-left: $contents-spacing; - padding-right: $contents-spacing; - - &:before { - content: "— "; - margin-left: -$contents-spacing; - padding-right: 5px; - - .direction-rtl & { - margin-left: 0; - margin-right: -$contents-spacing; - padding-right: 0; - padding-left: 5px; - } - } - - // Focus styles on IE8 and older include the - // left margin, creating an odd white box with - // orange border around the em dash. - // Use inline-block and vertical alignment to - // fix focus styles - // - // https://github.com/alphagov/government-frontend/pull/420#issuecomment-320632386 - .lte-ie8 & .app-c-contents-list__link { - display: inline-block; - vertical-align: top; - } -} diff --git a/app/assets/stylesheets/components/helpers/_contents-list-helper.scss b/app/assets/stylesheets/components/helpers/_contents-list-helper.scss deleted file mode 100644 index f769a6752..000000000 --- a/app/assets/stylesheets/components/helpers/_contents-list-helper.scss +++ /dev/null @@ -1,25 +0,0 @@ -// Contents list helper is used in both print and screen stylesheets -.app-c-contents-list__list-item--numbered { - .app-c-contents-list__link { - display: table; - } -} - -.app-c-contents-list__number, -.app-c-contents-list__numbered-text { - display: table-cell; -} - -.app-c-contents-list__number { - min-width: 1.5em; -} - -.app-c-contents-list__numbered-text { - $contents-text-padding: 0.3em; - padding-left: $contents-text-padding; - - .direction-rtl & { - padding-left: 0; - padding-right: $contents-text-padding; - } -} diff --git a/app/assets/stylesheets/components/print/_contents-list.scss b/app/assets/stylesheets/components/print/_contents-list.scss deleted file mode 100644 index a81ffc781..000000000 --- a/app/assets/stylesheets/components/print/_contents-list.scss +++ /dev/null @@ -1,19 +0,0 @@ -@import "../helpers/contents-list-helper"; - -// Override default browser indentation -.app-c-contents-list__list, -.app-c-contents-list__nested-list { - padding-left: 0; - margin-left: 0; -} - -// Put indentation back where we use list style types -.app-c-contents-list__list-item--dashed { - margin-left: $gutter / 2; - list-style-type: disc; -} - -.app-c-contents-list__list-item--numbered, -.app-c-contents-list__list-item--parent { - list-style-type: none; -} diff --git a/app/assets/stylesheets/print.scss b/app/assets/stylesheets/print.scss index 3da0649a0..5a67179ca 100644 --- a/app/assets/stylesheets/print.scss +++ b/app/assets/stylesheets/print.scss @@ -2,6 +2,5 @@ @import 'measurements'; @import 'typography'; -@import 'components/print/*'; @import 'govuk_publishing_components/all_components_print'; @import 'print/html-publication'; diff --git a/app/helpers/contents_list_helper.rb b/app/helpers/contents_list_helper.rb deleted file mode 100644 index 6b1f2d291..000000000 --- a/app/helpers/contents_list_helper.rb +++ /dev/null @@ -1,19 +0,0 @@ -module ContentsListHelper - def wrap_numbers_with_spans(content_item_link) - content_item_text = strip_tags(content_item_link) #just the text of the link - - # Must start with a number - # Number must be between 1 and 999 (ie not 2014) - # Must be followed by a space - # May contain a period `1.` - # May be a decimal `1.2` - number = /^\d{1,3}(\.?|\.\d{1,2})(?=\s)/.match(content_item_text) - - if number - words = content_item_text.sub(number.to_s, '').strip #remove the number from the text - content_item_link.sub(content_item_text, "#{number} #{words}").squish.html_safe - else - content_item_link - end - end -end diff --git a/app/views/components/_contents-list-with-body.html.erb b/app/views/components/_contents-list-with-body.html.erb index 244e1a937..8c0bb1cfe 100644 --- a/app/views/components/_contents-list-with-body.html.erb +++ b/app/views/components/_contents-list-with-body.html.erb @@ -7,7 +7,7 @@
> <% if contents.any? %>
- <%= render 'components/contents-list', contents: contents %> + <%= render 'govuk_publishing_components/components/contents_list', contents: contents %>
<% end %> <%= block %> diff --git a/app/views/components/_contents-list.html.erb b/app/views/components/_contents-list.html.erb deleted file mode 100644 index 41d8551cf..000000000 --- a/app/views/components/_contents-list.html.erb +++ /dev/null @@ -1,79 +0,0 @@ -<% - format_numbers ||= false - underline_links ||= false - contents ||= [] - aria_label ||= '' - nested = !!contents.find { |c| c[:items] && c[:items].any? } - parent_list_item_modifier = if nested - 'parent' - elsif format_numbers - 'numbered' - else - 'dashed' - end -%> -<% if contents.any? %> - -<% end %> diff --git a/app/views/components/docs/contents-list.yml b/app/views/components/docs/contents-list.yml deleted file mode 100644 index 6f02d488b..000000000 --- a/app/views/components/docs/contents-list.yml +++ /dev/null @@ -1,191 +0,0 @@ -name: Contents list -description: Lists a page’s contents with links pointing to headings within the document -body: | - Pass a list of contents each with an `href` and `text`. The `href` should point at the ID of a heading within the page. - - Supports nesting contents one level deep, currently only used by specialist documents. When nesting the top level list items - display in bold. - - `format_numbers` option will pull out numbers in the link text to render them as though they were the list style type. Applies to - numbers at the start of text, with or without a decimal. See the [format complex numbers fixture](/component-guide/contents-list/formats_complex_numbers) for details. -accessibility_criteria: | - The component must be [a landmark with a navigation role](https://accessibility.blog.gov.uk/2016/05/27/using-navigation-landmarks/). - - The contents list must: - - - inform the user how many items are in the list - - convey the content structure - - indicate the current page when contents span different pages, and not link to itself - - The contents list may: - - include an aria-label to contextualise the list if helpful - - Links with formatted numbers must separate the number and text with a space for correct screen reader pronunciation. This changes pronunciation from "1 dot Item" to "1 Item". -shared_accessibility_criteria: - - link -examples: - default: - data: - contents: - - href: "#first-thing" - text: First thing - - href: "#second-thing" - text: Second thing - - href: "#third-thing" - text: Third thing - underline_links: - description: By default we do not underline links in this component even though this is the general approach on GOV.UK. This is because some of the examples below (particularly those with numbers) do not work well with underlined links. Instead, this option allows the links to be underlined where appropriate. - data: - underline_links: true - contents: - - href: "#first-thing" - text: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. - - href: "#second-thing" - text: Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. - - href: "#third-thing" - text: Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. - long_text: - data: - contents: - - href: "#first-thing" - text: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. - - href: "#second-thing" - text: Another pretty long contents list entry, not as long as the first, but still a little. - - href: "#third-thing" - text: Third thing - active_content_link: - description: 'An active state allows for "you are here" items in a contents list that spans different pages to avoid linking back to the current page.' - data: - contents: - - href: "#first-thing" - text: First - - href: "#two" - text: Second - active: true - - href: "#third-thing" - text: Third thing - aria_label: - description: 'An aria-label string can be used to contextualise the navigation for assistive technology.' - data: - aria_label: "Pages in this guide" - contents: - - href: "#first-thing" - text: First - - href: "#two" - text: Second - active: true - - href: "#third-thing" - text: Third thing - nested_contents_lists: - data: - contents: - - href: "#first-thing" - text: First thing - - href: "#second-thing" - text: Second thing - - href: "#third-thing" - text: Third thing - items: - - href: "#sub-third-thing" - text: Sub third thing - - href: "#another-third-thing" - text: Another third thing - - href: "#fourth-thing" - text: Fourth thing - formats_numbers: - data: - format_numbers: true - contents: - - href: "#first-thing" - text: 1. First thing - - href: "#two" - active: true - text: 2. Second thing - - href: "#third-thing" - text: 3. Third thing - formats_complex_numbers: - data: - format_numbers: true - contents: - - href: "#" - text: 1. Item - - href: "#" - text: 1.1 Sub item - - href: "#" - text: 1.2 Sub item - - href: "#" - text: "1.02 longer decimals allowed" - - href: "#" - text: "1.021 even longer decimals ignored" - - href: "#" - text: 1 Number without period - - href: "#" - text: 10. Two digit numbers - - href: "#" - text: 99. Two digit numbers - - href: "#" - text: 100. Three digit numbers - - href: "#" - text: 2017 four digit numbers ignored - - href: "#" - text: "2001: A space odyssey" - nested_with_formatted_numbers: - data: - format_numbers: true - contents: - - href: "#first-thing" - text: 1. First thing - items: - - href: "#second-thing" - text: 2. Numbers not parsed - - href: "#third-thing" - text: 3. Numbers are just text - - href: "#first-thing" - text: 2. Next thing - items: - - href: "#second-thing" - text: No numbers here - - href: "#third-thing" - active: true - text: None here either - right_to_left: - data: - contents: - - href: "#section" - text: "هل يمكنك تقديم" - - href: "#section-1" - text: "أعد مستند" - - href: "#section-2" - text: "تقديم الطلب" - context: - right_to_left: true - right_to_left_with_formatted_numbers: - data: - format_numbers: true - contents: - - href: "#section" - text: "هل يمكنك تقديم" - - href: "#section-1" - text: "أعد مستند" - - href: "#section-2" - text: "تقديم الطلب" - context: - right_to_left: true - right_to_left_with_nested_contents_lists: - data: - contents: - - href: "#section" - text: "هل يمكنك تقديم" - - href: "#section-1" - text: "أعد مستند" - - href: "#section-2" - text: "تقديم الطلب" - items: - - href: "#section" - text: "هل يمكنك تقديم" - - href: "#section-1" - text: "أعد مستند" - - href: "#section-2" - text: "تقديم الطلب" - context: - right_to_left: true diff --git a/app/views/content_items/guide.html.erb b/app/views/content_items/guide.html.erb index 31a5a6ac7..2a0c40177 100644 --- a/app/views/content_items/guide.html.erb +++ b/app/views/content_items/guide.html.erb @@ -12,7 +12,7 @@ <%= render 'govuk_component/title', { title: @content_item.title } %> <% if @content_item.multi_page_guide? %> <% end %>
diff --git a/app/views/content_items/html_publication.html.erb b/app/views/content_items/html_publication.html.erb index 518aa9672..0ea82908b 100644 --- a/app/views/content_items/html_publication.html.erb +++ b/app/views/content_items/html_publication.html.erb @@ -37,7 +37,7 @@ > <% if @content_item.contents.any? %>
- <%= render 'components/contents-list', contents: @content_item.contents, format_numbers: true %> + <%= render 'govuk_publishing_components/components/contents_list', contents: @content_item.contents, format_numbers: true %>
<% end %> diff --git a/test/components/contents_list_component_test.rb b/test/components/contents_list_component_test.rb deleted file mode 100644 index d58be48d5..000000000 --- a/test/components/contents_list_component_test.rb +++ /dev/null @@ -1,123 +0,0 @@ -require 'component_test_helper' - -class ContentsListComponentTest < ComponentTestCase - def component_name - "contents-list" - end - - def contents_list - [ - { href: '/one', text: "1. One" }, - { href: '/two', text: "2. Two" } - ] - end - - def contents_list_with_active_item - [ - { href: '/one', text: "1. One" }, - { href: '/two', text: "2. Two", active: true }, - { href: '/three', text: "3. Three" } - ] - end - - def nested_contents_list - contents_list << { - href: '/three', - text: "3. Three", - items: [ - { href: '/nested-one', text: "Nested one" }, - { href: '/nested-two', text: "Nested two" }, - { href: '/nested-four', text: "4. Four" }, - ] - } - end - - def assert_tracking_link(name, value, total = 1) - assert_select "a[data-track-#{name}='#{value}']", total - end - - test "renders nothing without provided contents" do - assert_empty render_component({}) - end - - test "renders a list of contents links" do - render_component(contents: contents_list) - assert_select ".app-c-contents-list.app-c-contents-list--no-underline" - assert_select ".app-c-contents-list__link[href='/one']", text: "1. One" - assert_select ".app-c-contents-list__link[href='/two']", text: "2. Two" - end - - test "renders with the underline option" do - render_component(contents: contents_list, underline_links: true) - assert_select ".app-c-contents-list" - assert_select ".app-c-contents-list.app-c-contents-list--no-underline", false - end - - test "renders text only when link is active" do - render_component(contents: contents_list_with_active_item) - assert_select ".app-c-contents-list" - assert_select ".app-c-contents-list__link[href='/one']", text: "1. One" - assert_select ".app-c-contents-list__link[href='/two']", count: 0 - assert_select ".app-c-contents-list__list-item[2]", text: '2. Two' - assert_select ".app-c-contents-list__list-item--active[aria-current='true']" - end - - test "renders text only when link is active for numbered lists" do - render_component(contents: contents_list_with_active_item, format_numbers: true) - assert_select ".app-c-contents-list" - assert_select ".app-c-contents-list__link[href='/one']", text: "1. One" - assert_select ".app-c-contents-list__link[href='/two']", count: 0 - assert_select ".app-c-contents-list__list-item[2]", text: '2. Two' - assert_select ".app-c-contents-list__list-item[2] .app-c-contents-list__number", text: '2.' - assert_select ".app-c-contents-list__list-item--active[aria-current='true']" - end - - test "renders a nested list of contents links" do - render_component(contents: nested_contents_list) - nested_link_selector = ".app-c-contents-list__list-item--parent ol li .app-c-contents-list__link" - - assert_select "#{nested_link_selector}[href='/nested-one']", text: "Nested one" - assert_select "#{nested_link_selector}[href='/nested-two']", text: "Nested two" - end - - test "renders data attributes for tracking" do - render_component(contents: nested_contents_list) - - assert_select ".app-c-contents-list[data-module='track-click']" - - assert_tracking_link("category", "contentsClicked", 6) - assert_tracking_link("action", "content_item 1") - assert_tracking_link("label", "/one") - assert_tracking_link("options", { dimension29: "1. One" }.to_json) - - assert_tracking_link("action", "nested_content_item 3:1") - assert_tracking_link("label", "/nested-one") - assert_tracking_link("options", { dimension29: "Nested one" }.to_json) - end - - - test "formats numbers in contents links" do - render_component(contents: contents_list, format_numbers: true) - link_selector = ".app-c-contents-list__list-item--numbered a[href='/one']" - - assert_select "#{link_selector} .app-c-contents-list__number", text: "1." - assert_select "#{link_selector} .app-c-contents-list__numbered-text", text: "One" - end - - test "does not format numbers in a nested list" do - render_component(contents: nested_contents_list, format_numbers: true) - - link_selector = ".app-c-contents-list__list-item--parent a[href='/one']" - assert_select "#{link_selector} .app-c-contents-list__number", text: "1." - assert_select "#{link_selector} .app-c-contents-list__numbered-text", text: "One" - - nested_link_selector = ".app-c-contents-list__list-item--parent ol li a[href='/nested-four']" - assert_select "#{nested_link_selector} .app-c-contents-list__number", count: 0 - assert_select "#{nested_link_selector} .app-c-contents-list__numbered-text", count: 0 - end - - test "aria label is rendered when supplied" do - render_component(contents: contents_list_with_active_item, aria_label: "All pages in this guide") - assert_select ".app-c-contents-list[aria-label=\"All pages in this guide\"]" - end -end diff --git a/test/components/contents_list_with_body_test.rb b/test/components/contents_list_with_body_test.rb index 50f0741dc..b66452a23 100644 --- a/test/components/contents_list_with_body_test.rb +++ b/test/components/contents_list_with_body_test.rb @@ -40,8 +40,8 @@ def block test "renders a contents-list component" do render(component_path, contents: contents_list) { block } - assert_select(".app-c-contents-list-with-body .app-c-contents-list") - assert_select ".app-c-contents-list__link[href='/one']", text: "1. One" + assert_select(".app-c-contents-list-with-body .gem-c-contents-list") + assert_select ".gem-c-contents-list__link[href='/one']", text: "1. One" end test "renders a back-to-top component" do diff --git a/test/helpers/contents_list_helper_test.rb b/test/helpers/contents_list_helper_test.rb deleted file mode 100644 index 06982560d..000000000 --- a/test/helpers/contents_list_helper_test.rb +++ /dev/null @@ -1,78 +0,0 @@ -require 'test_helper' - -class ContentsListHelperTest < ActionView::TestCase - include ActionView::Helpers::SanitizeHelper - - test "it wraps a number and text in separate span elements" do - assert_split_number_and_text('1. Thing', '1.', 'Thing') - assert_split_number_and_text('10. Thing', '10.', 'Thing') - assert_split_number_and_text('100. Thing', '100.', 'Thing') - end - - test "it keeps a space between number and text for screen reader pronunciation" do - # 1.Thing can be pronounced "1 dot Thing" - # 1. Thing is always pronounced "1 Thing" - text = "1. Thing" - wrapped_html = wrap_numbers_with_spans("#{text}") - assert_equal text, strip_tags(wrapped_html) - end - - test "it wraps a number and text in span elements if it's a number without a period" do - assert_split_number_and_text('1 Thing', '1', 'Thing') - end - - test "it wraps a number in the form X.Y" do - assert_split_number_and_text('1.2 Vision', '1.2', 'Vision') - end - - test "it does nothing if no number is found" do - input = 'Vision' - expected = 'Vision' - assert_equal expected, wrap_numbers_with_spans(input) - end - - test "it does nothing if it's just a number" do - input = '1' - expected = '1' - assert_equal expected, wrap_numbers_with_spans(input) - end - - test "it does nothing if the number is part of the word" do - input = '1Vision' - expected = '1Vision' - assert_equal expected, wrap_numbers_with_spans(input) - - input = '1.Vision' - expected = '1.Vision' - assert_equal expected, wrap_numbers_with_spans(input) - end - - test "it does nothing if it starts with a number longer than 3 digits" do - input = '2014 Vision' - expected = '2014 Vision' - assert_equal expected, wrap_numbers_with_spans(input) - - input = '2014. Vision' - expected = '2014. Vision' - assert_equal expected, wrap_numbers_with_spans(input) - - input = '10001. Vision' - expected = '10001. Vision' - assert_equal expected, wrap_numbers_with_spans(input) - end - - test "it does nothing if a number is present but not at the start" do - input = 'Run an effective welfare system part 1. Social Care' - expected = 'Run an effective welfare system part 1. Social Care' - assert_equal expected, wrap_numbers_with_spans(input) - end - - def assert_split_number_and_text(number_and_text, number, text) - number_class = "app-c-contents-list__number" - numbered_text_class = "app-c-contents-list__numbered-text" - - input = "#{number_and_text}" - expected = "#{number} #{text}" - assert_equal expected, wrap_numbers_with_spans(input) - end -end diff --git a/test/integration/corporate_information_page_test.rb b/test/integration/corporate_information_page_test.rb index 61c8f29f5..1ad2617a0 100644 --- a/test/integration/corporate_information_page_test.rb +++ b/test/integration/corporate_information_page_test.rb @@ -27,7 +27,7 @@ class CorporateInformationPageTest < ActionDispatch::IntegrationTest content_store_has_item(item["base_path"], item.to_json) visit(item["base_path"]) - refute page.has_css?(".app-c-contents-list") + refute page.has_css?(".gem-c-contents-list") end test "renders corporate information with body when present" do diff --git a/test/integration/detailed_guide_test.rb b/test/integration/detailed_guide_test.rb index 28ea24747..011d299a9 100644 --- a/test/integration/detailed_guide_test.rb +++ b/test/integration/detailed_guide_test.rb @@ -74,12 +74,12 @@ class DetailedGuideTest < ActionDispatch::IntegrationTest test "renders a contents list" do setup_and_visit_content_item("detailed_guide") - assert page.has_css?(".app-c-contents-list") + assert page.has_css?(".gem-c-contents-list") end test "renders without contents list if it has fewer than 3 items" do setup_and_visit_content_item("national_applicability_alternative_url_detailed_guide") - refute page.has_css?(".app-c-contents-list") + refute page.has_css?(".gem-c-contents-list") end test "conditionally renders a logo" do diff --git a/test/integration/document_collection_test.rb b/test/integration/document_collection_test.rb index 67851f4fd..12d5354b3 100644 --- a/test/integration/document_collection_test.rb +++ b/test/integration/document_collection_test.rb @@ -5,7 +5,7 @@ class DocumentCollectionTest < ActionDispatch::IntegrationTest setup_and_visit_content_item('document_collection') assert_has_component_title(@content_item["title"]) assert page.has_text?(@content_item["description"]) - assert page.has_css?(".app-c-contents-list") + assert page.has_css?(".gem-c-contents-list") end test "document collection with no body and 2 collection groups where 1st group has long body" do @@ -14,7 +14,7 @@ class DocumentCollectionTest < ActionDispatch::IntegrationTest content_store_has_item(content_item['base_path'], content_item.to_json) visit(content_item['base_path']) - assert page.has_css?('.app-c-contents-list') + assert page.has_css?('.gem-c-contents-list') end test "renders metadata and document footer" do @@ -56,7 +56,7 @@ class DocumentCollectionTest < ActionDispatch::IntegrationTest content_store_has_item(item["base_path"], item.to_json) visit(item["base_path"]) - refute page.has_css?(".app-c-contents-list") + refute page.has_css?(".gem-c-contents-list") end test "renders each collection group" do diff --git a/test/integration/guide_test.rb b/test/integration/guide_test.rb index 37348cc93..c73d0e415 100644 --- a/test/integration/guide_test.rb +++ b/test/integration/guide_test.rb @@ -19,7 +19,7 @@ class GuideTest < ActionDispatch::IntegrationTest test "draft access tokens are appended to part links within navigation" do setup_and_visit_content_item('guide', '?token=some_token') - assert page.has_css?('.app-c-contents-list a[href$="?token=some_token"]') + assert page.has_css?('.gem-c-contents-list a[href$="?token=some_token"]') end test "does not show part navigation, print link or part title when only one part" do diff --git a/test/integration/html_publication_test.rb b/test/integration/html_publication_test.rb index 072a600d8..2c46c48ad 100644 --- a/test/integration/html_publication_test.rb +++ b/test/integration/html_publication_test.rb @@ -17,7 +17,7 @@ class HtmlPublicationTest < ActionDispatch::IntegrationTest within ".sidebar-with-body" do assert page.has_text?("Contents") - assert page.has_css?('.app-c-contents-list') + assert page.has_css?('.gem-c-contents-list') end within ".organisation-logos" do diff --git a/test/integration/specialist_document_test.rb b/test/integration/specialist_document_test.rb index 3293c160e..aca4e0e95 100644 --- a/test/integration/specialist_document_test.rb +++ b/test/integration/specialist_document_test.rb @@ -110,11 +110,11 @@ class SpecialistDocumentTest < ActionDispatch::IntegrationTest test "renders a nested contents list" do setup_and_visit_content_item('countryside-stewardship-grants') - assert page.has_css?("#contents .app-c-contents-list") + assert page.has_css?("#contents .gem-c-contents-list") assert page.has_css?(%(#contents .app-c-contents-list-with-body__link-wrapper .app-c-contents-list-with-body__link-container a.app-c-back-to-top)) - within ".app-c-contents-list" do + within ".gem-c-contents-list" do @content_item['details']['headers'].each do |heading| assert_nested_content_item(heading) end @@ -124,7 +124,7 @@ class SpecialistDocumentTest < ActionDispatch::IntegrationTest test "renders a nested contents list with level 2 and 3 headings only" do setup_and_visit_content_item('drug-device-alerts') - within ".app-c-contents-list" do + within ".gem-c-contents-list" do @content_item['details']['headers'].each do |heading| assert_nested_content_item(heading) end @@ -166,6 +166,6 @@ def assert_nested_content_item(heading) test 'does not render a contents list if there are fewer than three items in the contents list' do setup_and_visit_content_item('aaib-reports') - refute page.has_css?('#contents .app-c-contents-list') + refute page.has_css?('#contents .gem-c-contents-list') end end diff --git a/test/integration/statistical_data_set_test.rb b/test/integration/statistical_data_set_test.rb index a0118aca6..84a388f66 100644 --- a/test/integration/statistical_data_set_test.rb +++ b/test/integration/statistical_data_set_test.rb @@ -66,6 +66,6 @@ class StatisticalDataSetTest < ActionDispatch::IntegrationTest content_store_has_item(item["base_path"], item.to_json) visit(item["base_path"]) - refute page.has_css?(".app-c-contents-list") + refute page.has_css?(".gem-c-contents-list") end end diff --git a/test/integration/topical_event_about_page_test.rb b/test/integration/topical_event_about_page_test.rb index bf188cc70..0676d76a2 100644 --- a/test/integration/topical_event_about_page_test.rb +++ b/test/integration/topical_event_about_page_test.rb @@ -29,7 +29,7 @@ class TopicalEventAboutPageTest < ActionDispatch::IntegrationTest content_store_has_item(@content_item["base_path"], @content_item.to_json) visit @content_item["base_path"] - refute page.has_css?(".app-c-contents-list") + refute page.has_css?(".gem-c-contents-list") end test "contents list displayed when fewer than three items and first item word count is greater than 100" do @@ -39,7 +39,7 @@ class TopicalEventAboutPageTest < ActionDispatch::IntegrationTest content_store_has_item(@content_item["base_path"], @content_item.to_json) visit @content_item["base_path"] - assert page.has_css?(".app-c-contents-list") + assert page.has_css?(".gem-c-contents-list") end private diff --git a/test/integration/working_group_test.rb b/test/integration/working_group_test.rb index 56f6772cb..4f28139ff 100644 --- a/test/integration/working_group_test.rb +++ b/test/integration/working_group_test.rb @@ -59,6 +59,6 @@ class WorkingGroupTest < ActionDispatch::IntegrationTest content_store_has_item(item["base_path"], item.to_json) visit(item["base_path"]) - refute page.has_css?(".app-c-contents-list") + refute page.has_css?(".gem-c-contents-list") end end diff --git a/test/test_helper.rb b/test/test_helper.rb index db25e0c8f..e72093033 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -107,8 +107,8 @@ def assert_has_component_government_navigation_active(active) end def assert_has_contents_list(contents) - assert page.has_css?(".app-c-contents-list"), "Failed to find an element with a class of contents-list" - within ".app-c-contents-list" do + assert page.has_css?(".gem-c-contents-list"), "Failed to find an element with a class of contents-list" + within ".gem-c-contents-list" do contents.each do |heading| selector = "a[href=\"##{heading[:id]}\"]" text = heading.fetch(:text)