Add confirmation banner when cancelling user invites

This shows the green banner with a tick when cancelling a user's
invitation to a service or organisation. The accessibility audit noted
that 'When cancelling an invite a new page loads, however, there is no
immediate indication that the invite has been cancelled.'

In order to display the invited user's email address as part of the
flash message, this adds new methods to the api clients for invites to get
a single invite.
This commit is contained in:
Katie Smith
2020-08-17 14:30:09 +01:00
parent ecc44d5d56
commit 895a9df55a
8 changed files with 82 additions and 7 deletions

View File

@@ -631,6 +631,34 @@ def test_organisation_trial_mode_services_doesnt_work_if_not_platform_admin(
)
def test_cancel_invited_org_user_cancels_user_invitations(
client_request,
mock_get_invites_for_organisation,
sample_org_invite,
mock_get_organisation,
mock_get_users_for_organisation,
mocker,
):
mock_cancel = mocker.patch('app.org_invite_api_client.cancel_invited_user')
mocker.patch('app.org_invite_api_client.get_invited_user', return_value=sample_org_invite)
page = client_request.get(
'main.cancel_invited_org_user',
org_id=ORGANISATION_ID,
invited_user_id=sample_org_invite['id'],
_follow_redirects=True
)
assert normalize_spaces(page.h1.text) == 'Team members'
flash_banner = normalize_spaces(
page.find('div', class_='banner-default-with-tick').text
)
assert flash_banner == f"Invitation cancelled for {sample_org_invite['email_address']}"
mock_cancel.assert_called_once_with(
org_id=ORGANISATION_ID,
invited_user_id=sample_org_invite['id'],
)
def test_organisation_settings_platform_admin_only(
client_request,
mock_get_organisation,

View File

@@ -1002,18 +1002,25 @@ def test_cancel_invited_user_cancels_user_invitations(
mock_get_invites_for_service,
sample_invite,
active_user_with_permissions,
mock_get_users_by_service,
mock_get_template_folders,
mocker,
):
mock_cancel = mocker.patch('app.invite_api_client.cancel_invited_user')
client_request.get(
mocker.patch('app.invite_api_client.get_invited_user', return_value=sample_invite)
page = client_request.get(
'main.cancel_invited_user',
service_id=SERVICE_ONE_ID,
invited_user_id=sample_invite['id'],
_expected_status=302,
_expected_redirect=url_for(
'main.manage_users', service_id=SERVICE_ONE_ID, _external=True
),
_follow_redirects=True,
)
assert normalize_spaces(page.h1.text) == 'Team members'
flash_banner = normalize_spaces(
page.find('div', class_='banner-default-with-tick').text
)
assert flash_banner == f"Invitation cancelled for {sample_invite['email_address']}"
mock_cancel.assert_called_once_with(
service_id=SERVICE_ONE_ID,
invited_user_id=sample_invite['id'],