Convert frontend display to be just UTC (#540)

This changeset converts the display of dates and times to be just UTC to match the recent changes in the backend.  This unwinds a bit of work that was done previously and allows us to start with a clean slate in how we want to approach displaying dates and times going forward. It also adds a bit of explanatory text to help users.

Signed-off-by: Carlo Costino <carlo.costino@gsa.gov>
Co-authored-by: stvnrlly <steven.reilly@gsa.gov>
This commit is contained in:
Carlo Costino
2023-06-12 15:49:48 -04:00
committed by GitHub
parent da623c87d6
commit 92d25f5a69
19 changed files with 114 additions and 110 deletions

View File

@@ -4,28 +4,28 @@ from freezegun import freeze_time
from app.main.forms import ChooseTimeForm
@freeze_time("2016-01-01 16:09:00.061258")
@freeze_time("2016-01-01 11:09:00.061258")
def test_form_contains_next_24h(notify_admin):
choices = ChooseTimeForm().scheduled_for.choices
# Friday
assert choices[0] == ('', 'Now')
assert choices[1] == ('2016-01-01T17:00:00', 'Today at noon ET')
assert choices[13] == ('2016-01-02T05:00:00', 'Today at midnight ET')
assert choices[1] == ('2016-01-01T12:00:00', 'Today at noon UTC')
assert choices[13] == ('2016-01-02T00:00:00', 'Today at midnight UTC')
# Saturday
assert choices[14] == ('2016-01-02T06:00:00', 'Tomorrow at 1am ET')
assert choices[37] == ('2016-01-03T05:00:00', 'Tomorrow at midnight ET')
assert choices[14] == ('2016-01-02T01:00:00', 'Tomorrow at 1am UTC')
assert choices[37] == ('2016-01-03T00:00:00', 'Tomorrow at midnight UTC')
# Sunday
assert choices[38] == ('2016-01-03T06:00:00', 'Sunday at 1am ET')
assert choices[38] == ('2016-01-03T01:00:00', 'Sunday at 1am UTC')
# Monday
assert choices[62] == ('2016-01-04T06:00:00', 'Monday at 1am ET')
assert choices[80] == ('2016-01-05T00:00:00', 'Monday at 7pm ET')
assert choices[84] == ('2016-01-05T04:00:00', 'Monday at 11pm ET')
assert choices[85] == ('2016-01-05T05:00:00', 'Monday at midnight ET')
assert choices[62] == ('2016-01-04T01:00:00', 'Monday at 1am UTC')
assert choices[80] == ('2016-01-04T19:00:00', 'Monday at 7pm UTC')
assert choices[84] == ('2016-01-04T23:00:00', 'Monday at 11pm UTC')
assert choices[85] == ('2016-01-05T00:00:00', 'Monday at midnight UTC')
with pytest.raises(IndexError):
assert choices[

View File

@@ -58,38 +58,38 @@ def test_format_number_in_pounds_as_currency(input_number, formatted_number):
@pytest.mark.parametrize('time, human_readable_datetime', [
# incoming in UTC, outgoing in local timezone
# this test assumes timezone is America/New_York
('2018-03-14 09:00', '14 March at 5:00am'),
('2018-03-14 19:00', '14 March at 3:00pm'),
('2018-03-14 09:00', '14 March at 9:00am'),
('2018-03-14 19:00', '14 March at 7:00pm'),
('2018-03-15 09:00', '15 March at 5:00am'),
('2018-03-15 19:00', '15 March at 3:00pm'),
('2018-03-15 09:00', '15 March at 9:00am'),
('2018-03-15 19:00', '15 March at 7:00pm'),
('2018-03-19 09:00', '19 March at 5:00am'),
('2018-03-19 19:00', '19 March at 3:00pm'),
('2018-03-19 23:59', '19 March at 7:59pm'),
('2018-03-19 09:00', '19 March at 9:00am'),
('2018-03-19 19:00', '19 March at 7:00pm'),
('2018-03-19 23:59', '19 March at 11:59pm'),
('2018-03-20 04:00', '19 March at midnight'), # we specifically refer to 00:00 as belonging to the day before.
('2018-03-20 04:01', 'yesterday at 12:01am'),
('2018-03-20 09:00', 'yesterday at 5:00am'),
('2018-03-20 19:00', 'yesterday at 3:00pm'),
('2018-03-20 23:59', 'yesterday at 7:59pm'),
('2018-03-20 00:00', '19 March at midnight'), # we specifically refer to 00:00 as belonging to the day before.
('2018-03-20 04:01', 'yesterday at 4:01am'),
('2018-03-20 09:00', 'yesterday at 9:00am'),
('2018-03-20 19:00', 'yesterday at 7:00pm'),
('2018-03-20 23:59', 'yesterday at 11:59pm'),
('2018-03-21 04:00', 'yesterday at midnight'), # we specifically refer to 00:00 as belonging to the day before.
('2018-03-21 04:01', 'today at 12:01am'),
('2018-03-21 09:00', 'today at 5:00am'),
('2018-03-21 16:00', 'today at noon'),
('2018-03-21 19:00', 'today at 3:00pm'),
('2018-03-21 23:59', 'today at 7:59pm'),
('2018-03-21 00:00', 'yesterday at midnight'), # we specifically refer to 00:00 as belonging to the day before.
('2018-03-21 04:01', 'today at 4:01am'),
('2018-03-21 09:00', 'today at 9:00am'),
('2018-03-21 12:00', 'today at noon'),
('2018-03-21 19:00', 'today at 7:00pm'),
('2018-03-21 23:59', 'today at 11:59pm'),
('2018-03-22 04:00', 'today at midnight'), # we specifically refer to 00:00 as belonging to the day before.
('2018-03-22 04:01', 'tomorrow at 12:01am'),
('2018-03-22 09:00', 'tomorrow at 5:00am'),
('2018-03-22 19:00', 'tomorrow at 3:00pm'),
('2018-03-22 23:59', 'tomorrow at 7:59pm'),
('2018-03-22 00:00', 'today at midnight'), # we specifically refer to 00:00 as belonging to the day before.
('2018-03-22 04:01', 'tomorrow at 4:01am'),
('2018-03-22 09:00', 'tomorrow at 9:00am'),
('2018-03-22 19:00', 'tomorrow at 7:00pm'),
('2018-03-22 23:59', 'tomorrow at 11:59pm'),
('2018-03-23 04:01', '23 March at 12:01am'),
('2018-03-23 09:00', '23 March at 5:00am'),
('2018-03-23 19:00', '23 March at 3:00pm'),
('2018-03-23 04:01', '23 March at 4:01am'),
('2018-03-23 09:00', '23 March at 9:00am'),
('2018-03-23 19:00', '23 March at 7:00pm'),
])
def test_format_datetime_relative(time, human_readable_datetime):

View File

@@ -153,7 +153,7 @@ def test_can_show_notifications(
assert normalize_spaces(
first_row.select_one('.table-field-right-aligned .align-with-message-body').text
) == (
'Delivered 1 January at 1:01am'
'Delivered 1 January at 6:01am'
)
assert page_title in page.h1.text.strip()
@@ -623,7 +623,7 @@ def test_redacts_templates_that_should_be_redacted(
)
@freeze_time("2017-09-27 16:30:00.000000")
@freeze_time("2017-09-27 12:30:00.000000")
@pytest.mark.parametrize(
"message_type, status, expected_hint_status, single_line", [
('email', 'created', 'Sending since 27 September at 12:30pm', True),

View File

@@ -73,7 +73,7 @@ def test_get_user_phone_number_raises_if_both_api_requests_fail(mocker):
(True, 'Hello hidden'),
(False, 'Hello Jo'),
])
@freeze_time("2012-01-01 05:00:00")
@freeze_time("2012-01-01 00:00:00")
def test_view_conversation(
client_request,
mocker,

View File

@@ -370,7 +370,7 @@ def test_view_inbox_updates(
mock_get_partials.assert_called_once_with(SERVICE_ONE_ID)
@freeze_time("2016-07-01 18:00")
@freeze_time("2016-07-01 12:00")
def test_download_inbox(
client_request,
mock_get_inbound_sms,
@@ -389,14 +389,14 @@ def test_download_inbox(
)
assert response.get_data(as_text=True) == (
'Phone number,Message,Received\r\n'
'(202) 867-5300,message-1,2016-07-01 13:00\r\n'
'(202) 867-5300,message-2,2016-07-01 12:59\r\n'
'(202) 867-5300,message-3,2016-07-01 12:59\r\n'
'(202) 867-5302,message-4,2016-07-01 10:59\r\n'
'+33 1 12 34 56 78,message-5,2016-07-01 08:59\r\n'
'(202) 555-0104,message-6,2016-07-01 06:59\r\n'
'(202) 555-0104,message-7,2016-07-01 04:59\r\n'
'+682 12345,message-8,2016-07-01 04:59\r\n'
'(202) 867-5300,message-1,2016-07-01 11:00\r\n'
'(202) 867-5300,message-2,2016-07-01 10:59\r\n'
'(202) 867-5300,message-3,2016-07-01 10:59\r\n'
'(202) 867-5302,message-4,2016-07-01 08:59\r\n'
'+33 1 12 34 56 78,message-5,2016-07-01 06:59\r\n'
'(202) 555-0104,message-6,2016-07-01 04:59\r\n'
'(202) 555-0104,message-7,2016-07-01 02:59\r\n'
'+682 12345,message-8,2016-07-01 02:59\r\n'
)
@@ -618,7 +618,7 @@ def test_monthly_has_equal_length_tables(
assert page.select_one('.table-field-headings th').get('width') == "33%"
@freeze_time("2016-01-01 11:09:00.061258")
@freeze_time("2016-01-01 1:09:00.061258")
def test_should_show_upcoming_jobs_on_dashboard(
client_request,
mock_get_service_templates,
@@ -648,7 +648,7 @@ def test_should_show_upcoming_jobs_on_dashboard(
page.select_one('a.banner-dashboard').text
) == (
'2 files waiting to send '
'sending starts today at 6:09am'
'sending starts today at 11:09am'
)
assert page.select_one('a.banner-dashboard')['href'] == url_for(

View File

@@ -9,34 +9,34 @@ from tests.conftest import SERVICE_ONE_ID, normalize_spaces
(
'12 December',
(
'Test User 1:13pm '
'Test User 6:13pm '
'Renamed this service from Before lunch to After lunch '
'Test User 12:12pm '
'Test User 5:12pm '
'Renamed this service from Example service to Before lunch'
),
),
(
'11 November',
(
'Test User 12:12pm '
'Test User 5:12pm '
'Revoked the Bad key API key'
),
),
(
'11 November 2011',
(
'Test User 11:11am '
'Test User 4:11pm '
'Created an API key called Bad key'
),
),
(
'10 October 2010',
(
'Test User 11:10am '
'Test User 3:10pm '
'Created an API key called Good key '
'Test User 10:09am '
'Test User 2:09pm '
'Created an API key called Key event returned in non-chronological order '
'Test User 2:01am '
'Test User 6:01am '
'Created this service and called it Example service'
),
),
@@ -45,23 +45,23 @@ from tests.conftest import SERVICE_ONE_ID, normalize_spaces
(
'11 November',
(
'Test User 12:12pm '
'Test User 5:12pm '
'Revoked the Bad key API key'
),
),
(
'11 November 2011',
(
'Test User 11:11am '
'Test User 4:11pm '
'Created an API key called Bad key'
),
),
(
'10 October 2010',
(
'Test User 11:10am '
'Test User 3:10pm '
'Created an API key called Good key '
'Test User 10:09am '
'Test User 2:09pm '
'Created an API key called Key event returned in non-chronological order'
),
),
@@ -70,22 +70,22 @@ from tests.conftest import SERVICE_ONE_ID, normalize_spaces
(
'12 December',
(
'Test User 1:13pm '
'Test User 6:13pm '
'Renamed this service from Before lunch to After lunch '
'Test User 12:12pm '
'Test User 5:12pm '
'Renamed this service from Example service to Before lunch'
),
),
(
'10 October 2010',
(
'Test User 2:01am '
'Test User 6:01am '
'Created this service and called it Example service'
),
),
]),
))
@freeze_time("2012-01-01 06:01:01")
@freeze_time("2012-01-01 01:01:01")
def test_history(
client_request,
mock_get_service_history,

View File

@@ -60,7 +60,7 @@ def test_old_jobs_hub_redirects(
)
]
)
@freeze_time("2016-01-01 16:09:00.061258")
@freeze_time("2016-01-01 11:09:00.061258")
def test_should_show_page_for_one_job(
client_request,
mock_get_service_template,
@@ -329,7 +329,7 @@ def test_should_show_scheduled_job(
)
assert normalize_spaces(page.select('main p')[1].text) == (
'Sending Two week reminder today at midnight'
'Sending Two week reminder tomorrow at 5:00am'
)
assert page.select('main p a')[0]['href'] == url_for(
'main.view_template_version',
@@ -402,8 +402,8 @@ def test_should_show_updates_for_one_job_as_json(
assert '2021234567' in content['notifications']
assert 'Status' in content['notifications']
assert 'Delivered' in content['notifications']
assert '12:01am' in content['notifications']
assert 'Sent by Test User on 1 January at midnight' in content['status']
assert '5:01am' in content['notifications']
assert 'Sent by Test User on 1 January at 5:00am' in content['status']
@freeze_time("2016-01-01 05:00:00.000001")
@@ -439,8 +439,8 @@ def test_should_show_updates_for_scheduled_job_as_json(
assert '2021234567' in content['notifications']
assert 'Status' in content['notifications']
assert 'Delivered' in content['notifications']
assert '12:01am' in content['notifications']
assert 'Sent by Test User on 1 June at 4:00pm' in content['status']
assert '5:01am' in content['notifications']
assert 'Sent by Test User on 1 June at 8:00pm' in content['status']
@pytest.mark.parametrize(

View File

@@ -182,16 +182,16 @@ def test_notification_status_shows_expected_back_link(
@pytest.mark.parametrize('time_of_viewing_page, expected_message', (
('2012-01-01 06:01', (
"sample template was sent by Test User today at 1:01am"
"sample template was sent by Test User today at 6:01am UTC"
)),
('2012-01-02 06:01', (
"sample template was sent by Test User yesterday at 1:01am"
"sample template was sent by Test User yesterday at 6:01am UTC"
)),
('2012-01-03 06:01', (
"sample template was sent by Test User on 1 January at 1:01am"
"sample template was sent by Test User on 1 January at 6:01am UTC"
)),
('2013-01-03 06:01', (
"sample template was sent by Test User on 1 January 2012 at 1:01am"
"sample template was sent by Test User on 1 January 2012 at 6:01am UTC"
)),
))
def test_notification_page_doesnt_link_to_template_in_tour(

View File

@@ -130,13 +130,13 @@ def test_should_render_performance_page(
''
'Messages sent since May 2023 '
'Date Emails Text messages '
'27 February 2021 1 2 '
'26 February 2021 1 2 '
'25 February 2021 1 2 '
'24 February 2021 1 2 '
'23 February 2021 1 2 '
'22 February 2021 1 2 '
'21 February 2021 1 2 '
'20 February 2021 1,234,567 123,456 '
'21 February 2021 1,234,567 123,456 '
'Only showing the last 7 days '
@@ -145,13 +145,13 @@ def test_should_render_performance_page(
'98.31% on average '
'Messages sent within 10 seconds '
'Date Percentage '
'26 February 2021 98.60% '
'25 February 2021 100.00% '
'24 February 2021 99.99% '
'23 February 2021 100.00% '
'22 February 2021 95.00% '
'21 February 2021 95.30% '
'20 February 2021 99.25% '
'27 February 2021 98.60% '
'26 February 2021 100.00% '
'25 February 2021 99.99% '
'24 February 2021 100.00% '
'23 February 2021 95.00% '
'22 February 2021 95.30% '
'21 February 2021 99.25% '
'Only showing the last 7 days '
''
'Organizations using Notify '

View File

@@ -188,7 +188,7 @@ def test_view_providers_shows_all_providers(
assert table_data[1].text.strip() == "20"
assert table_data[2].text.strip() == "42"
assert table_data[3].text.strip() == "True"
assert table_data[4].text.strip() == "16 January at 10:20am"
assert table_data[4].text.strip() == "16 January at 3:20pm"
assert table_data[5].text.strip() == "Test User"
domestic_sms_second_row = domestic_sms_table.tbody.find_all('tr')[1]

View File

@@ -472,7 +472,7 @@ def test_caseworker_sees_template_page_if_template_is_deleted(
content = str(page)
assert url_for("main.send_one_off", service_id=SERVICE_ONE_ID, template_id=fake_uuid) not in content
assert page.select('p.hint')[0].text.strip() == 'This template was deleted today at 10:00am.'
assert page.select('p.hint')[0].text.strip() == 'This template was deleted today at 3:00pm.'
mock_get_deleted_template.assert_called_with(SERVICE_ONE_ID, template_id, None)
@@ -1575,7 +1575,7 @@ def test_should_show_page_for_a_deleted_template(
content = str(page)
assert url_for("main.edit_service_template", service_id=SERVICE_ONE_ID, template_id=fake_uuid) not in content
assert url_for("main.send_one_off", service_id=SERVICE_ONE_ID, template_id=fake_uuid) not in content
assert page.select('p.hint')[0].text.strip() == 'This template was deleted today at 10:00am.'
assert page.select('p.hint')[0].text.strip() == 'This template was deleted today at 3:00pm.'
assert 'Delete this template' not in page.select_one('main').text
mock_get_deleted_template.assert_called_with(SERVICE_ONE_ID, template_id, None)

View File

@@ -48,7 +48,7 @@ def test_get_upload_hub_page(
assert normalize_spaces(uploads[0].text.strip()) == (
'some.csv '
'Sent 1 January 2016 at 6:09am '
'Sent 1 January 2016 at 11:09am '
'0 sending 8 delivered 2 failed'
)
assert uploads[0].select_one('a.file-list-filename-large')['href'] == (
@@ -79,12 +79,12 @@ def test_uploads_page_shows_scheduled_jobs(
),
(
'even_later.csv '
'Sending 1 January 2016 at 6:09pm '
'Sending 1 January 2016 at 11:09pm '
'1 text message waiting to send'
),
(
'send_me_later.csv '
'Sending 1 January 2016 at 6:09am '
'Sending 1 January 2016 at 11:09am '
'1 text message waiting to send'
),
]