mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 17:03:15 +00:00
fix: hold the ratchets after the SSO unlink and the day pager window
- The SSO unlink answers with a response contract (adminSsoUnlinkResponseSchema). - It reuses linkOidcIdentity with nulls instead of a new repository method, so UsersRepository keeps its method count and size. - The client calls the route through apiClient, so api/client.ts does not grow, and its confirm dialog takes no async callback. - The pager's preview step and pagesFor keep their complexity.
This commit is contained in:
@@ -9,9 +9,9 @@ const api = vi.hoisted(() => ({
|
||||
rotateJwtSecret: vi.fn(),
|
||||
resetUserPasskeys: vi.fn(),
|
||||
resetUserMfa: vi.fn(),
|
||||
unlinkUserSso: vi.fn(),
|
||||
}));
|
||||
vi.mock('../../api/client', () => ({ adminApi: api }));
|
||||
const http = vi.hoisted(() => ({ delete: vi.fn() }));
|
||||
vi.mock('../../api/client', () => ({ adminApi: api, apiClient: http }));
|
||||
|
||||
const t = (key: string, params?: Record<string, unknown>) => (params ? `${key} ${JSON.stringify(params)}` : key);
|
||||
|
||||
@@ -33,7 +33,7 @@ beforeEach(() => {
|
||||
api.rotateJwtSecret.mockReset().mockResolvedValue({});
|
||||
api.resetUserPasskeys.mockReset().mockResolvedValue({ deleted: 2 });
|
||||
api.resetUserMfa.mockReset().mockResolvedValue({ success: true });
|
||||
api.unlinkUserSso.mockReset().mockResolvedValue({ success: true, unlinked: true });
|
||||
http.delete.mockReset().mockResolvedValue({ data: { success: true, unlinked: true } });
|
||||
});
|
||||
|
||||
describe('useAdminUserActions', () => {
|
||||
@@ -114,13 +114,13 @@ describe('useAdminUserActions', () => {
|
||||
await act(async () => {
|
||||
ok = await actions.unlinkSso({ id: 11 });
|
||||
});
|
||||
expect(api.unlinkUserSso).toHaveBeenCalledWith(11);
|
||||
expect(http.delete).toHaveBeenCalledWith('/admin/users/11/sso');
|
||||
expect(admin.toast.success).toHaveBeenCalledWith('admin.sso.unlinkDone');
|
||||
expect(ok).toBe(true);
|
||||
});
|
||||
|
||||
it('FE-HOOK-ADMUSERACT-009: a failed SSO unlink toasts and reports failure', async () => {
|
||||
api.unlinkUserSso.mockRejectedValue(new Error('x'));
|
||||
http.delete.mockRejectedValue(new Error('x'));
|
||||
const { admin, actions } = mount();
|
||||
let ok: boolean | undefined;
|
||||
await act(async () => {
|
||||
|
||||
Reference in New Issue
Block a user