mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-18 21:49:37 -04:00
Reduce usage of the platform admin index page
This page is slow to load which means: - it’s annoying for us - it’s potentially causing load on the database This commit does two things to reduce the amount we’re unnecessarily looking at this page: 1. Avoid redirecting to it when signing in as a platform admin user 2. Don’t go directly to it when clicking ‘platform admin’ at the top, but instead show a holding page (there’s a fair chance you’ve clicked that link in order to go and manage some email branding or find a user, not wait for stats to load)
This commit is contained in:
@@ -37,6 +37,7 @@ def test_should_redirect_if_not_logged_in(
|
||||
|
||||
@pytest.mark.parametrize('endpoint', [
|
||||
'main.platform_admin',
|
||||
'main.platform_admin_splash_page',
|
||||
'main.live_services',
|
||||
'main.trial_services',
|
||||
])
|
||||
@@ -589,6 +590,20 @@ def test_get_tech_failure_status_box_data_removes_percentage_data():
|
||||
assert 'percentage' not in tech_failure_data
|
||||
|
||||
|
||||
def test_platform_admin_splash_doesnt_talk_to_api(
|
||||
client_request,
|
||||
platform_admin_user,
|
||||
):
|
||||
|
||||
client_request.login(platform_admin_user)
|
||||
|
||||
page = client_request.get('main.platform_admin_splash_page')
|
||||
|
||||
assert page.select_one('main .govuk-body a')['href'] == url_for(
|
||||
'main.platform_admin',
|
||||
)
|
||||
|
||||
|
||||
def test_platform_admin_with_start_and_end_dates_provided(mocker, platform_admin_client):
|
||||
start_date = '2018-01-01'
|
||||
end_date = '2018-06-01'
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import pytest
|
||||
from bs4 import BeautifulSoup
|
||||
from flask import url_for
|
||||
from freezegun import freeze_time
|
||||
@@ -107,6 +108,9 @@ def test_should_login_user_and_not_redirect_to_external_url(
|
||||
assert response.location == url_for('main.show_accounts_or_dashboard', _external=True)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('platform_admin', (
|
||||
True, False,
|
||||
))
|
||||
@freeze_time('2020-01-27T12:00:00')
|
||||
def test_should_login_user_and_redirect_to_show_accounts(
|
||||
client,
|
||||
@@ -115,12 +119,14 @@ def test_should_login_user_and_redirect_to_show_accounts(
|
||||
mock_get_user_by_email,
|
||||
mock_check_verify_code,
|
||||
mock_create_event,
|
||||
platform_admin,
|
||||
):
|
||||
with client.session_transaction() as session:
|
||||
session['user_details'] = {
|
||||
'id': api_user_active['id'],
|
||||
'email': api_user_active['email_address']}
|
||||
api_user_active['email_access_validated_at'] = '2020-01-23T11:35:21.726132Z'
|
||||
api_user_active['platform_admin'] = platform_admin
|
||||
|
||||
response = client.post(url_for('main.two_factor'),
|
||||
data={'sms_code': '12345'})
|
||||
|
||||
Reference in New Issue
Block a user