Add tests for sort order of branding radios

This commit is contained in:
Tom Byers
2018-08-15 16:10:25 +01:00
parent 93d3027d1f
commit bdde98e9ba
2 changed files with 28 additions and 14 deletions

View File

@@ -20,15 +20,19 @@ def test_email_branding_page_shows_full_branding_list(
assert response.status_code == 200
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
radio_labels = page.select('div.multiple-choice > label')
brand_names = [element.get_text().strip() for idx, element in enumerate(radio_labels)]
assert normalize_spaces(
page.select_one('h1').text
) == "Select an email branding to update or create a new email branding"
first_label = page.select('div.multiple-choice > label')[0]
first_label = radio_labels[0]
assert normalize_spaces(first_label.text) == 'org 1'
assert brand_names == [
'org 1', 'org 2', 'org 3', 'org 4', 'org 5', 'Create a new email branding']
assert normalize_spaces((page.select('div.multiple-choice > label')[-1]).text) == 'Create a new email branding'
assert normalize_spaces((radio_labels[-1]).text) == 'Create a new email branding'
def test_edit_email_branding_shows_the_correct_branding_info(

View File

@@ -1753,20 +1753,30 @@ def test_should_show_branding_styles(
))
assert response.status_code == 200
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
branding_style_choices = page.find_all('input', attrs={"name": "branding_style"})
assert page.find('input', attrs={"id": "branding_style-0"})['value'] == 'None'
assert page.find('input', attrs={"id": "branding_style-1"})['value'] == '1'
assert page.find('input', attrs={"id": "branding_style-2"})['value'] == '2'
assert page.find('input', attrs={"id": "branding_style-3"})['value'] == '3'
assert page.find('input', attrs={"id": "branding_style-4"})['value'] == '4'
assert page.find('input', attrs={"id": "branding_style-5"})['value'] == '5'
radio_labels = [
page.find('label', attrs={"for": branding_style_choices[idx]['id']}).get_text().strip()
for idx, element in enumerate(branding_style_choices)]
assert 'checked' in page.find('input', attrs={"id": "branding_style-0"}).attrs
assert 'checked' not in page.find('input', attrs={"id": "branding_style-1"}).attrs
assert 'checked' not in page.find('input', attrs={"id": "branding_style-2"}).attrs
assert 'checked' not in page.find('input', attrs={"id": "branding_style-3"}).attrs
assert 'checked' not in page.find('input', attrs={"id": "branding_style-4"}).attrs
assert 'checked' not in page.find('input', attrs={"id": "branding_style-5"}).attrs
assert len(branding_style_choices) == 6
assert branding_style_choices[0]['value'] == 'None'
assert branding_style_choices[1]['value'] == '1'
assert branding_style_choices[2]['value'] == '2'
assert branding_style_choices[3]['value'] == '3'
assert branding_style_choices[4]['value'] == '4'
assert branding_style_choices[5]['value'] == '5'
# radios should be in alphabetical order, based on their labels
assert radio_labels == ['None', 'org 1', 'org 2', 'org 3', 'org 4', 'org 5']
assert 'checked' in branding_style_choices[0].attrs
assert 'checked' not in branding_style_choices[1].attrs
assert 'checked' not in branding_style_choices[2].attrs
assert 'checked' not in branding_style_choices[3].attrs
assert 'checked' not in branding_style_choices[4].attrs
assert 'checked' not in branding_style_choices[5].attrs
app.email_branding_client.get_all_email_branding.assert_called_once_with()
app.service_api_client.get_service.assert_called_once_with(service_one['id'])