some fixes and refactors
This commit is contained in:
parent
ead8a566d0
commit
75cfc6c928
16 changed files with 381 additions and 425 deletions
|
|
@ -20,6 +20,9 @@ const mockLogout = vi.fn();
|
|||
const mockHasPermission = vi.fn((permission: string) =>
|
||||
mockUser?.permissions.includes(permission) ?? false
|
||||
);
|
||||
const mockHasRole = vi.fn((role: string) =>
|
||||
mockUser?.roles.includes(role) ?? false
|
||||
);
|
||||
|
||||
vi.mock("../auth-context", () => ({
|
||||
useAuth: () => ({
|
||||
|
|
@ -27,6 +30,7 @@ vi.mock("../auth-context", () => ({
|
|||
isLoading: mockIsLoading,
|
||||
logout: mockLogout,
|
||||
hasPermission: mockHasPermission,
|
||||
hasRole: mockHasRole,
|
||||
}),
|
||||
Permission: {
|
||||
VIEW_COUNTER: "view_counter",
|
||||
|
|
@ -52,6 +56,9 @@ beforeEach(() => {
|
|||
mockHasPermission.mockImplementation((permission: string) =>
|
||||
mockUser?.permissions.includes(permission) ?? false
|
||||
);
|
||||
mockHasRole.mockImplementation((role: string) =>
|
||||
mockUser?.roles.includes(role) ?? false
|
||||
);
|
||||
// Default: successful empty response
|
||||
mockFetch.mockResolvedValue({
|
||||
ok: true,
|
||||
|
|
@ -114,7 +121,8 @@ describe("AuditPage", () => {
|
|||
render(<AuditPage />);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText("Failed to load counter records")).toBeTruthy();
|
||||
const errors = screen.getAllByText("Request failed: 500");
|
||||
expect(errors.length).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue