Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make the "loading" message be accurate #188

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
});
});