Skip to content

Commit

Permalink
Merge pull request #188 from openedx/dkaplan1/APER-2190_page-you're-l…
Browse files Browse the repository at this point in the history
…ooking-for-is-unavailable-error-flashes-on-lr-mfe-before-program-record-has-rendered

feat:  make the "loading" message be accurate
  • Loading branch information
deborahgu authored Oct 2, 2023
2 parents 2bcbd6a + 56130ed commit 962f686
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/components/ProgramRecord/ProgramRecord.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,14 @@ function ProgramRecord({ isPublic }) {
</div>
);

const renderNotFound = () => (
const renderLoading = () => (
<>
{!isPublic && renderBackButton()}
<p>
<FormattedMessage
id="page.notfound.message"
defaultMessage="The page you're looking for is unavailable or there's an error in the URL. Please check the URL and try again."
description="Error message when a page does not exist for the provided URL"
id="page.loading.message"
defaultMessage="Loading..."
description="Loading message when a program record is fetching data."
/>
</p>
</>
Expand All @@ -195,7 +195,7 @@ function ProgramRecord({ isPublic }) {
}
return renderProgramDetails();
}
return renderNotFound();
return renderLoading();
};

return (
Expand Down
7 changes: 3 additions & 4 deletions src/components/ProgramRecord/test/ProgramRecord.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(<ProgramRecord isPublic={false} />);
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();
});
});

0 comments on commit 962f686

Please sign in to comment.