fix(admin): address PR #623 second-pass review feedback
- Fix VALID_STATUSES fallback to use uppercase enum value - Add TODO comment on InviteListItem cast pending type regeneration - Guard revoke action against null id (returns fail 400) - Add request: to delete action mock events for Sentry consistency - Add expiresAt forwarding test for create action - Add null-id guard test for revoke action Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -203,6 +203,22 @@ describe('admin/invites create action', () => {
|
||||
|
||||
expect(result).toMatchObject({ status: 500, data: { createError: 'INTERNAL_ERROR' } });
|
||||
});
|
||||
|
||||
it('includes expiresAt in POST body when provided', async () => {
|
||||
const fd = new FormData();
|
||||
fd.append('expiresAt', '2026-12-31');
|
||||
mockFetch.mockResolvedValueOnce(mockResponse(true, successBody, 201));
|
||||
|
||||
await actions.create({
|
||||
request: new Request('http://localhost', { method: 'POST', body: fd }),
|
||||
fetch: mockFetch as unknown as typeof fetch
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} as any);
|
||||
|
||||
const [req] = mockFetch.mock.calls[0] as [Request, unknown];
|
||||
const sent = await req.json();
|
||||
expect(sent.expiresAt).toBe('2026-12-31');
|
||||
});
|
||||
});
|
||||
|
||||
describe('admin/invites revoke action', () => {
|
||||
@@ -254,4 +270,15 @@ describe('admin/invites revoke action', () => {
|
||||
|
||||
expect(result).toMatchObject({ status: 404, data: { revokeError: 'NOT_FOUND' } });
|
||||
});
|
||||
|
||||
it('returns fail(400) when revoke id is missing', async () => {
|
||||
const result = await actions.revoke({
|
||||
request: new Request('http://localhost', { method: 'POST', body: new FormData() }),
|
||||
fetch: mockFetch as unknown as typeof fetch
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} as any);
|
||||
|
||||
expect(mockFetch).not.toHaveBeenCalled();
|
||||
expect(result).toMatchObject({ status: 400 });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user