-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test coverage for
index.tsx
- Adds basic tests dependent on potential query results
- Loading branch information
1 parent
799ea09
commit 4c1a93f
Showing
2 changed files
with
118 additions
and
3 deletions.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
editor.planx.uk/src/pages/FlowEditor/components/Settings/Submissions/index.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { MockedProvider } from "@apollo/client/testing"; | ||
import { waitFor } from "@testing-library/react"; | ||
import { vanillaStore } from "pages/FlowEditor/lib/store"; | ||
import React from "react"; | ||
import { axe, setup } from "testUtils"; | ||
|
||
import Submissions from "./index"; | ||
import { mockApplications, mockRequests } from "./mocks"; | ||
|
||
const { setState } = vanillaStore; | ||
|
||
describe("Submissions Component", () => { | ||
test("no results message", async () => { | ||
setState({ flowSlug: "no-results-service", teamSlug: "test-team" }); | ||
const { container, getByText } = setup( | ||
<MockedProvider mocks={mockRequests} addTypename={false}> | ||
<Submissions /> | ||
</MockedProvider>, | ||
); | ||
|
||
expect(getByText("Submissions")).toBeInTheDocument(); | ||
expect( | ||
getByText( | ||
"View data on the user submitted applications for this service.", | ||
), | ||
).toBeInTheDocument(); | ||
|
||
await waitFor(() => { | ||
expect( | ||
getByText("No submitted applications found for this service."), | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
const results = await axe(container); | ||
expect(results).toHaveNoViolations(); | ||
}); | ||
|
||
test("basic view table with expected values", async () => { | ||
setState({ flowSlug: "test-service", teamSlug: "test-team" }); | ||
const { container, getByText } = setup( | ||
<MockedProvider mocks={mockRequests} addTypename={false}> | ||
<Submissions /> | ||
</MockedProvider>, | ||
); | ||
|
||
expect(getByText("Submissions")).toBeInTheDocument(); | ||
expect( | ||
getByText( | ||
"View data on the user submitted applications for this service.", | ||
), | ||
).toBeInTheDocument(); | ||
|
||
await waitFor(() => { | ||
mockApplications.forEach((app) => { | ||
expect(getByText(app.sessionId)).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
const results = await axe(container); | ||
expect(results).toHaveNoViolations(); | ||
}); | ||
|
||
test("error renders as expected", async () => { | ||
setState({ flowSlug: "error-service", teamSlug: "test-team" }); | ||
const { container, getByText } = setup( | ||
<MockedProvider mocks={mockRequests} addTypename={false}> | ||
<Submissions /> | ||
</MockedProvider>, | ||
); | ||
|
||
expect(getByText("Submissions")).toBeInTheDocument(); | ||
expect( | ||
getByText( | ||
"View data on the user submitted applications for this service.", | ||
), | ||
).toBeInTheDocument(); | ||
|
||
await waitFor(() => { | ||
expect(getByText("An error occurred")).toBeInTheDocument(); | ||
}); | ||
|
||
const results = await axe(container); | ||
expect(results).toHaveNoViolations(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters