test: playkit v0.3.1 adoption, Zod widening, PROD smoke, NextAuth write gates (#68)
CI / skip-ci-check (push) Successful in 4s
CI / docker-ci (push) Successful in 6s
CI / secret-scan (push) Successful in 11s
CI / admin-unit (push) Successful in 1m23s
CI / viewer-unit (push) Successful in 2m2s
CI / e2e (push) Successful in 2m43s

This commit was merged in pull request #68.
This commit is contained in:
2026-07-14 22:24:07 -05:00
parent 72e89aef9f
commit 96351288f0
26 changed files with 1349 additions and 84 deletions
+22 -2
View File
@@ -1,9 +1,27 @@
import { z } from 'zod';
import { test, expect } from '../fixtures';
/**
* FastAPI `/api/v1/auth/login` uses a *separate* user DB from NextAuth.
* Set E2E_API_USERNAME + E2E_API_PASSWORD (or reuse admin FastAPI creds) to enable.
*
* Schemas mirror `backend/schemas/auth.py` (`TokenResponse` / `UserResponse`).
*/
const TokenResponse = z.object({
access_token: z.string().min(1),
refresh_token: z.string().min(1),
password_change_required: z.boolean(),
});
const UserResponse = z.object({
username: z.string().min(1),
is_admin: z.boolean(),
role: z.string().min(1),
permissions: z.record(z.boolean()),
});
type TokenResponse = z.infer<typeof TokenResponse>;
type UserResponse = z.infer<typeof UserResponse>;
test.describe('fastapi login @smoke', () => {
test('login returns bearer token when API creds set', async ({ api, timings }) => {
const username = process.env.E2E_API_USERNAME || '';
@@ -11,17 +29,19 @@ test.describe('fastapi login @smoke', () => {
test.skip(!username || !password, 'E2E_API_USERNAME/PASSWORD required for FastAPI auth');
const res = await timings.measure('api_login', () =>
api.post<{ access_token: string }>('/api/v1/auth/login', {
api.post<TokenResponse>('/api/v1/auth/login', {
body: { username, password },
expectedStatus: 200,
schema: TokenResponse,
}),
);
expect(res.data.access_token).toBeTruthy();
const authed = api.withAuthBearer(res.data.access_token);
const me = await timings.measure('api_me', () =>
authed.get('/api/v1/auth/me', { expectedStatus: 200 }),
authed.get<UserResponse>('/api/v1/auth/me', { expectedStatus: 200, schema: UserResponse }),
);
expect(me.status).toBe(200);
expect(me.data.username).toBe(username);
});
});