mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 15:57:23 -04:00
Let users filter by type of event
At the moment we have two types of event, ‘service’ events and ‘API key’ events. They are munged together which is useful initially, but could get noisy. This commit adds filters (copied from the choose template page) that let users narrow down the list to one of the two types of event. This might help users get a clearer picture of what’s going on.
This commit is contained in:
@@ -1,24 +1,10 @@
|
||||
import pytest
|
||||
|
||||
from tests.conftest import SERVICE_ONE_ID, normalize_spaces
|
||||
|
||||
|
||||
def test_history(
|
||||
client_request,
|
||||
mock_get_service_history,
|
||||
):
|
||||
page = client_request.get('main.history', service_id=SERVICE_ONE_ID)
|
||||
|
||||
assert page.select_one('h1').text == 'Service and API key history'
|
||||
|
||||
headings = page.select('main h2')
|
||||
events = page.select('main ul')
|
||||
|
||||
assert len(headings) == len(events)
|
||||
assert [
|
||||
(
|
||||
normalize_spaces(headings[index].text),
|
||||
normalize_spaces(events[index].text),
|
||||
) for index in range(len(headings))
|
||||
] == [
|
||||
@pytest.mark.parametrize('extra_args, expected_headings_and_events', (
|
||||
({}, [
|
||||
(
|
||||
'12 December',
|
||||
(
|
||||
@@ -44,9 +30,70 @@ def test_history(
|
||||
'10 October',
|
||||
(
|
||||
'6ce466d0-fd6a-11e5-82f5-e0accb9d11a6 11:10am '
|
||||
'Created this service and called it ‘Example service’ '
|
||||
'Created an API key called ‘Good key’ '
|
||||
'6ce466d0-fd6a-11e5-82f5-e0accb9d11a6 2:01am '
|
||||
'Created this service and called it ‘Example service’'
|
||||
),
|
||||
),
|
||||
]),
|
||||
({'selected': 'api'}, [
|
||||
(
|
||||
'11 November',
|
||||
(
|
||||
'6ce466d0-fd6a-11e5-82f5-e0accb9d11a6 12:12pm '
|
||||
'Revoked the ‘Bad key’ API key'
|
||||
),
|
||||
),
|
||||
(
|
||||
'11 November',
|
||||
(
|
||||
'6ce466d0-fd6a-11e5-82f5-e0accb9d11a6 11:11am '
|
||||
'Created an API key called ‘Bad key’'
|
||||
),
|
||||
),
|
||||
(
|
||||
'10 October',
|
||||
(
|
||||
'6ce466d0-fd6a-11e5-82f5-e0accb9d11a6 11:10am '
|
||||
'Created an API key called ‘Good key’'
|
||||
),
|
||||
),
|
||||
]
|
||||
]),
|
||||
({'selected': 'service'}, [
|
||||
(
|
||||
'12 December',
|
||||
(
|
||||
'6ce466d0-fd6a-11e5-82f5-e0accb9d11a6 12:12pm '
|
||||
'Renamed this service from ‘Example service’ to ‘Real service’'
|
||||
),
|
||||
),
|
||||
(
|
||||
'10 October',
|
||||
(
|
||||
'6ce466d0-fd6a-11e5-82f5-e0accb9d11a6 2:01am '
|
||||
'Created this service and called it ‘Example service’'
|
||||
),
|
||||
),
|
||||
]),
|
||||
))
|
||||
def test_history(
|
||||
client_request,
|
||||
mock_get_service_history,
|
||||
mock_get_users_by_service,
|
||||
extra_args,
|
||||
expected_headings_and_events,
|
||||
):
|
||||
page = client_request.get('main.history', service_id=SERVICE_ONE_ID, **extra_args)
|
||||
|
||||
assert page.select_one('h1').text == 'Audit events'
|
||||
|
||||
headings = page.select('main h2.heading-small')
|
||||
events = page.select('main ul.bottom-gutter')
|
||||
|
||||
assert len(headings) == len(events) == len(expected_headings_and_events)
|
||||
|
||||
for index, expected in enumerate(expected_headings_and_events):
|
||||
assert (
|
||||
normalize_spaces(headings[index].text),
|
||||
normalize_spaces(events[index].text),
|
||||
) == expected
|
||||
|
||||
Reference in New Issue
Block a user