From f3baacfb563c50b8282a603816216581efbf73f8 Mon Sep 17 00:00:00 2001 From: Katie Smith Date: Wed, 12 Jan 2022 11:49:58 +0000 Subject: [PATCH] Stop showing link for cancelled org users --- .../organisation/users/index.html | 2 +- .../views/organisations/test_organisations.py | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/templates/views/organisations/organisation/users/index.html b/app/templates/views/organisations/organisation/users/index.html index 9880bf2d7..80d5db14a 100644 --- a/app/templates/views/organisations/organisation/users/index.html +++ b/app/templates/views/organisations/organisation/users/index.html @@ -54,7 +54,7 @@
{% if user.status == 'pending' %} Cancel invitation for {{ user.email_address }} - {% else %} + {% elif user.status != 'cancelled' %} Remove {{ user.name }} {{ user.email_address }} {% endif %}
diff --git a/tests/app/main/views/organisations/test_organisations.py b/tests/app/main/views/organisations/test_organisations.py index 7b2e06ceb..8ad264489 100644 --- a/tests/app/main/views/organisations/test_organisations.py +++ b/tests/app/main/views/organisations/test_organisations.py @@ -801,6 +801,26 @@ def test_manage_org_users_shows_correct_link_next_to_each_user( assert users[2].a['href'] == url_for('.edit_organisation_user', org_id=ORGANISATION_ID, user_id='5678') +def test_manage_org_users_shows_no_link_for_cancelled_users( + client_request, + mock_get_organisation, + mock_get_users_for_organisation, + sample_org_invite, + mocker, +): + sample_org_invite['status'] = 'cancelled' + mocker.patch('app.models.user.OrganisationInvitedUsers.client_method', return_value=[sample_org_invite]) + + page = client_request.get( + '.manage_org_users', + org_id=ORGANISATION_ID, + ) + users = page.find_all(class_='user-list-item') + + assert normalize_spaces(users[0].text) == 'invited_user@test.gov.uk (cancelled invite)' + assert not users[0].a + + @pytest.mark.parametrize('number_of_users', ( pytest.param(7, marks=pytest.mark.xfail), pytest.param(8),