-
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.
feat: add SubmissionsTable to SubmissionsView (#2905)
- Loading branch information
1 parent
f070dc0
commit 79f0b3d
Showing
3 changed files
with
109 additions
and
9 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
....planx.uk/src/pages/FlowEditor/components/Settings/Submissions/SubmissionView.stories.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,46 @@ | ||
import { Meta, StoryObj } from "@storybook/react"; | ||
import React from "react"; | ||
|
||
import { mockApplications } from "./mocks"; | ||
import SubmissionsView from "./SubmissionsView"; | ||
|
||
const meta: Meta<typeof SubmissionsView> = { | ||
title: "Design System/Molecules/SubmissionsView", | ||
component: SubmissionsView, | ||
}; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export default meta; | ||
|
||
export const DefaultView: Story = { | ||
render: () => ( | ||
<SubmissionsView | ||
applications={mockApplications} | ||
loading={false} | ||
error={undefined} | ||
/> | ||
), | ||
}; | ||
|
||
export const Loading: Story = { | ||
render: () => ( | ||
<SubmissionsView applications={[]} loading={true} error={undefined} /> | ||
), | ||
}; | ||
|
||
export const ErrorState: Story = { | ||
render: () => ( | ||
<SubmissionsView | ||
applications={[]} | ||
loading={false} | ||
error={new Error("Failed to load data")} | ||
/> | ||
), | ||
}; | ||
|
||
export const Empty: Story = { | ||
render: () => ( | ||
<SubmissionsView applications={[]} loading={false} error={undefined} /> | ||
), | ||
}; |
61 changes: 61 additions & 0 deletions
61
...or.planx.uk/src/pages/FlowEditor/components/Settings/Submissions/SubmissionsView.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,61 @@ | ||
import { waitFor } from "@storybook/testing-library"; | ||
import React from "react"; | ||
import { axe, setup } from "testUtils"; | ||
|
||
import { mockApplications } from "./mocks"; | ||
import SubmissionsView from "./SubmissionsView"; | ||
|
||
describe("SubmissionsView Component", () => { | ||
test("displays the loading indicator when loading", async () => { | ||
const { container, getByTestId } = setup( | ||
<SubmissionsView applications={[]} loading={true} error={undefined} />, | ||
); | ||
await waitFor(() => { | ||
expect(getByTestId("delayed-loading-indicator")).toBeInTheDocument(); | ||
}); | ||
const results = await axe(container); | ||
expect(results).toHaveNoViolations(); | ||
}); | ||
|
||
test("displays the error message when there is an error", async () => { | ||
const errorMessage = "Test error message"; | ||
const { container, getByText } = setup( | ||
<SubmissionsView | ||
applications={[]} | ||
loading={false} | ||
error={new Error(errorMessage)} | ||
/>, | ||
); | ||
expect(getByText(errorMessage)).toBeInTheDocument(); | ||
const results = await axe(container); | ||
expect(results).toHaveNoViolations(); | ||
}); | ||
|
||
test("displays a message when there are no applications", async () => { | ||
const { container, getByText } = setup( | ||
<SubmissionsView applications={[]} loading={false} error={undefined} />, | ||
); | ||
expect( | ||
getByText("No submitted applications found for this service."), | ||
).toBeInTheDocument(); | ||
|
||
const results = await axe(container); | ||
expect(results).toHaveNoViolations(); | ||
}); | ||
|
||
test("displays the submissions table when there are applications", async () => { | ||
const { container, getByText } = setup( | ||
<SubmissionsView | ||
applications={mockApplications} | ||
loading={false} | ||
error={undefined} | ||
/>, | ||
); | ||
mockApplications.forEach((app) => { | ||
expect(getByText(app.sessionId)).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