feat: warm-up deps — ts-reset, web-vitals, RHF devtool, query-broadcast
Four low-risk adds before the Zod 4 / drizzle-zod headliner: - @total-typescript/ts-reset: tightens TS stdlib types globally (JSON.parse → unknown, fetch().json() → unknown, .filter(Boolean) narrows, Set literals respect typed Set targets). Caught 179 latent type errors; fixed all production sites (8 files) and added `any` cast escape hatch in test files (ESLint exemption scoped to tests/). - web-vitals + /api/v1/internal/vitals endpoint + WebVitalsReporter client component: establishes Core Web Vitals baseline (LCP/INP/CLS/ FCP/TTFB) via navigator.sendBeacon. Required before optimisation work. - @hookform/devtools + FormDevtool wrapper: dev-only RHF state inspector, lazy-loaded via next/dynamic so the chunk is excluded from prod bundles entirely. - @tanstack/query-broadcast-client-experimental: cross-tab cache sync via BroadcastChannel — wired in query-provider.tsx, 1-liner. Audit doc updated with sections 35 + 36 (PDF stack overhaul + comprehensive second-pass package sweep) covering ~20 package adoption candidates and 4-5 deprecation candidates. Verified: tsc clean, vitest 1293/1293 pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { login, navigateTo, PORT_SLUG } from './helpers';
|
||||
import { login, navigateTo } from './helpers';
|
||||
|
||||
test.describe('AI Features', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
@@ -9,9 +9,12 @@ test.describe('AI Features', () => {
|
||||
// Test 39: AI features are hidden when flag is off
|
||||
test('AI score badge hidden when feature flag disabled', async ({ page }) => {
|
||||
// First, ensure the flag is off by checking via API
|
||||
const flagRes = await page.request.get('/api/v1/settings/feature-flag?key=ai_interest_scoring', {
|
||||
headers: { 'X-Port-Id': '' }, // Will use session port
|
||||
});
|
||||
const flagRes = await page.request.get(
|
||||
'/api/v1/settings/feature-flag?key=ai_interest_scoring',
|
||||
{
|
||||
headers: { 'X-Port-Id': '' }, // Will use session port
|
||||
},
|
||||
);
|
||||
|
||||
// Navigate to an interest
|
||||
await navigateTo(page, '/interests');
|
||||
@@ -27,11 +30,17 @@ test.describe('AI Features', () => {
|
||||
const hotBadge = page.getByText(/^(Hot|Warm|Cool|Cold)$/).first();
|
||||
|
||||
if (flagRes.ok()) {
|
||||
const flagData = await flagRes.json().catch(() => ({ enabled: false }));
|
||||
const flagData = (await flagRes.json().catch(() => ({ enabled: false }))) as {
|
||||
enabled?: boolean;
|
||||
};
|
||||
if (!flagData.enabled) {
|
||||
// Score badge should NOT be visible
|
||||
await expect(scoreBadge.first()).not.toBeVisible({ timeout: 3_000 }).catch(() => {});
|
||||
await expect(hotBadge).not.toBeVisible({ timeout: 2_000 }).catch(() => {});
|
||||
await expect(scoreBadge.first())
|
||||
.not.toBeVisible({ timeout: 3_000 })
|
||||
.catch(() => {});
|
||||
await expect(hotBadge)
|
||||
.not.toBeVisible({ timeout: 2_000 })
|
||||
.catch(() => {});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,7 +57,10 @@ test.describe('AI Features', () => {
|
||||
const aiToggle = page.getByText(/ai.*scoring|interest.*scoring/i).first();
|
||||
if (await aiToggle.isVisible({ timeout: 5_000 }).catch(() => false)) {
|
||||
// Find the associated switch/toggle
|
||||
const toggle = aiToggle.locator('..').locator('button[role="switch"], input[type="checkbox"]').first();
|
||||
const toggle = aiToggle
|
||||
.locator('..')
|
||||
.locator('button[role="switch"], input[type="checkbox"]')
|
||||
.first();
|
||||
if (await toggle.isVisible({ timeout: 2_000 }).catch(() => false)) {
|
||||
await toggle.click();
|
||||
await page.waitForTimeout(2_000);
|
||||
@@ -56,10 +68,12 @@ test.describe('AI Features', () => {
|
||||
} else {
|
||||
// If no UI for feature flags, try setting it via API
|
||||
// This is an acceptable approach for testing
|
||||
await page.request.put('/api/v1/settings/feature-flag', {
|
||||
data: { key: 'ai_interest_scoring', value: true },
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
}).catch(() => {});
|
||||
await page.request
|
||||
.put('/api/v1/settings/feature-flag', {
|
||||
data: { key: 'ai_interest_scoring', value: true },
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
expect(true).toBeTruthy();
|
||||
});
|
||||
@@ -78,10 +92,10 @@ test.describe('AI Features', () => {
|
||||
// Try calling the scoring API directly to verify it works
|
||||
const scoreRes = await page.request.get('/api/v1/ai/interest-score/bulk');
|
||||
if (scoreRes.ok()) {
|
||||
const data = await scoreRes.json().catch(() => null);
|
||||
const data = (await scoreRes.json().catch(() => null)) as any;
|
||||
if (data && Array.isArray(data) && data.length > 0) {
|
||||
// Verify scores are in 0-100 range
|
||||
const score = data[0].score?.totalScore ?? data[0].totalScore;
|
||||
const score = (data as any)[0].score?.totalScore ?? (data as any)[0].totalScore;
|
||||
if (score !== undefined) {
|
||||
expect(score).toBeGreaterThanOrEqual(0);
|
||||
expect(score).toBeLessThanOrEqual(100);
|
||||
@@ -97,7 +111,7 @@ test.describe('AI Features', () => {
|
||||
// Test via API to avoid UI dependencies
|
||||
const interests = await page.request.get(`/api/v1/interests?limit=1`).catch(() => null);
|
||||
if (interests?.ok()) {
|
||||
const data = await interests.json().catch(() => ({ data: [] }));
|
||||
const data = (await interests.json().catch(() => ({ data: [] }))) as any;
|
||||
const interest = data.data?.[0];
|
||||
|
||||
if (interest) {
|
||||
@@ -115,7 +129,7 @@ test.describe('AI Features', () => {
|
||||
expect([200, 202, 404].includes(draftRes.status())).toBeTruthy();
|
||||
|
||||
if (draftRes.status() === 202) {
|
||||
const result = await draftRes.json();
|
||||
const result = (await draftRes.json()) as any;
|
||||
expect(result.jobId).toBeTruthy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ async function signUpUser(email: string, password: string, name: string) {
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
const data = (await res.json()) as any;
|
||||
return data.user?.id ?? data.id;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ async function signUpUser(email: string, password: string, name: string) {
|
||||
});
|
||||
|
||||
if (loginRes.ok) {
|
||||
const loginData = await loginRes.json();
|
||||
const loginData = (await loginRes.json()) as any;
|
||||
return loginData.user?.id ?? loginData.id;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ async function seedReservation(portId: string) {
|
||||
ctx,
|
||||
{ id: berth.id },
|
||||
);
|
||||
return (await res.json()).data as { id: string; berthId: string };
|
||||
return ((await res.json()) as any).data as { id: string; berthId: string };
|
||||
}
|
||||
|
||||
describe('GET /api/v1/berth-reservations', () => {
|
||||
@@ -51,7 +51,7 @@ describe('GET /api/v1/berth-reservations', () => {
|
||||
);
|
||||
expect(res.status).toBe(200);
|
||||
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
const ids = (body.data as Array<{ id: string }>).map((r) => r.id).sort();
|
||||
expect(ids).toEqual([r1.id, r2.id].sort());
|
||||
expect(body.pagination).toMatchObject({ page: 1, total: 2 });
|
||||
@@ -70,7 +70,7 @@ describe('GET /api/v1/berth-reservations', () => {
|
||||
);
|
||||
expect(res.status).toBe(200);
|
||||
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
const ids = (body.data as Array<{ id: string }>).map((r) => r.id);
|
||||
expect(ids).not.toContain(reservationInB.id);
|
||||
});
|
||||
@@ -88,7 +88,7 @@ describe('GET /api/v1/berth-reservations', () => {
|
||||
);
|
||||
expect(res.status).toBe(200);
|
||||
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.data).toHaveLength(2);
|
||||
expect(body.pagination).toMatchObject({
|
||||
page: 1,
|
||||
|
||||
@@ -19,7 +19,7 @@ describe('POST /api/v1/companies', () => {
|
||||
});
|
||||
const res = await createHandler(req, ctx, {});
|
||||
expect(res.status).toBe(201);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.data.name).toBe(name);
|
||||
expect(body.data.portId).toBe(port.id);
|
||||
expect(body.data.status).toBe('active');
|
||||
@@ -88,7 +88,7 @@ describe('GET /api/v1/companies', () => {
|
||||
);
|
||||
const res = await listHandler(req, ctx, {});
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.data.some((c: { name: string }) => c.name === 'ListedCo')).toBe(true);
|
||||
expect(body.pagination.page).toBe(1);
|
||||
expect(body.pagination.pageSize).toBe(20);
|
||||
@@ -115,7 +115,7 @@ describe('GET /api/v1/companies', () => {
|
||||
);
|
||||
const res = await listHandler(req, ctx, {});
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.data.every((c: { status: string }) => c.status === 'dissolved')).toBe(true);
|
||||
expect(body.data.some((c: { name: string }) => c.name === 'DissolvedCo')).toBe(true);
|
||||
expect(body.data.some((c: { name: string }) => c.name === 'ActiveCo')).toBe(false);
|
||||
@@ -133,7 +133,7 @@ describe('GET /api/v1/companies/[id]', () => {
|
||||
const req = makeMockRequest('GET', `http://localhost/api/v1/companies/${company.id}`);
|
||||
const res = await getHandler(req, ctx, { id: company.id });
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.data.id).toBe(company.id);
|
||||
expect(body.data.name).toBe('DetailCo');
|
||||
});
|
||||
@@ -162,7 +162,7 @@ describe('PATCH /api/v1/companies/[id]', () => {
|
||||
});
|
||||
const res = await patchHandler(req, ctx, { id: company.id });
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.data.name).toBe('AfterCo');
|
||||
expect(body.data.notes).toBe('updated notes');
|
||||
});
|
||||
@@ -211,7 +211,7 @@ describe('GET /api/v1/companies/autocomplete', () => {
|
||||
);
|
||||
const res = await autocompleteHandler(req, ctx, {});
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.data.length).toBeGreaterThanOrEqual(1);
|
||||
expect(body.data.every((c: { name: string }) => c.name.includes('AutoCompleteCoMatch'))).toBe(
|
||||
true,
|
||||
@@ -224,7 +224,7 @@ describe('GET /api/v1/companies/autocomplete', () => {
|
||||
const req = makeMockRequest('GET', 'http://localhost/api/v1/companies/autocomplete');
|
||||
const res = await autocompleteHandler(req, ctx, {});
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.data).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -56,7 +56,7 @@ describe('GET /api/v1/interests/[id]/berths (listHandler)', () => {
|
||||
const req = makeMockRequest('GET', `http://localhost/api/v1/interests/${interest.id}/berths`);
|
||||
const res = await listHandler(req, ctx, { id: interest.id });
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.data).toHaveLength(1);
|
||||
expect(body.data[0].berthId).toBe(berth.id);
|
||||
expect(body.data[0].mooringNumber).toBe(berth.mooringNumber);
|
||||
@@ -102,7 +102,7 @@ describe('POST /api/v1/interests/[id]/berths (addHandler)', () => {
|
||||
});
|
||||
const res = await addHandler(req, ctx, { id: interest.id });
|
||||
expect(res.status).toBe(201);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.data.berthId).toBe(berth.id);
|
||||
expect(body.data.isSpecificInterest).toBe(true);
|
||||
});
|
||||
@@ -165,7 +165,7 @@ describe('PATCH /api/v1/interests/[id]/berths/[berthId] (patchHandler)', () => {
|
||||
);
|
||||
const res = await patchHandler(req, ctx, { id: interest.id, berthId: berth.id });
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.data.isInEoiBundle).toBe(true);
|
||||
expect(body.data.isSpecificInterest).toBe(false);
|
||||
});
|
||||
|
||||
@@ -43,7 +43,7 @@ describe('GET /api/v1/companies/[id]/members', () => {
|
||||
const req = makeMockRequest('GET', `http://localhost/api/v1/companies/${company.id}/members`);
|
||||
const res = await listHandler(req, ctx, { id: company.id });
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(Array.isArray(body.data)).toBe(true);
|
||||
expect(body.data.length).toBe(2);
|
||||
expect(body.data.every((m: { endDate: string | null }) => m.endDate === null)).toBe(true);
|
||||
@@ -81,7 +81,7 @@ describe('GET /api/v1/companies/[id]/members', () => {
|
||||
ctx,
|
||||
{ id: company.id },
|
||||
);
|
||||
const createdBody = await createRes.json();
|
||||
const createdBody = (await createRes.json()) as any;
|
||||
const toEndId = createdBody.data.id as string;
|
||||
|
||||
const delRes = await deleteHandler(
|
||||
@@ -100,7 +100,7 @@ describe('GET /api/v1/companies/[id]/members', () => {
|
||||
ctx,
|
||||
{ id: company.id },
|
||||
);
|
||||
const activeBody = await activeOnlyRes.json();
|
||||
const activeBody = (await activeOnlyRes.json()) as any;
|
||||
expect(activeBody.data.length).toBe(1);
|
||||
|
||||
// activeOnly=false.
|
||||
@@ -112,7 +112,7 @@ describe('GET /api/v1/companies/[id]/members', () => {
|
||||
ctx,
|
||||
{ id: company.id },
|
||||
);
|
||||
const allBody = await allRes.json();
|
||||
const allBody = (await allRes.json()) as any;
|
||||
expect(allBody.data.length).toBe(2);
|
||||
});
|
||||
|
||||
@@ -143,7 +143,7 @@ describe('POST /api/v1/companies/[id]/members', () => {
|
||||
});
|
||||
const res = await createHandler(req, ctx, { id: company.id });
|
||||
expect(res.status).toBe(201);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.data.companyId).toBe(company.id);
|
||||
expect(body.data.clientId).toBe(client.id);
|
||||
expect(body.data.role).toBe('director');
|
||||
@@ -217,7 +217,7 @@ describe('PATCH /api/v1/companies/[id]/members/[mid]', () => {
|
||||
ctx,
|
||||
{ id: company.id },
|
||||
);
|
||||
const created = (await createRes.json()).data;
|
||||
const created = ((await createRes.json()) as any).data;
|
||||
|
||||
const patchRes = await patchHandler(
|
||||
makeMockRequest(
|
||||
@@ -234,7 +234,7 @@ describe('PATCH /api/v1/companies/[id]/members/[mid]', () => {
|
||||
{ id: company.id, mid: created.id },
|
||||
);
|
||||
expect(patchRes.status).toBe(200);
|
||||
const body = await patchRes.json();
|
||||
const body = (await patchRes.json()) as any;
|
||||
expect(body.data.role).toBe('officer');
|
||||
expect(body.data.notes).toBe('promoted');
|
||||
});
|
||||
@@ -257,7 +257,7 @@ describe('PATCH /api/v1/companies/[id]/members/[mid]', () => {
|
||||
ctxA,
|
||||
{ id: company.id },
|
||||
);
|
||||
const created = (await createRes.json()).data;
|
||||
const created = ((await createRes.json()) as any).data;
|
||||
|
||||
const ctxB = makeMockCtx({ portId: portB.id, permissions: makeFullPermissions() });
|
||||
const patchRes = await patchHandler(
|
||||
@@ -291,7 +291,7 @@ describe('DELETE /api/v1/companies/[id]/members/[mid]', () => {
|
||||
ctx,
|
||||
{ id: company.id },
|
||||
);
|
||||
const created = (await createRes.json()).data;
|
||||
const created = ((await createRes.json()) as any).data;
|
||||
|
||||
const before = new Date();
|
||||
const delRes = await deleteHandler(
|
||||
@@ -329,7 +329,7 @@ describe('DELETE /api/v1/companies/[id]/members/[mid]', () => {
|
||||
ctx,
|
||||
{ id: company.id },
|
||||
);
|
||||
const created = (await createRes.json()).data;
|
||||
const created = ((await createRes.json()) as any).data;
|
||||
|
||||
const explicitEnd = new Date('2026-06-01T00:00:00.000Z');
|
||||
const delRes = await deleteHandler(
|
||||
@@ -373,7 +373,7 @@ describe('POST /api/v1/companies/[id]/members/[mid]/set-primary', () => {
|
||||
ctx,
|
||||
{ id: company.id },
|
||||
);
|
||||
const m1 = (await m1Res.json()).data;
|
||||
const m1 = ((await m1Res.json()) as any).data;
|
||||
|
||||
// M2, M3 — not primary.
|
||||
const m2Res = await createHandler(
|
||||
@@ -387,7 +387,7 @@ describe('POST /api/v1/companies/[id]/members/[mid]/set-primary', () => {
|
||||
ctx,
|
||||
{ id: company.id },
|
||||
);
|
||||
const m2 = (await m2Res.json()).data;
|
||||
const m2 = ((await m2Res.json()) as any).data;
|
||||
|
||||
const m3Res = await createHandler(
|
||||
makeMockRequest('POST', `http://localhost/api/v1/companies/${company.id}/members`, {
|
||||
@@ -400,7 +400,7 @@ describe('POST /api/v1/companies/[id]/members/[mid]/set-primary', () => {
|
||||
ctx,
|
||||
{ id: company.id },
|
||||
);
|
||||
const m3 = (await m3Res.json()).data;
|
||||
const m3 = ((await m3Res.json()) as any).data;
|
||||
|
||||
// Promote M2.
|
||||
const setPrimRes = await setPrimaryHandler(
|
||||
@@ -412,7 +412,7 @@ describe('POST /api/v1/companies/[id]/members/[mid]/set-primary', () => {
|
||||
{ id: company.id, mid: m2.id },
|
||||
);
|
||||
expect(setPrimRes.status).toBe(200);
|
||||
const setPrimBody = await setPrimRes.json();
|
||||
const setPrimBody = (await setPrimRes.json()) as any;
|
||||
expect(setPrimBody.data.id).toBe(m2.id);
|
||||
expect(setPrimBody.data.isPrimary).toBe(true);
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ describe('POST /api/v1/berths/[id]/reservations', () => {
|
||||
});
|
||||
const res = await createReservationHandler(req, ctx, { id: berth.id });
|
||||
expect(res.status).toBe(201);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.data.berthId).toBe(berth.id);
|
||||
expect(body.data.clientId).toBe(client.id);
|
||||
expect(body.data.yachtId).toBe(yacht.id);
|
||||
@@ -129,7 +129,7 @@ describe('POST /api/v1/berths/[id]/reservations', () => {
|
||||
);
|
||||
const res = await createReservationHandler(req, ctx, { id: urlBerth.id });
|
||||
expect(res.status).toBe(201);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.data.berthId).toBe(urlBerth.id);
|
||||
expect(body.data.berthId).not.toBe(bodyBerth.id);
|
||||
});
|
||||
@@ -182,7 +182,7 @@ describe('GET /api/v1/berths/[id]/reservations', () => {
|
||||
{ id: berthA.id },
|
||||
);
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.data.length).toBe(1);
|
||||
expect(body.data[0].berthId).toBe(berthA.id);
|
||||
});
|
||||
@@ -213,7 +213,7 @@ describe('GET /api/v1/berth-reservations/[id]', () => {
|
||||
ctx,
|
||||
{ id: berth.id },
|
||||
);
|
||||
const reservation = (await createRes.json()).data;
|
||||
const reservation = ((await createRes.json()) as any).data;
|
||||
|
||||
const res = await getReservationHandler(
|
||||
makeMockRequest('GET', `http://localhost/api/v1/berth-reservations/${reservation.id}`),
|
||||
@@ -221,7 +221,7 @@ describe('GET /api/v1/berth-reservations/[id]', () => {
|
||||
{ id: reservation.id },
|
||||
);
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.data.id).toBe(reservation.id);
|
||||
});
|
||||
|
||||
@@ -248,7 +248,7 @@ describe('GET /api/v1/berth-reservations/[id]', () => {
|
||||
ctxA,
|
||||
{ id: berth.id },
|
||||
);
|
||||
const reservation = (await createRes.json()).data;
|
||||
const reservation = ((await createRes.json()) as any).data;
|
||||
|
||||
const ctxB = makeMockCtx({ portId: portB.id, permissions: makeFullPermissions() });
|
||||
const res = await getReservationHandler(
|
||||
@@ -285,7 +285,7 @@ describe('PATCH /api/v1/berth-reservations/[id]', () => {
|
||||
ctx,
|
||||
{ id: berth.id },
|
||||
);
|
||||
const reservation = (await createRes.json()).data;
|
||||
const reservation = ((await createRes.json()) as any).data;
|
||||
return { port, berth, client, yacht, ctx, reservation };
|
||||
}
|
||||
|
||||
@@ -299,7 +299,7 @@ describe('PATCH /api/v1/berth-reservations/[id]', () => {
|
||||
{ id: reservation.id },
|
||||
);
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.data.status).toBe('active');
|
||||
});
|
||||
|
||||
@@ -329,7 +329,7 @@ describe('PATCH /api/v1/berth-reservations/[id]', () => {
|
||||
{ id: reservation.id },
|
||||
);
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.data.status).toBe('ended');
|
||||
expect(new Date(body.data.endDate).toISOString()).toBe(endDate.toISOString());
|
||||
});
|
||||
@@ -344,7 +344,7 @@ describe('PATCH /api/v1/berth-reservations/[id]', () => {
|
||||
{ id: reservation.id },
|
||||
);
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.data.status).toBe('cancelled');
|
||||
});
|
||||
|
||||
@@ -467,7 +467,7 @@ describe('DELETE /api/v1/berth-reservations/[id]', () => {
|
||||
ctx,
|
||||
{ id: berth.id },
|
||||
);
|
||||
const reservation = (await createRes.json()).data;
|
||||
const reservation = ((await createRes.json()) as any).data;
|
||||
|
||||
const delRes = await deleteReservationHandler(
|
||||
makeMockRequest('DELETE', `http://localhost/api/v1/berth-reservations/${reservation.id}`),
|
||||
|
||||
@@ -42,7 +42,7 @@ describe('saved-views ownership enforcement', () => {
|
||||
{ id: viewId },
|
||||
);
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.data.name).toBe('Renamed by owner');
|
||||
});
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ describe('GET /api/v1/yachts/[id]', () => {
|
||||
const req = makeMockRequest('GET', `http://localhost/api/v1/yachts/${yacht.id}`);
|
||||
const res = await getHandler(req, ctx, { id: yacht.id });
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.data.id).toBe(yacht.id);
|
||||
expect(body.data.name).toBe('Detail Yacht');
|
||||
});
|
||||
@@ -77,7 +77,7 @@ describe('PATCH /api/v1/yachts/[id]', () => {
|
||||
});
|
||||
const res = await patchHandler(req, ctx, { id: yacht.id });
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.data.name).toBe('After');
|
||||
expect(body.data.notes).toBe('updated notes');
|
||||
});
|
||||
@@ -184,7 +184,7 @@ describe('POST /api/v1/yachts/[id]/transfer', () => {
|
||||
});
|
||||
const res = await transferHandler(req, ctx, { id: yacht.id });
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.data.currentOwnerType).toBe('company');
|
||||
expect(body.data.currentOwnerId).toBe(company.id);
|
||||
});
|
||||
@@ -262,7 +262,7 @@ describe('GET /api/v1/yachts/[id]/ownership-history', () => {
|
||||
);
|
||||
const res = await historyHandler(req, ctxFull, { id: yacht.id });
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.data).toHaveLength(2);
|
||||
// Sorted DESC by startDate — newest first
|
||||
const firstStart = new Date(body.data[0].startDate).getTime();
|
||||
@@ -312,7 +312,7 @@ describe('GET /api/v1/yachts/autocomplete', () => {
|
||||
);
|
||||
const res = await autocompleteHandler(req, ctx, {});
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.data.length).toBeGreaterThanOrEqual(1);
|
||||
expect(body.data.every((y: { name: string }) => y.name.includes('AutoCompleteMatch'))).toBe(
|
||||
true,
|
||||
@@ -325,7 +325,7 @@ describe('GET /api/v1/yachts/autocomplete', () => {
|
||||
const req = makeMockRequest('GET', 'http://localhost/api/v1/yachts/autocomplete');
|
||||
const res = await autocompleteHandler(req, ctx, {});
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.data).toEqual([]);
|
||||
});
|
||||
|
||||
@@ -346,7 +346,7 @@ describe('GET /api/v1/yachts/autocomplete', () => {
|
||||
);
|
||||
const res = await autocompleteHandler(req, ctx, {});
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.data).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -22,7 +22,7 @@ describe('POST /api/v1/yachts (createHandler)', () => {
|
||||
});
|
||||
const res = await createHandler(req, ctx, {});
|
||||
expect(res.status).toBe(201);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.data.name).toBe('Sea Breeze');
|
||||
expect(body.data.currentOwnerId).toBe(client.id);
|
||||
});
|
||||
@@ -63,7 +63,7 @@ describe('GET /api/v1/yachts (listHandler)', () => {
|
||||
const req = makeMockRequest('GET', 'http://localhost/api/v1/yachts?page=1&limit=20&order=desc');
|
||||
const res = await listHandler(req, ctx, {});
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.data.some((y: { name: string }) => y.name === 'Listed')).toBe(true);
|
||||
expect(body.pagination.page).toBe(1);
|
||||
expect(body.pagination.pageSize).toBe(20);
|
||||
|
||||
@@ -32,7 +32,7 @@ async function callHandler(
|
||||
const req = makeMockRequest('GET', url.toString());
|
||||
const res = await getMatchCandidatesHandler(req, ctx);
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
return body.data as MatchData[];
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ describe('GET /api/health (liveness)', () => {
|
||||
it('returns 200 + status=ok regardless of downstream dependency state', async () => {
|
||||
const res = await healthGet();
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.status).toBe('ok');
|
||||
expect(body.timestamp).toMatch(/^\d{4}-\d{2}-\d{2}T/);
|
||||
});
|
||||
@@ -25,7 +25,7 @@ describe('GET /api/ready (readiness)', () => {
|
||||
// active port is configured for, via getStorageBackend().head().
|
||||
const res = await readyGet();
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.status).toBe('ready');
|
||||
expect(body.checks).toEqual({
|
||||
postgres: 'ok',
|
||||
|
||||
@@ -59,7 +59,7 @@ describe('POST /api/public/interests — trio creation', () => {
|
||||
});
|
||||
const res = await POST(req);
|
||||
expect(res.status).toBe(201);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
const interestId: string = body.data.id;
|
||||
|
||||
const [interest] = await db.select().from(interests).where(eq(interests.id, interestId));
|
||||
@@ -116,7 +116,7 @@ describe('POST /api/public/interests — trio creation', () => {
|
||||
});
|
||||
const res = await POST(req);
|
||||
expect(res.status).toBe(201);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
const interestId: string = body.data.id;
|
||||
|
||||
const [interest] = await db.select().from(interests).where(eq(interests.id, interestId));
|
||||
@@ -179,7 +179,7 @@ describe('POST /api/public/interests — trio creation', () => {
|
||||
);
|
||||
const firstRes = await POST(firstReq);
|
||||
expect(firstRes.status).toBe(201);
|
||||
const firstBody = await firstRes.json();
|
||||
const firstBody = (await firstRes.json()) as any;
|
||||
|
||||
const [firstInterest] = await db
|
||||
.select()
|
||||
@@ -204,7 +204,7 @@ describe('POST /api/public/interests — trio creation', () => {
|
||||
);
|
||||
const secondRes = await POST(secondReq);
|
||||
expect(secondRes.status).toBe(201);
|
||||
const secondBody = await secondRes.json();
|
||||
const secondBody = (await secondRes.json()) as any;
|
||||
|
||||
const [secondInterest] = await db
|
||||
.select()
|
||||
@@ -248,7 +248,7 @@ describe('POST /api/public/interests — trio creation', () => {
|
||||
);
|
||||
const firstRes = await POST(firstReq);
|
||||
expect(firstRes.status).toBe(201);
|
||||
const firstBody = await firstRes.json();
|
||||
const firstBody = (await firstRes.json()) as any;
|
||||
const [firstInterest] = await db
|
||||
.select()
|
||||
.from(interests)
|
||||
@@ -277,7 +277,7 @@ describe('POST /api/public/interests — trio creation', () => {
|
||||
);
|
||||
const secondRes = await POST(secondReq);
|
||||
expect(secondRes.status).toBe(201);
|
||||
const secondBody = await secondRes.json();
|
||||
const secondBody = (await secondRes.json()) as any;
|
||||
const [secondInterest] = await db
|
||||
.select()
|
||||
.from(interests)
|
||||
|
||||
@@ -117,7 +117,7 @@ describe('GET /api/storage/[token]', () => {
|
||||
);
|
||||
const res = await callRoute(badToken);
|
||||
expect(res.status).toBe(403);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.error).toMatch(/Invalid|expired/i);
|
||||
});
|
||||
|
||||
@@ -154,7 +154,7 @@ describe('GET /api/storage/[token]', () => {
|
||||
|
||||
const second = await callRoute(token);
|
||||
expect(second.status).toBe(403);
|
||||
const body = await second.json();
|
||||
const body = (await second.json()) as any;
|
||||
expect(body.error).toMatch(/already used/i);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -61,7 +61,7 @@ describe('Documenso recipient redirect — EMAIL_REDIRECT_TO', () => {
|
||||
]);
|
||||
|
||||
expect(fetchMock).toHaveBeenCalledOnce();
|
||||
const callBody = JSON.parse(fetchMock.mock.calls[0]![1].body as string);
|
||||
const callBody = JSON.parse(fetchMock.mock.calls[0]![1].body as string) as any;
|
||||
expect(callBody.recipients).toHaveLength(2);
|
||||
for (const r of callBody.recipients) {
|
||||
expect(r.email).toBe(REDIRECT_TARGET);
|
||||
@@ -82,7 +82,7 @@ describe('Documenso recipient redirect — EMAIL_REDIRECT_TO', () => {
|
||||
});
|
||||
|
||||
expect(fetchMock).toHaveBeenCalledOnce();
|
||||
const callBody = JSON.parse(fetchMock.mock.calls[0]![1].body as string);
|
||||
const callBody = JSON.parse(fetchMock.mock.calls[0]![1].body as string) as any;
|
||||
expect(callBody.formValues['client.primaryEmail']).toBe(REDIRECT_TARGET);
|
||||
expect(callBody.formValues['developer.email']).toBe(REDIRECT_TARGET);
|
||||
// Non-email field untouched
|
||||
@@ -99,7 +99,7 @@ describe('Documenso recipient redirect — EMAIL_REDIRECT_TO', () => {
|
||||
],
|
||||
});
|
||||
|
||||
const callBody = JSON.parse(fetchMock.mock.calls[0]![1].body as string);
|
||||
const callBody = JSON.parse(fetchMock.mock.calls[0]![1].body as string) as any;
|
||||
for (const r of callBody.recipients) {
|
||||
expect(r.email).toBe(REDIRECT_TARGET);
|
||||
expect(r.name).toMatch(/\(was: .+@realclient\.com\)/);
|
||||
@@ -134,7 +134,7 @@ describe('Documenso recipient redirect — EMAIL_REDIRECT_TO', () => {
|
||||
{ name: 'Alice', email: 'alice@realclient.com', role: 'SIGNER', signingOrder: 1 },
|
||||
]);
|
||||
|
||||
const callBody = JSON.parse(fetchMock.mock.calls[0]![1].body as string);
|
||||
const callBody = JSON.parse(fetchMock.mock.calls[0]![1].body as string) as any;
|
||||
expect(callBody.recipients[0].email).toBe('alice@realclient.com');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -26,7 +26,7 @@ describe('encrypt / decrypt', () => {
|
||||
});
|
||||
|
||||
it('tampered data field throws on decrypt', () => {
|
||||
const stored = JSON.parse(encrypt('tamper me'));
|
||||
const stored = JSON.parse(encrypt('tamper me')) as any;
|
||||
// Flip the first hex byte of data
|
||||
const originalByte = stored.data.slice(0, 2);
|
||||
const flipped = originalByte === 'ff' ? '00' : 'ff';
|
||||
@@ -36,7 +36,7 @@ describe('encrypt / decrypt', () => {
|
||||
});
|
||||
|
||||
it('tampered auth tag throws on decrypt', () => {
|
||||
const stored = JSON.parse(encrypt('tamper tag'));
|
||||
const stored = JSON.parse(encrypt('tamper tag')) as any;
|
||||
const originalByte = stored.tag.slice(0, 2);
|
||||
const flipped = originalByte === 'ff' ? '00' : 'ff';
|
||||
stored.tag = flipped + stored.tag.slice(2);
|
||||
|
||||
@@ -60,7 +60,7 @@ describe('Error response security — AppError subclasses', () => {
|
||||
const error = new AppError(400, 'Bad request', 'BAD_REQUEST');
|
||||
const response = errorResponse(error);
|
||||
expect(response.status).toBe(400);
|
||||
const body = await response.json();
|
||||
const body = (await response.json()) as any;
|
||||
expect(body.error).toBe('Bad request');
|
||||
expect(body.code).toBe('BAD_REQUEST');
|
||||
// Stack trace must never appear in the response body
|
||||
@@ -72,7 +72,7 @@ describe('Error response security — AppError subclasses', () => {
|
||||
const error = new NotFoundError('Client');
|
||||
const response = errorResponse(error);
|
||||
expect(response.status).toBe(404);
|
||||
const body = await response.json();
|
||||
const body = (await response.json()) as any;
|
||||
// Message is now plain-text user-facing (no jargon, lowercased entity).
|
||||
expect(body.error).toBe("We couldn't find that client. It may have been removed.");
|
||||
expect(body.code).toBe('NOT_FOUND');
|
||||
@@ -83,7 +83,7 @@ describe('Error response security — AppError subclasses', () => {
|
||||
const error = new ForbiddenError();
|
||||
const response = errorResponse(error);
|
||||
expect(response.status).toBe(403);
|
||||
const body = await response.json();
|
||||
const body = (await response.json()) as any;
|
||||
expect(body.code).toBe('FORBIDDEN');
|
||||
});
|
||||
|
||||
@@ -91,7 +91,7 @@ describe('Error response security — AppError subclasses', () => {
|
||||
const error = new RateLimitError(60);
|
||||
const response = errorResponse(error);
|
||||
expect(response.status).toBe(429);
|
||||
const body = await response.json();
|
||||
const body = (await response.json()) as any;
|
||||
expect(body.retryAfter).toBe(60);
|
||||
expect(JSON.stringify(body)).not.toMatch(/stack|node_modules/i);
|
||||
});
|
||||
@@ -102,7 +102,7 @@ describe('Error response security — AppError subclasses', () => {
|
||||
]);
|
||||
const response = errorResponse(error);
|
||||
expect(response.status).toBe(400);
|
||||
const body = await response.json();
|
||||
const body = (await response.json()) as any;
|
||||
expect(body.details).toHaveLength(1);
|
||||
expect(body.details[0].field).toBe('email');
|
||||
expect(JSON.stringify(body)).not.toContain('src/');
|
||||
@@ -115,7 +115,7 @@ describe('Error response security — unknown / native errors', () => {
|
||||
const error = new Error('SELECT * FROM users WHERE id = 1; DROP TABLE users;--');
|
||||
const response = errorResponse(error);
|
||||
expect(response.status).toBe(500);
|
||||
const body = await response.json();
|
||||
const body = (await response.json()) as any;
|
||||
expect(body.error).toBe('Internal server error');
|
||||
expect(JSON.stringify(body)).not.toContain('SELECT');
|
||||
expect(JSON.stringify(body)).not.toContain('DROP TABLE');
|
||||
@@ -127,7 +127,7 @@ describe('Error response security — unknown / native errors', () => {
|
||||
);
|
||||
const response = errorResponse(error);
|
||||
expect(response.status).toBe(500);
|
||||
const body = await response.json();
|
||||
const body = (await response.json()) as any;
|
||||
expect(body.error).toBe('Internal server error');
|
||||
expect(JSON.stringify(body)).not.toContain('G:\\');
|
||||
expect(JSON.stringify(body)).not.toContain('src\\lib');
|
||||
@@ -137,7 +137,7 @@ describe('Error response security — unknown / native errors', () => {
|
||||
const error = new Error('ENOENT: no such file at /app/node_modules/pg/lib/connection.js');
|
||||
const response = errorResponse(error);
|
||||
expect(response.status).toBe(500);
|
||||
const body = await response.json();
|
||||
const body = (await response.json()) as any;
|
||||
expect(body.error).toBe('Internal server error');
|
||||
expect(JSON.stringify(body)).not.toContain('node_modules');
|
||||
expect(JSON.stringify(body)).not.toContain('ENOENT');
|
||||
@@ -147,7 +147,7 @@ describe('Error response security — unknown / native errors', () => {
|
||||
const error = new Error('relation "users" does not exist');
|
||||
const response = errorResponse(error);
|
||||
expect(response.status).toBe(500);
|
||||
const body = await response.json();
|
||||
const body = (await response.json()) as any;
|
||||
expect(body.error).toBe('Internal server error');
|
||||
expect(JSON.stringify(body)).not.toContain('relation');
|
||||
expect(JSON.stringify(body)).not.toContain('"users"');
|
||||
@@ -156,14 +156,14 @@ describe('Error response security — unknown / native errors', () => {
|
||||
it('null thrown value returns generic 500', async () => {
|
||||
const response = errorResponse(null);
|
||||
expect(response.status).toBe(500);
|
||||
const body = await response.json();
|
||||
const body = (await response.json()) as any;
|
||||
expect(body.error).toBe('Internal server error');
|
||||
});
|
||||
|
||||
it('string thrown returns generic 500', async () => {
|
||||
const response = errorResponse('something went wrong internally');
|
||||
expect(response.status).toBe(500);
|
||||
const body = await response.json();
|
||||
const body = (await response.json()) as any;
|
||||
expect(body.error).toBe('Internal server error');
|
||||
// The raw string must not appear in the response
|
||||
expect(JSON.stringify(body)).not.toContain('something went wrong internally');
|
||||
@@ -184,7 +184,7 @@ describe('Error response security — ZodError', () => {
|
||||
]);
|
||||
const response = errorResponse(error);
|
||||
expect(response.status).toBe(400);
|
||||
const body = await response.json();
|
||||
const body = (await response.json()) as any;
|
||||
expect(body.code).toBe('VALIDATION_ERROR');
|
||||
expect(body.details).toBeDefined();
|
||||
expect(Array.isArray(body.details)).toBe(true);
|
||||
@@ -203,7 +203,7 @@ describe('Error response security — ZodError', () => {
|
||||
},
|
||||
]);
|
||||
const response = errorResponse(error);
|
||||
const body = await response.json();
|
||||
const body = (await response.json()) as any;
|
||||
const bodyStr = JSON.stringify(body);
|
||||
expect(bodyStr).not.toContain('src/');
|
||||
expect(bodyStr).not.toContain('node_modules');
|
||||
@@ -222,7 +222,7 @@ describe('Error response security — response shape invariants', () => {
|
||||
new RateLimitError(30),
|
||||
];
|
||||
for (const err of errors) {
|
||||
const body = await errorResponse(err).json();
|
||||
const body = (await errorResponse(err).json()) as any;
|
||||
expect(typeof body.error).toBe('string');
|
||||
expect(body.error.length).toBeGreaterThan(0);
|
||||
// Stack must never appear
|
||||
@@ -232,7 +232,7 @@ describe('Error response security — response shape invariants', () => {
|
||||
|
||||
it('500 response body carries error + code (and requestId when in-flight)', async () => {
|
||||
const response = errorResponse(new Error('db connection refused'));
|
||||
const body = await response.json();
|
||||
const body = (await response.json()) as any;
|
||||
// Allowed keys for a 500 response. `code` is always present; `requestId`
|
||||
// and `message` only appear when an active request context is in scope.
|
||||
const allowed = new Set(['error', 'code', 'requestId', 'message']);
|
||||
|
||||
@@ -130,7 +130,7 @@ describe('placeFields v2 dispatch', () => {
|
||||
const [url, init] = fetchMock.mock.calls[0]!;
|
||||
expect(url).toBe('https://documenso.test/api/v2/envelope/field/create-many');
|
||||
expect((init as RequestInit).method).toBe('POST');
|
||||
const body = JSON.parse(String((init as RequestInit).body));
|
||||
const body = JSON.parse(String((init as RequestInit).body)) as any;
|
||||
expect(body.envelopeId).toBe('env-123');
|
||||
expect(body.fields[0]).toMatchObject({
|
||||
recipientId: 'rec-a',
|
||||
@@ -198,7 +198,7 @@ describe('placeFields v1 dispatch', () => {
|
||||
expect(fetchMock).toHaveBeenCalledTimes(2);
|
||||
const firstCall = fetchMock.mock.calls[0]!;
|
||||
expect(firstCall[0]).toBe('https://documenso.test/api/v1/documents/doc-123/fields');
|
||||
const firstBody = JSON.parse(String((firstCall[1] as RequestInit).body));
|
||||
const firstBody = JSON.parse(String((firstCall[1] as RequestInit).body)) as any;
|
||||
expect(firstBody).toMatchObject({
|
||||
recipientId: 42,
|
||||
type: 'SIGNATURE',
|
||||
@@ -227,7 +227,7 @@ describe('placeFields v1 dispatch', () => {
|
||||
],
|
||||
'port-1',
|
||||
);
|
||||
const body = JSON.parse(String((fetchMock.mock.calls[0]![1] as RequestInit).body));
|
||||
const body = JSON.parse(String((fetchMock.mock.calls[0]![1] as RequestInit).body)) as any;
|
||||
expect(body.recipientId).toBe(99);
|
||||
});
|
||||
|
||||
@@ -267,7 +267,7 @@ describe('placeDefaultSignatureFields integration', () => {
|
||||
'port-1',
|
||||
);
|
||||
expect(fetchMock).toHaveBeenCalledTimes(1);
|
||||
const body = JSON.parse(String((fetchMock.mock.calls[0]![1] as RequestInit).body));
|
||||
const body = JSON.parse(String((fetchMock.mock.calls[0]![1] as RequestInit).body)) as any;
|
||||
expect(body.fields).toHaveLength(3);
|
||||
expect(body.fields.every((f: { type: string }) => f.type === 'SIGNATURE')).toBe(true);
|
||||
expect(body.fields.every((f: { pageNumber: number }) => f.pageNumber === 4)).toBe(true);
|
||||
@@ -293,7 +293,7 @@ describe('placeDefaultSignatureFields integration', () => {
|
||||
expect(fetchMock).toHaveBeenCalledTimes(2);
|
||||
for (const call of fetchMock.mock.calls) {
|
||||
expect(call[0]).toBe('https://documenso.test/api/v1/documents/doc-z/fields');
|
||||
const body = JSON.parse(String((call[1] as RequestInit).body));
|
||||
const body = JSON.parse(String((call[1] as RequestInit).body)) as any;
|
||||
expect(body.type).toBe('SIGNATURE');
|
||||
expect(body.pageNumber).toBe(1);
|
||||
// 88% of 842 = 741 (footer band)
|
||||
|
||||
@@ -63,7 +63,7 @@ describe('POST /api/public/website-inquiries — 503 when secret unset', () => {
|
||||
),
|
||||
);
|
||||
expect(res.status).toBe(503);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.error).toMatch(/not configured/i);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -175,7 +175,7 @@ describe('POST /api/public/website-inquiries — auth + capture', () => {
|
||||
),
|
||||
);
|
||||
expect(res.status).toBe(400);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body.error).toMatch(/Unknown port/);
|
||||
});
|
||||
|
||||
@@ -193,7 +193,7 @@ describe('POST /api/public/website-inquiries — auth + capture', () => {
|
||||
),
|
||||
);
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body).toEqual({ id: 'generated-row-id', deduped: false });
|
||||
|
||||
expect(state.inserted).toHaveLength(1);
|
||||
@@ -219,7 +219,7 @@ describe('POST /api/public/website-inquiries — auth + capture', () => {
|
||||
),
|
||||
);
|
||||
expect(res.status).toBe(200);
|
||||
const body = await res.json();
|
||||
const body = (await res.json()) as any;
|
||||
expect(body).toEqual({ id: 'existing-row-id', deduped: true });
|
||||
expect(state.inserted).toHaveLength(0);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user