From 7cae303104f1f0e9dae334525ad9fd42676bbe74 Mon Sep 17 00:00:00 2001 From: Rebecca Law Date: Fri, 4 Sep 2020 14:32:07 +0100 Subject: [PATCH] Fix unit tests for changes to the pill component. --- app/templates/views/usage.html | 3 ++- .../views/organisations/test_organisation.py | 2 +- tests/app/main/views/test_activity.py | 6 +++--- tests/app/main/views/test_dashboard.py | 20 +++++++++---------- tests/app/main/views/test_jobs.py | 6 +++--- tests/app/main/views/test_template_folders.py | 2 +- tests/app/main/views/test_templates.py | 2 +- 7 files changed, 21 insertions(+), 20 deletions(-) diff --git a/app/templates/views/usage.html b/app/templates/views/usage.html index 4b7491be4..d14de5827 100644 --- a/app/templates/views/usage.html +++ b/app/templates/views/usage.html @@ -1,6 +1,7 @@ {% from "components/big-number.html" import big_number %} {% from "components/message-count-label.html" import message_count_label %} {% from "components/table.html" import list_table, field, hidden_field_heading, row_heading, text_field %} +{% from "components/page-header.html" import page_header %} {% from "components/pill.html" import pill %} {% extends "withnav_template.html" %} @@ -11,7 +12,7 @@ {% block maincolumn_content %} -

Usage

