testing/db_entities.ts

DB-backed entity factories for tests that need real account + actor rows in the database.

Companion to entities.ts — that file ships in-memory factories (create_test_account, create_test_actor) for tests that mock the DB; this file ships factories that hit a real Db so query-level tests don't reimplement the same query_create_account_with_actor wrapper in every file.

For full-fledged test accounts that also need an API token + signed session cookie + role_grants, use bootstrap_test_keeper (keeper) or create_test_account_with_credentials (additional accounts) from app_server.ts instead.

Declarations
#

3 declarations

view source

create_test_account_with_actor
#

testing/db_entities.ts view source

(db: Db, options: { username: string; password_hash?: string | undefined; }): Promise<TestAccountWithActor>

Create an account + actor row pair in the database for tests.

Wraps query_create_account_with_actor with a default password_hash so suites that don't exercise password verification can stay terse. Replaces the per-file create_user / create_test_actor / create_test_account helpers that had accumulated across the auth test suite.

db

type Db

options

type { username: string; password_hash?: string | undefined; }

returns

Promise<TestAccountWithActor>

create_test_role_grant_direct
#

testing/db_entities.ts view source

(db: Db, input: CreateRoleGrantInput): Promise<RoleGrant>

Materialize a role_grant directly via query_create_role_grant, bypassing the production offer/accept consent flow. Use only when the test focuses on revoke or isolation semantics rather than the consent path itself — the schema permits null source_offer_id for exactly this case (account_schema.ts). For tests that exercise the production grant flow, drive role_grant_offer_create_action_spec + role_grant_offer_accept_action_spec over RPC instead.

db

type Db

input

returns

Promise<RoleGrant>

TestAccountWithActor
#

Depends on
#

Imported by
#