Make the broadcast dashboard update via AJAX

Same technique as we use for other pages that update via AJAX.

I’ve split the page up into separate chunks because the DiffDOM library
we use finds it easier to work out what’s changed when there are fewer
elements/a shallower tree.
This commit is contained in:
Chris Hill-Scott
2020-07-14 13:39:29 +01:00
parent 414e4b5834
commit 5229373341
5 changed files with 104 additions and 47 deletions

View File

@@ -1,3 +1,5 @@
import json
import pytest
from flask import url_for
from freezegun import freeze_time
@@ -10,6 +12,7 @@ sample_uuid = sample_uuid()
@pytest.mark.parametrize('endpoint, extra_args', (
('.broadcast_dashboard', {}),
('.broadcast_dashboard_updates', {}),
('.broadcast', {'template_id': sample_uuid}),
('.preview_broadcast_areas', {'broadcast_message_id': sample_uuid}),
('.choose_broadcast_library', {'broadcast_message_id': sample_uuid}),
@@ -88,6 +91,28 @@ def test_broadcast_dashboard(
]
@freeze_time('2020-02-20 02:20')
def test_broadcast_dashboard_json(
logged_in_client,
service_one,
mock_get_broadcast_messages,
):
service_one['permissions'] += ['broadcast']
response = logged_in_client.get(url_for(
'.broadcast_dashboard_updates',
service_id=SERVICE_ONE_ID,
))
assert response.status_code == 200
json_response = json.loads(response.get_data(as_text=True))
assert json_response.keys() == {'live_broadcasts', 'previous_broadcasts'}
assert 'Live until tomorrow at 2:20am' in json_response['live_broadcasts']
assert 'Finished yesterday at 8:20pm' in json_response['previous_broadcasts']
def test_broadcast_page(
client_request,
service_one,