+ {{ page_header('Usage', size='medium') }}
{{ pill(years, selected_year, big_number_args={'smallest': True}) }} diff --git a/tests/app/main/views/organisations/test_organisation.py b/tests/app/main/views/organisations/test_organisation.py index 36e1b4cdf..6f33da32d 100644 --- a/tests/app/main/views/organisations/test_organisation.py +++ b/tests/app/main/views/organisations/test_organisation.py @@ -503,7 +503,7 @@ def test_organisation_services_filters_by_financial_year( '2019 to 2020 financial year ' '2018 to 2019 financial year' ) - assert normalize_spaces(page.select_one('.pill-selected-item').text) == ( + assert normalize_spaces(page.select_one('.pill-item--selected').text) == ( expected_selected ) diff --git a/tests/app/main/views/test_activity.py b/tests/app/main/views/test_activity.py index 9c5a8c7ab..1b793f771 100644 --- a/tests/app/main/views/test_activity.py +++ b/tests/app/main/views/test_activity.py @@ -692,7 +692,7 @@ def test_redacts_templates_that_should_be_redacted( @pytest.mark.parametrize( - "message_type, tablist_visible", [ + "message_type, nav_visible", [ ('email', True), ('sms', True), ('letter', False) @@ -707,7 +707,7 @@ def test_big_numbers_dont_show_for_letters( mock_get_service_data_retention, mock_get_no_api_keys, message_type, - tablist_visible, + nav_visible, ): page = client_request.get( 'main.view_notifications', @@ -717,7 +717,7 @@ def test_big_numbers_dont_show_for_letters( page=1, ) - assert (len(page.select("[role=tablist]")) > 0) == tablist_visible + assert (len(page.select(".pill")) > 0) == nav_visible assert (len(page.select("[type=search]")) > 0) is True diff --git a/tests/app/main/views/test_dashboard.py b/tests/app/main/views/test_dashboard.py index c748f9b92..01b9aacc9 100644 --- a/tests/app/main/views/test_dashboard.py +++ b/tests/app/main/views/test_dashboard.py @@ -950,12 +950,12 @@ def test_usage_page( mock_get_free_sms_fragment_limit.assert_called_with(SERVICE_ONE_ID, 2011) cols = page.find_all('div', {'class': 'govuk-grid-column-one-third'}) - nav = page.find('ul', {'class': 'pill', 'role': 'tablist'}) - nav_links = nav.find_all('a') + nav = page.find('ul', {'class': 'pill'}) + unselected_nav_links = nav.select('a:not(.pill-item--selected)') - assert normalize_spaces(nav.find('li', {'aria-selected': 'true'}).text) == '2011 to 2012 financial year' - assert normalize_spaces(nav_links[0].text) == '2010 to 2011 financial year' - assert normalize_spaces(nav_links[1].text) == '2009 to 2010 financial year' + assert normalize_spaces(nav.find('a', {'aria-current': 'page'}).text) == '2011 to 2012 financial year' + assert normalize_spaces(unselected_nav_links[0].text) == '2010 to 2011 financial year' + assert normalize_spaces(unselected_nav_links[1].text) == '2009 to 2010 financial year' assert '252,190' in cols[1].text assert 'Text messages' in cols[1].text @@ -992,12 +992,12 @@ def test_usage_page_with_letters( mock_get_free_sms_fragment_limit.assert_called_with(SERVICE_ONE_ID, 2011) cols = page.find_all('div', {'class': 'govuk-grid-column-one-third'}) - nav = page.find('ul', {'class': 'pill', 'role': 'tablist'}) - nav_links = nav.find_all('a') + nav = page.find('ul', {'class': 'pill'}) + unselected_nav_links = nav.select('a:not(.pill-item--selected)') - assert normalize_spaces(nav.find('li', {'aria-selected': 'true'}).text) == '2011 to 2012 financial year' - assert normalize_spaces(nav_links[0].text) == '2010 to 2011 financial year' - assert normalize_spaces(nav_links[1].text) == '2009 to 2010 financial year' + assert normalize_spaces(nav.find('a', {'aria-current': 'page'}).text) == '2011 to 2012 financial year' + assert normalize_spaces(unselected_nav_links[0].text) == '2010 to 2011 financial year' + assert normalize_spaces(unselected_nav_links[1].text) == '2009 to 2010 financial year' assert '252,190' in cols[1].text assert 'Text messages' in cols[1].text diff --git a/tests/app/main/views/test_jobs.py b/tests/app/main/views/test_jobs.py index 996d77dcc..cc5a9cb0d 100644 --- a/tests/app/main/views/test_jobs.py +++ b/tests/app/main/views/test_jobs.py @@ -188,7 +188,7 @@ def test_should_show_job_in_progress( ) assert [ normalize_spaces(link.text) - for link in page.select('.pill a') + for link in page.select('.pill a:not(.pill-item--selected)') ] == [ '10 sending', '0 delivered', '0 failed' ] @@ -213,7 +213,7 @@ def test_should_show_job_without_notifications( ) assert [ normalize_spaces(link.text) - for link in page.select('.pill a') + for link in page.select('.pill a:not(.pill-item--selected)') ] == [ '10 sending', '0 delivered', '0 failed' ] @@ -279,7 +279,7 @@ def test_should_show_old_job( service_id=SERVICE_ONE_ID, job_id=fake_uuid, ) - assert not page.select('.pill a') + assert not page.select('.pill') assert not page.select('p.hint') assert not page.select('a[download]') assert page.select_one('tbody').text.strip() == expected_message diff --git a/tests/app/main/views/test_template_folders.py b/tests/app/main/views/test_template_folders.py index b70a3cf79..ed8ca3533 100644 --- a/tests/app/main/views/test_template_folders.py +++ b/tests/app/main/views/test_template_folders.py @@ -429,7 +429,7 @@ def test_should_show_templates_folder_page( **expected_parent_link_args[index] ) - links_in_page = page.select('.pill a') + links_in_page = page.select('.pill a:not(.pill-item--selected)') assert len(links_in_page) == len(expected_nav_links) diff --git a/tests/app/main/views/test_templates.py b/tests/app/main/views/test_templates.py index b53f8b874..e531a33a4 100644 --- a/tests/app/main/views/test_templates.py +++ b/tests/app/main/views/test_templates.py @@ -181,7 +181,7 @@ def test_should_show_page_for_choosing_a_template( assert normalize_spaces(page.select_one('h1').text) == expected_page_title - links_in_page = page.select('.pill a') + links_in_page = page.select('.pill a:not(.pill-item--selected)') assert len(links_in_page) == len(expected_nav_links)