mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-02 04:39:25 -04:00
Merge pull request #3885 from alphagov/live-broadcast-tour
Add a version of the tour for live services
This commit is contained in:
@@ -6,6 +6,7 @@ from flask import url_for
|
||||
from notifications_python_client.errors import HTTPError
|
||||
|
||||
import app
|
||||
from tests import service_json
|
||||
from tests.conftest import (
|
||||
SERVICE_ONE_ID,
|
||||
USER_ONE_ID,
|
||||
@@ -55,6 +56,44 @@ def test_existing_user_accept_invite_calls_api_and_redirects_to_dashboard(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('trial_mode, expected_endpoint', (
|
||||
(True, '.broadcast_tour'),
|
||||
(False, '.broadcast_tour_live'),
|
||||
))
|
||||
def test_broadcast_service_shows_tour(
|
||||
client,
|
||||
service_one,
|
||||
mock_check_invite_token,
|
||||
mock_get_unknown_user_by_email,
|
||||
mock_get_users_by_service,
|
||||
mock_accept_invite,
|
||||
mock_add_user_to_service,
|
||||
mocker,
|
||||
mock_events,
|
||||
mock_get_user,
|
||||
trial_mode,
|
||||
expected_endpoint,
|
||||
):
|
||||
service_one['permissions'] = ['broadcast']
|
||||
service_one['restricted'] = trial_mode
|
||||
|
||||
mocker.patch('app.service_api_client.get_service', return_value={
|
||||
'data': service_one,
|
||||
})
|
||||
|
||||
response = client.get(url_for(
|
||||
'main.accept_invite',
|
||||
token='thisisnotarealtoken'
|
||||
))
|
||||
assert response.status_code == 302
|
||||
assert response.location == url_for(
|
||||
expected_endpoint,
|
||||
service_id=SERVICE_ONE_ID,
|
||||
step_index=1,
|
||||
_external=True,
|
||||
)
|
||||
|
||||
|
||||
def test_existing_user_with_no_permissions_or_folder_permissions_accept_invite(
|
||||
client,
|
||||
mocker,
|
||||
@@ -573,6 +612,54 @@ def test_new_invited_user_verifies_and_added_to_service(
|
||||
assert page.find('h1').text == 'Dashboard'
|
||||
|
||||
|
||||
@pytest.mark.parametrize('service_permissions, trial_mode, expected_endpoint, extra_args', (
|
||||
([], True, 'main.service_dashboard', {}),
|
||||
([], False, 'main.service_dashboard', {}),
|
||||
(['broadcast'], True, 'main.broadcast_tour', {'step_index': 1}),
|
||||
(['broadcast'], False, 'main.broadcast_tour_live', {'step_index': 1}),
|
||||
))
|
||||
def test_new_invited_user_is_redirected_to_correct_place(
|
||||
mocker,
|
||||
client,
|
||||
sample_invite,
|
||||
mock_check_invite_token,
|
||||
mock_check_verify_code,
|
||||
mock_get_user,
|
||||
mock_dont_get_user_by_email,
|
||||
mock_add_user_to_service,
|
||||
mock_get_invited_user_by_id,
|
||||
mock_events,
|
||||
mock_get_service,
|
||||
service_permissions,
|
||||
trial_mode,
|
||||
expected_endpoint,
|
||||
extra_args,
|
||||
):
|
||||
mocker.patch('app.service_api_client.get_service', return_value={
|
||||
'data': service_json(
|
||||
sample_invite['service'],
|
||||
restricted=trial_mode,
|
||||
permissions=service_permissions,
|
||||
)
|
||||
})
|
||||
client.get(url_for('main.accept_invite', token='thisisnotarealtoken'))
|
||||
|
||||
with client.session_transaction() as session:
|
||||
session['user_details'] = {
|
||||
'email': sample_invite['email_address'],
|
||||
'id': sample_invite['id'],
|
||||
}
|
||||
|
||||
response = client.post(url_for('main.verify'), data={'sms_code': '12345'})
|
||||
assert response.status_code == 302
|
||||
assert response.location == url_for(
|
||||
expected_endpoint,
|
||||
service_id=sample_invite['service'],
|
||||
_external=True,
|
||||
**extra_args
|
||||
)
|
||||
|
||||
|
||||
def test_existing_user_accepts_and_sets_email_auth(
|
||||
client_request,
|
||||
api_user_active,
|
||||
|
||||
@@ -236,24 +236,27 @@ def test_cancel_broadcast_page_403_for_user_without_permission(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('step_index, expected_link_text, expected_link_href', (
|
||||
(1, 'Continue', partial(url_for, '.broadcast_tour', step_index=2)),
|
||||
(2, 'Continue', partial(url_for, '.broadcast_tour', step_index=3)),
|
||||
(3, 'Continue', partial(url_for, '.broadcast_tour', step_index=4)),
|
||||
(4, 'Continue', partial(url_for, '.broadcast_tour', step_index=5)),
|
||||
(5, 'Continue', partial(url_for, '.service_dashboard')),
|
||||
(6, 'Continue', partial(url_for, '.service_dashboard')),
|
||||
@pytest.mark.parametrize('endpoint, step_index, expected_link_text, expected_link_href', (
|
||||
('.broadcast_tour', 1, 'Continue', partial(url_for, '.broadcast_tour', step_index=2)),
|
||||
('.broadcast_tour', 2, 'Continue', partial(url_for, '.broadcast_tour', step_index=3)),
|
||||
('.broadcast_tour', 3, 'Continue', partial(url_for, '.broadcast_tour', step_index=4)),
|
||||
('.broadcast_tour', 4, 'Continue', partial(url_for, '.broadcast_tour', step_index=5)),
|
||||
('.broadcast_tour', 5, 'Continue', partial(url_for, '.service_dashboard')),
|
||||
('.broadcast_tour', 6, 'Continue', partial(url_for, '.service_dashboard')),
|
||||
('.broadcast_tour_live', 1, 'Continue', partial(url_for, '.broadcast_tour_live', step_index=2)),
|
||||
('.broadcast_tour_live', 2, 'Continue', partial(url_for, '.service_dashboard')),
|
||||
))
|
||||
def test_broadcast_tour_pages_have_continue_link(
|
||||
client_request,
|
||||
service_one,
|
||||
endpoint,
|
||||
step_index,
|
||||
expected_link_text,
|
||||
expected_link_href,
|
||||
):
|
||||
service_one['permissions'] += ['broadcast']
|
||||
page = client_request.get(
|
||||
'.broadcast_tour',
|
||||
endpoint,
|
||||
service_id=SERVICE_ONE_ID,
|
||||
step_index=step_index,
|
||||
)
|
||||
@@ -262,26 +265,31 @@ def test_broadcast_tour_pages_have_continue_link(
|
||||
assert link['href'] == expected_link_href(service_id=SERVICE_ONE_ID)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('step_index', (
|
||||
pytest.param(1, marks=pytest.mark.xfail),
|
||||
pytest.param(2, marks=pytest.mark.xfail),
|
||||
pytest.param(3, marks=pytest.mark.xfail),
|
||||
pytest.param(4, marks=pytest.mark.xfail),
|
||||
5,
|
||||
6,
|
||||
@pytest.mark.parametrize('endpoint, step_index', (
|
||||
pytest.param('.broadcast_tour', 1, marks=pytest.mark.xfail),
|
||||
pytest.param('.broadcast_tour', 2, marks=pytest.mark.xfail),
|
||||
pytest.param('.broadcast_tour', 3, marks=pytest.mark.xfail),
|
||||
pytest.param('.broadcast_tour', 4, marks=pytest.mark.xfail),
|
||||
('.broadcast_tour', 5),
|
||||
('.broadcast_tour', 6),
|
||||
('.broadcast_tour_live', 1),
|
||||
('.broadcast_tour_live', 2),
|
||||
))
|
||||
def test_broadcast_tour_page_4_shows_service_name(
|
||||
def test_some_broadcast_tour_pages_show_service_name(
|
||||
client_request,
|
||||
service_one,
|
||||
endpoint,
|
||||
step_index,
|
||||
):
|
||||
service_one['permissions'] += ['broadcast']
|
||||
page = client_request.get(
|
||||
'.broadcast_tour',
|
||||
endpoint,
|
||||
service_id=SERVICE_ONE_ID,
|
||||
step_index=step_index,
|
||||
)
|
||||
assert normalize_spaces(page.select_one('.navigation-service').text) == (
|
||||
assert normalize_spaces(
|
||||
page.select_one('.navigation-service').text
|
||||
).startswith(
|
||||
'service one Training'
|
||||
)
|
||||
|
||||
@@ -326,8 +334,8 @@ def test_broadcast_tour_page_4_shows_service_name(
|
||||
'test',
|
||||
'vodafone',
|
||||
'.navigation-service-type.navigation-service-type--live',
|
||||
'service one Test (vodafone) Switch service',
|
||||
'Test (vodafone)',
|
||||
'service one Test (Vodafone) Switch service',
|
||||
'Test (Vodafone)',
|
||||
),
|
||||
(
|
||||
False,
|
||||
@@ -371,15 +379,21 @@ def test_broadcast_service_shows_live_or_training(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('step_index', (0, 7))
|
||||
@pytest.mark.parametrize('endpoint, step_index', (
|
||||
('.broadcast_tour', 0),
|
||||
('.broadcast_tour', 7),
|
||||
('.broadcast_tour_live', 0),
|
||||
('.broadcast_tour_live', 3),
|
||||
))
|
||||
def test_broadcast_tour_page_404s_out_of_range(
|
||||
client_request,
|
||||
service_one,
|
||||
endpoint,
|
||||
step_index,
|
||||
):
|
||||
service_one['permissions'] += ['broadcast']
|
||||
client_request.get(
|
||||
'.broadcast_tour',
|
||||
endpoint,
|
||||
service_id=SERVICE_ONE_ID,
|
||||
step_index=step_index,
|
||||
_expected_status=404,
|
||||
|
||||
@@ -39,6 +39,7 @@ EXCLUDED_ENDPOINTS = tuple(map(Navigation.get_endpoint_with_blueprint, {
|
||||
'broadcast_dashboard_rejected',
|
||||
'broadcast_dashboard_updates',
|
||||
'broadcast_tour',
|
||||
'broadcast_tour_live',
|
||||
'callbacks',
|
||||
'cancel_broadcast_message',
|
||||
'cancel_invited_org_user',
|
||||
|
||||
Reference in New Issue
Block a user