Make archive/suspend links not buttons

They don’t immediately perform an action, so semantically they are
links, not buttons.
This commit is contained in:
Chris Hill-Scott
2019-04-23 10:42:37 +01:00
parent 7c8ce6c62a
commit d3caaf94b1
2 changed files with 36 additions and 20 deletions

View File

@@ -353,26 +353,29 @@
{% endcall %}
<ul>
<p>
{% if current_service.active %}
<li class="bottom-gutter">
<a href="{{ url_for('.archive_service', service_id=current_service.id) }}" class="button">
<span class="page-footer-delete-link page-footer-delete-link-without-button">
<a href="{{ url_for('.archive_service', service_id=current_service.id) }}">
Archive service
</a>
</li>
<li class="bottom-gutter">
<a href="{{ url_for('.suspend_service', service_id=current_service.id) }}" class="button">
Suspend service
</a>
</li>
</span>
<span class="page-footer-delete-link">
<a href="{{ url_for('.suspend_service', service_id=current_service.id) }}" class="page-footer-delete-link">
Suspend service
</a>
</span>
{% else %}
<li class="bottom-gutter">
<a href="{{ url_for('.resume_service', service_id=current_service.id) }}" class="button">
<div class="hint bottom-gutter-1-2">
Service suspended
</div>
<span class="page-footer-delete-link page-footer-delete-link-without-button">
<a href="{{ url_for('.resume_service', service_id=current_service.id) }}">
Resume service
</a>
</li>
</span>
{% endif %}
</ul>
</p>
</div>
{% endif %}

View File

@@ -92,16 +92,29 @@ def test_service_setting_toggles_show(get_service_settings_page, service_one, se
assert normalize_spaces(page.find('a', {'href': button_url}).find_parent('tr').text.strip()) == text
@pytest.mark.parametrize('service_fields, endpoint, kwargs, text', [
({'active': True}, '.archive_service', {}, 'Archive service'),
({'active': True}, '.suspend_service', {}, 'Suspend service'),
({'active': False}, '.resume_service', {}, 'Resume service'),
@pytest.mark.parametrize('service_fields, endpoint, index, text', [
({'active': True}, '.archive_service', 0, 'Archive service'),
({'active': True}, '.suspend_service', 1, 'Suspend service'),
({'active': False}, '.resume_service', 0, 'Resume service'),
pytest.param(
{'active': False}, '.archive_service', 1, 'Resume service',
marks=pytest.mark.xfail(raises=IndexError)
)
])
def test_service_setting_button_toggles(get_service_settings_page, service_one, service_fields, endpoint, kwargs, text):
button_url = url_for(endpoint, **kwargs, service_id=service_one['id'])
def test_service_setting_button_toggles(
get_service_settings_page,
service_one,
service_fields,
endpoint,
index,
text,
):
button_url = url_for(endpoint, service_id=service_one['id'])
service_one.update(service_fields)
page = get_service_settings_page()
assert normalize_spaces(page.find('a', {'class': 'button', 'href': button_url}).text.strip()) == text
link = page.select('.page-footer-delete-link a')[index]
assert normalize_spaces(link.text) == text
assert link['href'] == button_url
@pytest.mark.parametrize('permissions,permissions_text,visible', [