Remote / foldkit-remote/testing

Scenario

namespace · packages/remote/src/scenario.ts:641

const Scenario = {
  write,
  accepted,
  refused,
  forbidden,
  unauthenticated,
  remote,
  run,
  fromReport,
  messages,
  reads,
  breaks,
  runMessages,
  decisionOf,
  expectedDecision,
  expectedRow,
  target,
  pick,
  mismatches,
  describeMismatch,
}

In the guides

Members

Scenario.write

function · packages/remote/src/scenario.ts:643

write<Principal>(scenario: WriteScenario<Principal>): WriteScenario<Principal>

A write scenario; the types are the declaration.

Scenario.accepted

function · packages/remote/src/scenario.ts:645

accepted(row: Row): WriteExpectation

The write lands; row holds the fields it changes.

Scenario.refused

function · packages/remote/src/scenario.ts:647

refused(refusal: RefusalMatch): WriteExpectation

Refused by an invariant (or a write's ensures), or by 'Unmet', 'Conflict', 'Taken', 'Referenced'.

Scenario.forbidden

const · packages/remote/src/scenario.ts:648

forbidden: WriteExpectation

Scenario.unauthenticated

const · packages/remote/src/scenario.ts:649

unauthenticated: WriteExpectation

Scenario.remote

function · packages/remote/src/scenario.ts:234

remote<AppModel, Principal>(
  options: RemoteRunnerOptions<AppModel, Principal>,
): ScenarioRunner<Principal>

Runs a scenario through Law.check, so the client's prediction and the server's answer are compared in the same run, and through the server alone for the decision and the row it leaves. Steps: law (the client and the server agree), decision, and row, which a Forbidden or an Unauthenticated scenario has none of, since nobody it names may read it.

operation is sent with the write, but Law.check does not take one: a runner that asserts a ledger is an example's.

Scenario.run

function · packages/remote/src/scenario.ts:392

run<Principal>(
  scenario: WriteScenario<Principal>,
  runners: ReadonlyArray<ScenarioRunner<Principal>>,
  options?: {
    readonly report?: LawsReport | undefined
  },
): Effect.Effect<ScenarioResult, unknown, never>

Runs scenario on every runner, compares what each said with what the scenario expects, and issues one Scenario record per runner that had no mismatch, for each invariant the write could break (given report).

With report, a scenario that expects what enumeration disproved throws here, before any runner runs. The runners run in order.

Scenario.fromReport

function · packages/remote/src/scenario.ts:456

fromReport<Principal>(
  report: LawsReport,
  options: FromReportOptions<Principal>,
): ReadonlyArray<WriteScenario<Principal>>

The scenarios a report implies: an acceptance for each arrow it says holds, a rejection for each refused pair. Each runs the reference judge's answer against the application's own stack. A pair a write only states by its author's word (Declared), an undecided one and an undeclared arrow imply none, since the report decided nothing there.

Scenario.messages

function · packages/remote/src/scenario.ts:654

messages<Message>(
  scenario: MessageScenario<Message>,
): MessageScenario<Message>

A Message scenario.

Scenario.reads

function · packages/remote/src/scenario.ts:655

reads(reader: string, equals: unknown): MessageExpectation

Scenario.breaks

function · packages/remote/src/scenario.ts:660

breaks(law: string): MessageExpectation

Scenario.runMessages

function · packages/remote/src/scenario.ts:595

runMessages<Model, Message>(
  scenario: MessageScenario<Message>,
  options: MessageRunOptions<Model, Message>,
): ScenarioResult

Applies the history and when over the Model, and judges expect.

Scenario.decisionOf

function · packages/remote/src/scenario.ts:185

decisionOf<
  E extends {
    readonly _tag: string
  },
  R,
>(
  mutation: AnyMutation,
  call: Effect.Effect<unknown, E, R>,
): Effect.Effect<Decision, never, R>

For a runner of another package: the decision a failed call reads as, and the scenario's own sides.

Scenario.expectedDecision

function · packages/remote/src/scenario.ts:114

expectedDecision({ expect }: { readonly expect: WriteExpectation }): Decision

Scenario.expectedRow

function · packages/remote/src/scenario.ts:142

expectedRow(scenario: WriteScenario<unknown>): Row

The fields the scenario says the row holds afterwards: what the write changes, or the seeded ones.

Scenario.target

function · packages/remote/src/scenario.ts:123

target({ when: [mutation, input] }: WriteScenario<unknown>): string

The id of the row the write is aimed at, read from its encoded input.

Scenario.pick

function · packages/remote/src/scenario.ts:151

pick(row: Row, of: Row): Row

The fields of row that of names.

Scenario.mismatches

function · packages/remote/src/scenario.ts:197

mismatches(steps: ReadonlyArray<ScenarioStep>): ReadonlyArray<ScenarioStep>

Scenario.describeMismatch

function · packages/remote/src/scenario.ts:201

describeMismatch({ backend, step, expected, actual }: ScenarioStep): string

A mismatch as a line: which backend, which step, and both sides.