Fix unit tests for changes to the pill component.

This commit is contained in:
Rebecca Law
2020-09-08 10:12:23 +01:00
committed by Tom Byers
parent 452e253e2c
commit 7cae303104
7 changed files with 21 additions and 20 deletions
+2 -1
View File
@@ -1,6 +1,7 @@
{% from "components/big-number.html" import big_number %} {% from "components/big-number.html" import big_number %}
{% from "components/message-count-label.html" import message_count_label %} {% 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/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 %} {% from "components/pill.html" import pill %}
{% extends "withnav_template.html" %} {% extends "withnav_template.html" %}
@@ -11,7 +12,7 @@
{% block maincolumn_content %} {% block maincolumn_content %}
<h1 class='heading-medium'>Usage</h1> {{ page_header('Usage', size='medium') }}
<div class="bottom-gutter"> <div class="bottom-gutter">
{{ pill(years, selected_year, big_number_args={'smallest': True}) }} {{ pill(years, selected_year, big_number_args={'smallest': True}) }}
@@ -503,7 +503,7 @@ def test_organisation_services_filters_by_financial_year(
'2019 to 2020 financial year ' '2019 to 2020 financial year '
'2018 to 2019 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 expected_selected
) )
+3 -3
View File
@@ -692,7 +692,7 @@ def test_redacts_templates_that_should_be_redacted(
@pytest.mark.parametrize( @pytest.mark.parametrize(
"message_type, tablist_visible", [ "message_type, nav_visible", [
('email', True), ('email', True),
('sms', True), ('sms', True),
('letter', False) ('letter', False)
@@ -707,7 +707,7 @@ def test_big_numbers_dont_show_for_letters(
mock_get_service_data_retention, mock_get_service_data_retention,
mock_get_no_api_keys, mock_get_no_api_keys,
message_type, message_type,
tablist_visible, nav_visible,
): ):
page = client_request.get( page = client_request.get(
'main.view_notifications', 'main.view_notifications',
@@ -717,7 +717,7 @@ def test_big_numbers_dont_show_for_letters(
page=1, 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 assert (len(page.select("[type=search]")) > 0) is True
+10 -10
View File
@@ -950,12 +950,12 @@ def test_usage_page(
mock_get_free_sms_fragment_limit.assert_called_with(SERVICE_ONE_ID, 2011) mock_get_free_sms_fragment_limit.assert_called_with(SERVICE_ONE_ID, 2011)
cols = page.find_all('div', {'class': 'govuk-grid-column-one-third'}) cols = page.find_all('div', {'class': 'govuk-grid-column-one-third'})
nav = page.find('ul', {'class': 'pill', 'role': 'tablist'}) nav = page.find('ul', {'class': 'pill'})
nav_links = nav.find_all('a') 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.find('a', {'aria-current': 'page'}).text) == '2011 to 2012 financial year'
assert normalize_spaces(nav_links[0].text) == '2010 to 2011 financial year' assert normalize_spaces(unselected_nav_links[0].text) == '2010 to 2011 financial year'
assert normalize_spaces(nav_links[1].text) == '2009 to 2010 financial year' assert normalize_spaces(unselected_nav_links[1].text) == '2009 to 2010 financial year'
assert '252,190' in cols[1].text assert '252,190' in cols[1].text
assert 'Text messages' 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) mock_get_free_sms_fragment_limit.assert_called_with(SERVICE_ONE_ID, 2011)
cols = page.find_all('div', {'class': 'govuk-grid-column-one-third'}) cols = page.find_all('div', {'class': 'govuk-grid-column-one-third'})
nav = page.find('ul', {'class': 'pill', 'role': 'tablist'}) nav = page.find('ul', {'class': 'pill'})
nav_links = nav.find_all('a') 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.find('a', {'aria-current': 'page'}).text) == '2011 to 2012 financial year'
assert normalize_spaces(nav_links[0].text) == '2010 to 2011 financial year' assert normalize_spaces(unselected_nav_links[0].text) == '2010 to 2011 financial year'
assert normalize_spaces(nav_links[1].text) == '2009 to 2010 financial year' assert normalize_spaces(unselected_nav_links[1].text) == '2009 to 2010 financial year'
assert '252,190' in cols[1].text assert '252,190' in cols[1].text
assert 'Text messages' in cols[1].text assert 'Text messages' in cols[1].text
+3 -3
View File
@@ -188,7 +188,7 @@ def test_should_show_job_in_progress(
) )
assert [ assert [
normalize_spaces(link.text) 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' '10 sending', '0 delivered', '0 failed'
] ]
@@ -213,7 +213,7 @@ def test_should_show_job_without_notifications(
) )
assert [ assert [
normalize_spaces(link.text) 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' '10 sending', '0 delivered', '0 failed'
] ]
@@ -279,7 +279,7 @@ def test_should_show_old_job(
service_id=SERVICE_ONE_ID, service_id=SERVICE_ONE_ID,
job_id=fake_uuid, 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('p.hint')
assert not page.select('a[download]') assert not page.select('a[download]')
assert page.select_one('tbody').text.strip() == expected_message assert page.select_one('tbody').text.strip() == expected_message
@@ -429,7 +429,7 @@ def test_should_show_templates_folder_page(
**expected_parent_link_args[index] **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) assert len(links_in_page) == len(expected_nav_links)
+1 -1
View File
@@ -181,7 +181,7 @@ def test_should_show_page_for_choosing_a_template(
assert normalize_spaces(page.select_one('h1').text) == expected_page_title 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) assert len(links_in_page) == len(expected_nav_links)