clone

a deno framework for local-first web apps that open instantly, work offline and sync when users choose

main
lofi / package / testing / mod.ts
mod.ts 4.4K
1/**2 * The `@nzip/lofi/testing` public surface: Playwright-backed helpers for testing3 * local-first behavior, including two-client fixtures, concurrent offline4 * convergence, app-owned readiness waits, value-free failure artifacts, and a5 * CDP virtual authenticator for headless WebAuthn flows.6 *7 * The supported Playwright release is 1.61 — the `playwright` alias in the8 * workspace import map. Install a matching Chromium with9 * `deno run -A npm:playwright@1.61.1 install chromium`.10 *11 * The scenario surface (`scenario`, `converge`, and the row assertions) turns12 * sync simulation testing into plain test declarations: named peers make13 * concurrent and offline edits through the app's own schema, and the test14 * asserts they converge. Headless scenarios drive real synced clients against15 * a local sync server and need FFI permissions; browser scenarios drive the16 * two-client Playwright fixture against a served app; `scenario.fuzz` runs17 * seeded, replayable operation sequences for property-style coverage.18 *19 * Alongside the browser fixtures, this entry re-exports the deterministic20 * seams of the schema and runtime registries — key installation, registry21 * clears, and fake runtime installation — so a test can isolate schema22 * declarations, encrypted and shared-field key state, write handles, and23 * verb dispatch without booting a runtime. Production code never calls these:24 * the runtime owns each seam at boot, and calling one in an application25 * corrupts the state the runtime maintains.26 *27 * @module28 */2930export {31 type BrowserDiagnostic,32 BrowserTestClient,33 BrowserUnavailableError,34 type ClientName,35 createTwoClientFixture,36 type FailureArtifactOptions,37 type FailureArtifacts,38 type IdentityOptions,39 type MemoryStorageState,40 type SafeContextOptions,41 TwoClientFixture,42 type TwoClientFixtureOptions,43} from "./fixture.ts";44export {45 type ConcurrentOfflineScenario,46 ConvergenceScenarioError,47 type ConvergenceScenarioErrorOptions,48 type ConvergenceStage,49 type OfflineTestClient,50 type OfflineTestFixture,51 runConcurrentOfflineConvergence,52} from "./convergence.ts";53export { ReadinessError, type ReadinessOptions, waitForReady } from "./readiness.ts";54export { assertValueFreeState, redactDiagnosticText, type ValueFreeState } from "./safety.ts";55export {56 type VirtualAuthenticatorCredential,57 type VirtualAuthenticatorHandle,58 type VirtualAuthenticatorOptions,59 withVirtualAuthenticator,60} from "./webauthn.ts";6162// Scenario simulation testing.63export { scenario, type ScenarioApi } from "./scenario/scenario.ts";64export type { ScenarioConfig, ScenarioContext } from "./scenario/run.ts";65export type { ScenarioApp } from "./scenario/headless.ts";66export type {67 ScenarioDb,68 ScenarioPeer,69 ScenarioPeerControls,70 ScenarioReadOptions,71 ScenarioSettleOptions,72 ScenarioTable,73 ScenarioTableKey,74} from "./scenario/peer.ts";75export { ScenarioError, type ScenarioErrorOptions, type ScenarioStage } from "./scenario/errors.ts";76export {77 assertNoRow,78 assertRow,79 assertRowCount,80 converge,81 type ConvergeOptions,82 type ScenarioTableRef,83} from "./scenario/assertions.ts";84export {85 type FuzzColumn,86 type FuzzOp,87 type FuzzOpKind,88 type FuzzPlan,89 type FuzzPlanInput,90 type FuzzScenarioOptions,91 generateFuzzPlan,92} from "./scenario/fuzz.ts";93export type {94 BrowserScenarioContext,95 BrowserScenarioOptions,96 BrowserScenarioPeer,97} from "./scenario/browser.ts";9899// Deterministic seams over the schema-side registries.100export {101 clearEffectDeclarations,102 type EffectContext,103 type MutationDescriptor,104 type MutationRuntime,105 type NoticeInput,106 setMutationRuntime,107} from "../schema/effects.ts";108export {109 clearEncryptedColumnKey,110 clearEncryptedColumnRegistry,111 setEncryptedColumnKey,112} from "../schema/encrypted.ts";113export {114 clearSharedFieldKeys,115 getSharedFieldKey,116 installSharedFieldKey,117 latestSharedFieldGeneration,118 sharedKeyScope,119 subscribeSharedKeyring,120} from "../schema/shared-keyring.ts";121export {122 clearSharedColumnRegistry,123 type SharedColumnConfig,124 sharedColumnConfigs,125} from "../schema/shared-registry.ts";126127// Deterministic seams over the runtime.128export { clearFingerprintPins } from "../runtime/shared-field-keys.ts";129export {130 createWriteHandle,131 type WriteHandle,132 type WriteHandleController,133 type WriteRejection,134 type WriteStage,135} from "../runtime/write-handle.ts";136export { type DevicePublicKey, memoryPopKeyStore, type PopKeyStore } from "../runtime/pop.ts";