From 63766531481ea29e21c13a7616ecdb6009f93310 Mon Sep 17 00:00:00 2001 From: ilee2u Date: Tue, 13 Feb 2024 10:46:57 -0500 Subject: [PATCH 1/3] fix: default start/end time is now "-" --- src/pages/ExamsPage/components/AttemptList.jsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/pages/ExamsPage/components/AttemptList.jsx b/src/pages/ExamsPage/components/AttemptList.jsx index 395ff2e..b8b7fad 100644 --- a/src/pages/ExamsPage/components/AttemptList.jsx +++ b/src/pages/ExamsPage/components/AttemptList.jsx @@ -145,23 +145,26 @@ const AttemptList = ({ attempts }) => { }, { Header: formatMessage(messages.examAttemptsTableHeaderStartedAt), - Cell: ({ row }) => (formatDate(row.original.started_at, { + // The ternary operator here sets the value of the started/completed at datetime to + // "-" if the value is null, as otherwise the DataTable will default to the + // UNIX epoch (i.e. 1/1/1970) for some reason. + Cell: ({ row }) => (row.original.started_at ? formatDate(row.original.started_at, { year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric', - })), + }) : "-"), }, { Header: formatMessage(messages.examAttemptsTableHeaderCompletedAt), - Cell: ({ row }) => (formatDate(row.original.completed_at, { + Cell: ({ row }) => (row.original.completed_at ? formatDate(row.original.completed_at, { year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric', - })), + }) : "-"), }, { Header: formatMessage(messages.examAttemptsTableHeaderStatus), From 48d8bad9ce1a55ea22add546bcaef4576930bfd0 Mon Sep 17 00:00:00 2001 From: ilee2u Date: Tue, 13 Feb 2024 10:49:04 -0500 Subject: [PATCH 2/3] chore: lint --- src/pages/ExamsPage/components/AttemptList.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/ExamsPage/components/AttemptList.jsx b/src/pages/ExamsPage/components/AttemptList.jsx index b8b7fad..8b5ad39 100644 --- a/src/pages/ExamsPage/components/AttemptList.jsx +++ b/src/pages/ExamsPage/components/AttemptList.jsx @@ -154,7 +154,7 @@ const AttemptList = ({ attempts }) => { day: 'numeric', hour: 'numeric', minute: 'numeric', - }) : "-"), + }) : '-'), }, { Header: formatMessage(messages.examAttemptsTableHeaderCompletedAt), @@ -164,7 +164,7 @@ const AttemptList = ({ attempts }) => { day: 'numeric', hour: 'numeric', minute: 'numeric', - }) : "-"), + }) : '-'), }, { Header: formatMessage(messages.examAttemptsTableHeaderStatus), From 43197c1c299f8d3bd117fc816f387f7d7faa7bc5 Mon Sep 17 00:00:00 2001 From: ilee2u Date: Tue, 13 Feb 2024 11:56:29 -0500 Subject: [PATCH 3/3] test: test --- .../ExamsPage/components/AttemptList.test.jsx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/pages/ExamsPage/components/AttemptList.test.jsx b/src/pages/ExamsPage/components/AttemptList.test.jsx index 964292b..3a20a58 100644 --- a/src/pages/ExamsPage/components/AttemptList.test.jsx +++ b/src/pages/ExamsPage/components/AttemptList.test.jsx @@ -57,6 +57,23 @@ describe('AttemptList', () => { } }); }); + it('attempt null start and end time makes "-" appear in UI', () => { + render(); + // Expect a two cells with '-' to be present (index 1 is for the second entry) + expect(screen.getAllByText('-')[1]).toBeInTheDocument(); + }); it('filtering by status displays the correct entry', () => { render(); // Get the 2nd row of data which has the values of defaultAttemptsData[1]