fix(unit-2-auth): Fix API endpoint paths and JSON casing for real backend
- Add /api/v1/ prefix to all Unit 2 API calls (Setup/status, Setup/owner,
Invitation/validate, Invitation/complete) to match backend ApiPrefixConvention
- Fix setup status endpoint to POST /api/v1/Setup/owner (not /Setup)
- Handle PascalCase 'Initialized' response from .NET backend without camelCase policy
- Update all MSW mock handlers to match corrected /api/v1/ URL patterns
- Remove unused imports from RouteGuard.test.tsx
Root cause: backend uses ApiPrefixConvention('api/v1') but frontend calls
were missing the prefix, and .NET defaults to PascalCase JSON serialization.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@ import { http, HttpResponse } from 'msw';
|
||||
import { API_BASE } from '../auth/fixtures';
|
||||
|
||||
export const invitationHandlers = [
|
||||
http.get(`${API_BASE}/Invitation/validate`, ({ request }) => {
|
||||
http.get(`${API_BASE}/api/v1/Invitation/validate`, ({ request }) => {
|
||||
const token = new URL(request.url).searchParams.get('token');
|
||||
|
||||
if (token === 'valid-token') {
|
||||
@@ -25,7 +25,7 @@ export const invitationHandlers = [
|
||||
);
|
||||
}),
|
||||
|
||||
http.post(`${API_BASE}/Invitation/complete`, async ({ request }) => {
|
||||
http.post(`${API_BASE}/api/v1/Invitation/complete`, async ({ request }) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const body = await request.json() as any;
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@ import { API_BASE } from '../auth/fixtures';
|
||||
|
||||
/** Setup status mock (used by public bootstrap guards). */
|
||||
export const setupHandlers = [
|
||||
http.get(`${API_BASE}/Setup/status`, () =>
|
||||
http.get(`${API_BASE}/api/v1/Setup/status`, () =>
|
||||
HttpResponse.json<SetupStatus>({ initialized: true }),
|
||||
),
|
||||
|
||||
http.post(`${API_BASE}/Setup`, async ({ request }) => {
|
||||
http.post(`${API_BASE}/api/v1/Setup/owner`, async ({ request }) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const body = await request.json() as any;
|
||||
if (!body.email || !body.password || !body.name) {
|
||||
@@ -39,15 +39,15 @@ export const setupHandlers = [
|
||||
|
||||
/** Override: returns not-initialized status — use in tests for InitGuard. */
|
||||
export const setupUninitializedHandlers = [
|
||||
http.get(`${API_BASE}/Setup/status`, () =>
|
||||
http.get(`${API_BASE}/api/v1/Setup/status`, () =>
|
||||
HttpResponse.json<SetupStatus>({ initialized: false }),
|
||||
),
|
||||
];
|
||||
|
||||
/** Override: POST /Setup returns 409 — system already initialized. */
|
||||
/** Override: POST /Setup/owner returns 409 — system already initialized. */
|
||||
export const setupConflictHandlers = [
|
||||
...setupUninitializedHandlers,
|
||||
http.post(`${API_BASE}/Setup`, () =>
|
||||
http.post(`${API_BASE}/api/v1/Setup/owner`, () =>
|
||||
HttpResponse.json(
|
||||
{ title: 'Conflict', detail: 'System has already been initialized.', status: 409 },
|
||||
{ status: 409 },
|
||||
|
||||
Reference in New Issue
Block a user