Skip to content

Commit

Permalink
Don't show loading indicator or announce loading if loading finishes …
Browse files Browse the repository at this point in the history
…before the timeout
  • Loading branch information
lortimer committed Sep 2, 2023
1 parent 811f0a5 commit abfb5b8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/pages/Page.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe(Page.name, () => {
expect(loadingText).toBeVisible();
});

test("does not show loading text if loading finished within the timeout period", async () => {
test("does not show loading text or indicator if loading finished within the timeout period", async () => {
const originalAppLoadingTimeout = process.env.REACT_APP_LOADING_TIMEOUT;
process.env.REACT_APP_LOADING_TIMEOUT = "250";

Expand All @@ -97,6 +97,9 @@ describe(Page.name, () => {
const loadingText = within(liveRegion).queryByText("loading");
expect(loadingText).not.toBeInTheDocument();

const loadingIndicator = screen.queryByText("Loading...");
expect(loadingIndicator).not.toBeInTheDocument();

process.env.REACT_APP_LOADING_TIMEOUT = originalAppLoadingTimeout;
});
});
Expand Down Expand Up @@ -167,6 +170,7 @@ const ChildComponentThatLoadsData = () => {
const { startLoading, finishLoading } = useContext(LoadingContext);

return (<>
children
<button onClick={startLoading}>START LOADING</button>
<button onClick={finishLoading}>STOP LOADING</button>
</>);
Expand Down

0 comments on commit abfb5b8

Please sign in to comment.