Migrate two more tests to the branding utility

All of the mock / UI assertions in these tests are covered by the
tests above them - these tests were mostly targetting which options
were being shown, which we can check at a lower level.
This commit is contained in:
Ben Thorner
2022-03-03 12:58:44 +00:00
parent 1946d3c928
commit 5a39e310aa
2 changed files with 57 additions and 111 deletions

View File

@@ -4850,117 +4850,6 @@ def test_letter_branding_request_page_when_no_branding_is_set(
assert not page.select('.conditional-radios-panel')
@pytest.mark.parametrize('branding_type', ['email', 'letter'])
@pytest.mark.parametrize('organisation_type, expected_options', (
('local', [
('organisation', 'Test Organisation'),
('something_else', 'Something else'),
]),
('nhs_central', [
('nhs', 'NHS'),
('something_else', 'Something else'),
]),
('nhs_local', [
('nhs', 'NHS'),
('something_else', 'Something else'),
]),
('nhs_gp', [
('nhs', 'NHS'),
('something_else', 'Something else'),
]),
('emergency_service', [
('organisation', 'Test Organisation'),
('something_else', 'Something else'),
]),
('other', [
('organisation', 'Test Organisation'),
('something_else', 'Something else'),
]),
))
def test_branding_request_page_when_no_branding_is_set_but_organisation_exists(
mocker,
service_one,
client_request,
mock_get_email_branding,
mock_get_letter_branding_by_id,
mock_get_service_organisation,
organisation_type,
expected_options,
branding_type
):
service_one['{}_branding'.format(branding_type)] = None
mocker.patch(
'app.organisations_client.get_organisation',
return_value=organisation_json(organisation_type=organisation_type),
)
page = client_request.get(
f'.{branding_type}_branding_request', service_id=SERVICE_ONE_ID
)
assert mock_get_email_branding.called is False
assert mock_get_letter_branding_by_id.called is False
assert [
(
radio['value'],
page.select_one('label[for={}]'.format(radio['id'])).text.strip()
)
for radio in page.select('input[type=radio]')
] == expected_options
button_text = normalize_spaces(page.select_one('.page-footer button').text)
if branding_type == 'email':
assert button_text == 'Continue'
else:
assert button_text == 'Request new branding'
@pytest.mark.parametrize('organisation_type, expected_options, branding_type', (
('central', [
('govuk_and_org', 'GOV.UK and Test Organisation'),
('organisation', 'Test Organisation'),
('something_else', 'Something else'),
], 'email'),
('central', [
('organisation', 'Test Organisation'),
('something_else', 'Something else'),
], 'letter'),
))
def test_branding_request_page_when_no_branding_is_set_but_organisation_exists_central_org(
mocker,
service_one,
client_request,
mock_get_email_branding,
mock_get_letter_branding_by_id,
mock_get_service_organisation,
organisation_type,
expected_options,
branding_type
):
service_one['{}_branding'.format(branding_type)] = None
mocker.patch(
'app.organisations_client.get_organisation',
return_value=organisation_json(organisation_type=organisation_type),
)
page = client_request.get(
f'.{branding_type}_branding_request', service_id=SERVICE_ONE_ID
)
assert mock_get_email_branding.called is False
assert mock_get_letter_branding_by_id.called is False
assert [
(
radio['value'],
page.select_one('label[for={}]'.format(radio['id'])).text.strip()
)
for radio in page.select('input[type=radio]')
] == expected_options
def test_email_branding_request_page_when_email_branding_is_set(
mocker,
service_one,