Move back link outside of main where it was used in the page header

The page_header macro includes an optional back link. Since the
page_header is always used inside `<main>`, where the back link should
not be, this stops setting the back link in the page header and instead
sets it in the new `backLink` block.
This commit is contained in:
Katie Smith
2021-07-30 18:23:12 +01:00
parent 1860b2b690
commit 0f0b8b8ae4
120 changed files with 773 additions and 538 deletions

View File

@@ -19,14 +19,11 @@ class _MockS3Object():
return {'Body': BytesIO(self.data)}
@pytest.mark.parametrize('agreement_signed, crown, expected_links', [
@pytest.mark.parametrize('agreement_signed, crown, expected_back_link, expected_other_links', [
(
True, True,
partial(url_for, 'main.request_to_go_live', service_id=SERVICE_ONE_ID),
[
(
['govuk-back-link'],
partial(url_for, 'main.request_to_go_live', service_id=SERVICE_ONE_ID),
),
(
['govuk-link', 'govuk-link--no-visited-state'],
partial(url_for, 'main.service_download_agreement', service_id=SERVICE_ONE_ID),
@@ -35,11 +32,8 @@ class _MockS3Object():
),
(
False, False,
partial(url_for, 'main.request_to_go_live', service_id=SERVICE_ONE_ID),
[
(
['govuk-back-link'],
partial(url_for, 'main.request_to_go_live', service_id=SERVICE_ONE_ID),
),
(
['govuk-link', 'govuk-link--no-visited-state'],
partial(url_for, 'main.service_download_agreement', service_id=SERVICE_ONE_ID),
@@ -52,11 +46,8 @@ class _MockS3Object():
),
(
False, True,
partial(url_for, 'main.request_to_go_live', service_id=SERVICE_ONE_ID),
[
(
['govuk-back-link'],
partial(url_for, 'main.request_to_go_live', service_id=SERVICE_ONE_ID),
),
(
['govuk-link', 'govuk-link--no-visited-state'],
partial(url_for, 'main.service_download_agreement', service_id=SERVICE_ONE_ID),
@@ -69,11 +60,8 @@ class _MockS3Object():
),
(
None, None,
partial(url_for, 'main.request_to_go_live', service_id=SERVICE_ONE_ID),
[
(
['govuk-back-link'],
partial(url_for, 'main.request_to_go_live', service_id=SERVICE_ONE_ID),
),
(
['govuk-link', 'govuk-link--no-visited-state'],
partial(url_for, 'main.support'),
@@ -89,7 +77,8 @@ def test_show_agreement_page(
mock_has_jobs,
agreement_signed,
crown,
expected_links,
expected_back_link,
expected_other_links,
):
org = organisation_json(
crown=crown,
@@ -98,10 +87,14 @@ def test_show_agreement_page(
mocker.patch('app.organisations_client.get_organisation', return_value=org)
page = client_request.get('main.service_agreement', service_id=SERVICE_ONE_ID)
back_link = page.select_one('.govuk-back-link')
assert back_link['href'] == expected_back_link()
links = page.select('main .govuk-grid-column-five-sixths a')
assert len(links) == len(expected_links)
assert len(links) == len(expected_other_links)
for index, link in enumerate(links):
classes, url = expected_links[index]
classes, url = expected_other_links[index]
assert link.get('class', []) == classes
assert link['href'] == url()

View File

@@ -629,11 +629,11 @@ def test_bat_email_page(
assert response.status_code == 200
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
assert page.select('main a')[0].text == 'Back'
assert page.select('main a')[0]['href'] == url_for('main.support')
assert page.select('main a')[2].text == 'Fill in this form'
assert page.select('main a')[2]['href'] == url_for('main.feedback', ticket_type=PROBLEM_TICKET_TYPE, severe='no')
next_page_response = client.get(page.select('main a')[2]['href'])
assert page.select_one('.govuk-back-link').text == 'Back'
assert page.select_one('.govuk-back-link')['href'] == url_for('main.support')
assert page.select('main a')[1].text == 'Fill in this form'
assert page.select('main a')[1]['href'] == url_for('main.feedback', ticket_type=PROBLEM_TICKET_TYPE, severe='no')
next_page_response = client.get(page.select('main a')[1]['href'])
next_page = BeautifulSoup(next_page_response.data.decode('utf-8'), 'html.parser')
assert next_page.h1.text.strip() == 'Report a problem'

View File

@@ -1550,8 +1550,7 @@ def test_send_one_off_offers_link_to_upload(
template_id=fake_uuid,
_follow_redirects=True,
)
back_link = page.select('main a')[0]
back_link = page.select_one('.govuk-back-link')
link = page.select_one('form a')
assert back_link.text.strip() == 'Back'
@@ -1662,8 +1661,8 @@ def test_link_to_upload_not_offered_when_entering_personalisation(
# Were entering personalisation
assert page.select_one('input[type=text]')['name'] == 'placeholder_value'
assert page.select_one('label[for=placeholder_value]').text.strip() == 'name'
# …but first link on the page is Back, so not preceeded by Upload
assert page.select_one('main a').text == 'Back'
# No Upload link shown
assert len(page.select('main a')) == 0
assert 'Upload' not in page.select_one('main').text