Files
waggle-os/app/tests/e2e/test-utils.ts
Oleg Maslov 0c3e2ead3b
Some checks failed
Installer Smoke / installer-smoke (push) Has been cancelled
moving
2026-09-02 10:10:29 +02:00

23 lines
646 B
TypeScript

/**
* Shared test utilities for e2e tests.
* Provides authenticated inject helper for local server tests (SEC-011).
*/
import type { FastifyInstance, InjectOptions } from 'fastify';
/**
* Shorthand: inject with auth token from the server's agentState.
* Returns the same result as server.inject().
*/
export function injectWithAuth(server: FastifyInstance, opts: InjectOptions) {
const token = server.agentState.wsSessionToken;
const existingHeaders = (opts.headers ?? {}) as Record<string, string>;
return server.inject({
...opts,
headers: {
...existingHeaders,
authorization: `Bearer ${token}`,
},
});
}