Add READMEs for remaining packages

- db-schema: Database schema types from kysely-codegen
- db: Database client and helper functions
- testing: Overview of testing packages
- test-helpers: Database testing utilities
- virtual-authenticator: WebAuthn virtual authenticator

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
igm
2026-01-12 13:59:34 +08:00
parent 26d10d452f
commit 01f1e1c9e3
5 changed files with 182 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
# Testing Packages
Shared testing utilities for the RevIQ platform.
## Packages
### @reviq/test-helpers
Database testing utilities including test database setup, transactions, and fixtures.
```typescript
import { createTestDb, withTestTransaction, describeE2E } from "@reviq/test-helpers";
```
### @reviq/virtual-authenticator
WebAuthn virtual authenticator for testing passkey flows without real hardware.
```typescript
import { VirtualAuthenticator } from "@reviq/virtual-authenticator";
```
## Usage
These packages are used internally for e2e and integration tests. Add them as dev dependencies:
```json
{
"devDependencies": {
"@reviq/test-helpers": "workspace:*",
"@reviq/virtual-authenticator": "workspace:*"
}
}
```

View File

@@ -0,0 +1,52 @@
# @reviq/test-helpers
Database testing utilities for integration and e2e tests.
## Usage
```typescript
import {
describeE2E,
createTestDb,
withTestTransaction,
createTestUser,
} from "@reviq/test-helpers";
describeE2E("My API tests", () => {
it("should create a user", async () => {
await withTestTransaction(async (trx) => {
const user = await createTestUser(trx, {
email: "test@example.com",
});
expect(user.id).toBeDefined();
});
});
});
```
## Exports
### Test Setup
- `describeE2E(name, fn)` - Wrapper for describe() that skips when `SKIP_DB_TESTS=1`
- `SKIP_DB_TESTS` - Boolean indicating if db tests should be skipped
### Database Utilities
- `createTestDb()` - Create an isolated test database
- `destroyTestDb(db)` - Destroy a test database
- `getSharedDb()` - Get the shared test database instance
- `destroySharedDb()` - Destroy the shared database
- `initTestDb()` - Initialize the test database
- `runMigrations(url)` - Run database migrations
- `truncateAllTables(db)` - Clear all data from tables
- `getTestDatabaseUrl()` - Get the test database connection URL
### Transaction Helpers
- `withTestTransaction(fn)` - Run a function in a rolled-back transaction
### Fixtures
- `createTestUser(trx, opts)` - Create a test user
### Constants
- `TEST_RP` - Test relying party configuration for WebAuthn
- `DEFAULT_TEST_AAGUID` - Default AAGUID for virtual authenticator
- `KNOWN_AAGUIDS` - Map of known authenticator AAGUIDs

View File

@@ -0,0 +1,39 @@
# @reviq/virtual-authenticator
WebAuthn virtual authenticator for testing passkey registration and authentication flows.
## Usage
```typescript
import { VirtualAuthenticator } from "@reviq/virtual-authenticator";
const authenticator = new VirtualAuthenticator({
aaguid: "00000000-0000-0000-0000-000000000000",
});
// Create a credential during registration
const credential = await authenticator.create(
publicKeyCredentialCreationOptions,
);
// Use the credential during authentication
const assertion = await authenticator.get(
publicKeyCredentialRequestOptions,
);
```
## Exports
### Classes
- `VirtualAuthenticator` - Simulates a WebAuthn authenticator
### Utilities
- `base64urlToUint8Array(str)` - Decode base64url to bytes
- `uint8ArrayToBase64url(bytes)` - Encode bytes to base64url
- `parseAaguid(str)` - Parse an AAGUID string to bytes
### Constants
- `DEFAULT_AAGUID` - Default AAGUID for the virtual authenticator
### Types
- `VirtualAuthenticatorOptions` - Configuration options for the authenticator