From 453347e2a9a57a5ddc7573c2046a16b294b1a9eb Mon Sep 17 00:00:00 2001 From: Deborah Kaplan Date: Fri, 29 Sep 2023 20:42:07 +0000 Subject: [PATCH 1/4] feat: make the "loading" message be accurate * While a program record is loading we now get a loading message * spun off a second private ticket APER-2924, to fix the API problem which makes it impossible to accurately report that a URL is invalid * Left the stub method in place because I didn't want to lose the translation strings people have made. FIXES: APER-2190 --- .../ProgramRecord/ProgramRecord.jsx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/components/ProgramRecord/ProgramRecord.jsx b/src/components/ProgramRecord/ProgramRecord.jsx index ae5923c..1288e71 100644 --- a/src/components/ProgramRecord/ProgramRecord.jsx +++ b/src/components/ProgramRecord/ProgramRecord.jsx @@ -28,6 +28,7 @@ function ProgramRecord({ isPublic }) { const [recordDetails, setRecordDetails] = useState({}); const [isLoaded, setIsLoaded] = useState(false); const [hasNoData, setHasNoData] = useState(false); + const [isNotFound, setNotFound] = useState(false); const [showSendRecordButton, setShowSendRecordButton] = useState(false); const [sendRecord, setSendRecord] = useState({ @@ -188,14 +189,30 @@ function ProgramRecord({ isPublic }) { ); + const renderLoading = () => ( + <> + {!isPublic && renderBackButton()} +

+ +

+ + ); + const renderData = () => { if (isLoaded) { if (hasNoData) { return renderCredentialsServiceIssueAlert(); } + if (isNotFound) { + return renderNotFound(); + } return renderProgramDetails(); } - return renderNotFound(); + return renderLoading(); }; return ( From c567bb5077c9738982f8113a83e9a44825176879 Mon Sep 17 00:00:00 2001 From: Deborah Kaplan Date: Fri, 29 Sep 2023 21:00:48 +0000 Subject: [PATCH 2/4] feat: commenting on an unused variable FIXES: APER-2190 --- src/components/ProgramRecord/ProgramRecord.jsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/ProgramRecord/ProgramRecord.jsx b/src/components/ProgramRecord/ProgramRecord.jsx index 1288e71..90dd5ae 100644 --- a/src/components/ProgramRecord/ProgramRecord.jsx +++ b/src/components/ProgramRecord/ProgramRecord.jsx @@ -28,6 +28,8 @@ function ProgramRecord({ isPublic }) { const [recordDetails, setRecordDetails] = useState({}); const [isLoaded, setIsLoaded] = useState(false); const [hasNoData, setHasNoData] = useState(false); + // Leaving a stub value in for a method that's ticketed to fix + // eslint-disable-next-line no-unused-vars const [isNotFound, setNotFound] = useState(false); const [showSendRecordButton, setShowSendRecordButton] = useState(false); From 8fb08a9b3b4da6061892b55e1b0e1c4bdcc9645e Mon Sep 17 00:00:00 2001 From: Deborah Kaplan Date: Fri, 29 Sep 2023 21:32:15 +0000 Subject: [PATCH 3/4] feat: tests * Getting rid of the 404 test with the old error message * replacing with a no return test with the new loading message FIXES: APER-2190 --- src/components/ProgramRecord/test/ProgramRecord.test.jsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/components/ProgramRecord/test/ProgramRecord.test.jsx b/src/components/ProgramRecord/test/ProgramRecord.test.jsx index 5c18c34..d05ae90 100644 --- a/src/components/ProgramRecord/test/ProgramRecord.test.jsx +++ b/src/components/ProgramRecord/test/ProgramRecord.test.jsx @@ -78,12 +78,11 @@ describe('program-record', () => { expect(await screen.findByText('An error occurred attempting to retrieve your program records. Please try again later.')).toBeTruthy(); }); - it('renders not found message on unsuccessful request', async () => { + it('renders loading message on delay', async () => { const axiosMock = new MockAdapter(getAuthenticatedHttpClient()); axiosMock - .onGet(`${getConfig().CREDENTIALS_BASE_URL}/records/api/v1/program_records/test-id/?is_public=false`) - .reply(404, {}); + .onGet(`${getConfig().CREDENTIALS_BASE_URL}/records/api/v1/program_records/test-id/?is_public=false`); render(); - expect(await screen.findByText('The page you\'re looking for is unavailable or there\'s an error in the URL. Please check the URL and try again.')).toBeTruthy(); + expect(await screen.findByText('Loading...')).toBeTruthy(); }); }); From 56130edb89abe7757f184de620b93a0b16dfa69e Mon Sep 17 00:00:00 2001 From: Deborah Kaplan Date: Fri, 29 Sep 2023 21:39:03 +0000 Subject: [PATCH 4/4] feat: felt uncomfortable about my decision to leave in the stub code FIXES: APER-2190 --- .../ProgramRecord/ProgramRecord.jsx | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/components/ProgramRecord/ProgramRecord.jsx b/src/components/ProgramRecord/ProgramRecord.jsx index 90dd5ae..bb881cd 100644 --- a/src/components/ProgramRecord/ProgramRecord.jsx +++ b/src/components/ProgramRecord/ProgramRecord.jsx @@ -28,9 +28,6 @@ function ProgramRecord({ isPublic }) { const [recordDetails, setRecordDetails] = useState({}); const [isLoaded, setIsLoaded] = useState(false); const [hasNoData, setHasNoData] = useState(false); - // Leaving a stub value in for a method that's ticketed to fix - // eslint-disable-next-line no-unused-vars - const [isNotFound, setNotFound] = useState(false); const [showSendRecordButton, setShowSendRecordButton] = useState(false); const [sendRecord, setSendRecord] = useState({ @@ -178,19 +175,6 @@ function ProgramRecord({ isPublic }) { ); - const renderNotFound = () => ( - <> - {!isPublic && renderBackButton()} -

- -

- - ); - const renderLoading = () => ( <> {!isPublic && renderBackButton()} @@ -209,9 +193,6 @@ function ProgramRecord({ isPublic }) { if (hasNoData) { return renderCredentialsServiceIssueAlert(); } - if (isNotFound) { - return renderNotFound(); - } return renderProgramDetails(); } return renderLoading();