-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: implement PR review suggestions
Signed-off-by: SeSo <[email protected]>
- Loading branch information
1 parent
dc06cec
commit 9c23643
Showing
4 changed files
with
132 additions
and
53 deletions.
There are no files selected for viewing
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
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
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
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ import { | |
} from "@bciers/testConfig/mocks"; | ||
import UserOperatorsPage from "@/administration/app/components/userOperators/UserOperatorsPage"; | ||
import { expect } from "vitest"; | ||
import { UserOperatorStatus } from "@bciers/utils/src/enums"; | ||
|
||
useSearchParams.mockReturnValue({ | ||
get: vi.fn(), | ||
|
@@ -17,6 +18,32 @@ vi.mock( | |
}), | ||
); | ||
|
||
const mockResponse = { | ||
rows: [ | ||
{ | ||
id: 1, | ||
user_friendly_id: "1", | ||
status: UserOperatorStatus.APPROVED, | ||
user__first_name: "John", | ||
user__last_name: "Doe", | ||
user__email: "[email protected]", | ||
user__bceid_business_name: "John Doe Inc.", | ||
operator__legal_name: "FakeOperator 1", | ||
}, | ||
{ | ||
id: 2, | ||
user_friendly_id: "2", | ||
status: UserOperatorStatus.PENDING, | ||
user__first_name: "Jane", | ||
user__last_name: "Smith", | ||
user__email: "[email protected]", | ||
user__bceid_business_name: "Jane Smith Inc.", | ||
operator__legal_name: "FakeOperator 2", | ||
}, | ||
], | ||
row_count: 2, | ||
}; | ||
|
||
describe("User Operators (External Access Requests) Page", () => { | ||
beforeEach(() => { | ||
vi.clearAllMocks(); | ||
|
@@ -37,6 +64,13 @@ describe("User Operators (External Access Requests) Page", () => { | |
expect(screen.queryByRole("grid")).toBeInTheDocument(); | ||
expect(screen.getByText(/No records found/i)).toBeVisible(); | ||
}); | ||
it("renders UserOperatorsPage that correctly handle a non-empty data array", async () => { | ||
getUserOperatorsPageData.mockReturnValueOnce(mockResponse); | ||
render(await UserOperatorsPage({ searchParams: {} })); | ||
expect(screen.queryByRole("grid")).toBeInTheDocument(); | ||
const allRows = screen.getAllByRole("row"); | ||
expect(allRows).toHaveLength(4); // 2 rows + 1 header + 1 filter row | ||
}); | ||
it("renders the appropriate error component when getUserOperatorsPageData fails", async () => { | ||
getUserOperatorsPageData.mockReturnValueOnce(undefined); | ||
expect(async () => | ||
|