testing/admin_integration.ts

Standard admin integration test suite for fuz_app admin routes.

describe_standard_admin_integration_tests creates a composable test suite that exercises admin account listing, role_grant grant/revoke (via the RPC surface — see role_grant_offer_create / role_grant_revoke), session/token management, and audit log routes against a real PGlite database.

Consumers call it with their route factory, session config, role schema, and RPC endpoint specs — all admin route tests come for free.

Scope: admin *semantics* — cross-admin isolation, role_grant grant/revoke flow, session/token revoke-all, audit writes. Output-schema conformance for admin methods is not the concern of this suite; it lives in:

- describe_rpc_round_trip_tests — every RPC method (admin methods included) is hit with a spec-generated valid body and the 2xx result is validated against spec.output. - describe_round_trip_validation — every REST route is hit and validated against its declared output / error schemas (SSE routes skipped via Content-Type: text/event-stream). - describe_sse_route_tests — SSE frames validated against their declared EventSpec.

Declarations
#

2 declarations

view source

describe_standard_admin_integration_tests
#

testing/admin_integration.ts view source

(options: StandardAdminIntegrationTestOptions): void

Standard admin integration test suite for fuz_app admin routes.

Exercises account listing, role_grant grant/revoke (via RPC), session management, token management, audit log reads, admin-to-admin isolation, and 401/403 error-coverage on the admin REST surface. Output-schema conformance is not in scope — see the module docstring for the suites that cover it.

options

returns

void

throws

  • Error - at setup time when `options.rpc_endpoints` is empty — admin

StandardAdminIntegrationTestOptions
#

testing/admin_integration.ts view source

StandardAdminIntegrationTestOptions

session_options

Session config for cookie-based auth.

type SessionOptions<string>

create_route_specs

Route spec factory — same one used in production.

type (ctx: AppServerContext) => Array<RouteSpec>

roles

Role schema result from create_role_schema() — used to determine valid/invalid/web-grantable roles.

rpc_endpoints

RPC endpoint specs — the source RpcAction arrays. Required; role_grant grant/revoke are RPC-only and the suite hard-fails without them.

Accepts either an array (eager) or a factory (ctx: AppServerContext) => Array<RpcEndpointSpec> — the factory form is required when action handlers must close over the per-test ctx.app_settings / ctx.deps (e.g. the canonical create_standard_rpc_actions(ctx.deps, {app_settings: ctx.app_settings}) pattern). The factory must return the same endpoint path regardless of ctx — it is invoked once at setup with a stub ctx for path lookup and again per-test by create_app_server for live dispatch.

admin_prefix

Path prefix where admin routes are mounted (e.g., '/api/admin'). Used by the 401/403 error-coverage probe to scope to fuz_app admin routes only, avoiding app-specific admin-gated routes that may use stub deps. Default '/api/admin'.

type string

app_options

Optional overrides for AppServerOptions.

db_factories

Database factories to run tests against. Default: pglite only. Pass consumer factories (e.g. [pglite_factory, pg_factory]) to also test against PostgreSQL.

type Array<DbFactory>

Depends on
#

Imported by
#