Contract UI tests
The authored test language as used in Seed Exact, every *.test.contract file with its backend, and how to run them on web and iOS.

Contract UI tests are scripts in *.test.contract files that drive the built app by testId on a clock the driver controls. They are the main check that screens, navigation and data sources work together, and they run the same on the web host and on an iOS simulator.

Running

bun exact.mjs test web # every *.test.contract, headless Chrome bun exact.mjs test web read.test.contract # one file EXACT_SIM=<simulator UUID> bun exact.mjs test ios

    test web builds the web app first. test ios builds when the build is missing or older than its sources (help.mjs).

    Each test launches the app fresh with its own store, after its first data has landed. Nothing is left running; a failed test exits 1.

    The runner starts the app's server from app.json commands.server, here the local test server. It refuses to run when a server already answers on that port. "server": {"database": false} tells Exact to skip its scratch database (app.json).

    EXACT_SIM names the simulator by UUID for repeatable runs (README). Without it Exact picks a booted iPhone or the newest Pro.

    These tests do not run in GitHub Actions.

The language as used here

The full grammar is "Authored tests" in Exact's contract-grammar.md. Lines before the first test apply to every test in the file.

Step

Meaning

Example

at "<location>"

Launch line: open the app at a route

vault.test.contract L3 at "/me/vault"

seed <n>

Launch line: seed for the driver's randomness

vault.test.contract L2 seed 42

epoch "<ISO>" or epoch now

Launch line: the app's clock start. now is for tests against live time

activity.test.contract L14, agents.test.contract L1

tap "<id>"

Press a control. A disabled control fails the step

app.test.contract L3

tap "<id>" wheel <dx> <dy>

Scroll inside a view

agents.test.contract L153

type "<id>" "<text>"

Replace a field's text. type "app" "<location>" on the root delivers a deep link

me.test.contract L20, read.test.contract L120

type "<id>" key "Enter"

Press a key in a field

open-site.test.contract L7

back

The platform's Back

read.test.contract L24

reload

Relaunch on the same store, then wait for data

me.test.contract L28

expect tree has "<id>" / missing

A node exists or not

read.test.contract L7, read.test.contract L11

expect text "<id>" == "<text>"

A node's text

read.test.contract L6

expect state <path> == <value>

A state, resource or field, dotted

me.test.contract L136, me.test.contract L253 (== [])

expect disabled "<id>" / enabled

A control's disabled

me.test.contract L19, me.test.contract L22

clock data

Wait until every request in flight has answered, clock unmoved

read.test.contract L5

clock settle

Finish transitions

app.test.contract L4

clock +<ms>

Advance the app's clock

vault.test.contract L35 (clock + 900000, the 15 minute token expiry)

clock until state <path> == <v> within <ms>

Poll on real time with the clock frozen, for state a stream reaches later

agents.test.contract L7

fail fetch "<prefix>" / pass fetch

Fetches whose URL starts with the prefix fail as a refused connection; pass clears it

read.test.contract L104-L110

request <METHOD> "<path>" <json> as fixture

The driver, not the app, calls the test server. The path is resolved against the first loopback origin granted in app.ts, http://127.0.0.1:4790. as fixture sends Authorization: Bearer fixture, which the mocks ignore

activity.test.contract L15, agents.test.contract L5

A request that answers outside 200 to 299 fails the step. The mocks use this for assertions: /activity/posts and /dev/assert-* answer 409 when the condition does not hold.

Files

File

Tests

Backend

app.test.contract

3

Live hyper.media, read only

read.test.contract

12

Live hyper.media, read only. "Assertions are structural" so edits to published documents do not break them

open-site.test.contract

4

Live hyper.media plus an unreachable host

open-site-activity.test.contract

1

Local test server (notify thread scenario) and live hyper.media

discuss.test.contract

6

Reads from live hyper.media; the one write test switches to dev.hyper.media and signs with the BIP-39 test vector phrase

profile.test.contract

2

dev.hyper.media with the BIP-39 test vector identity z6MkhMSRโ€ฆCQgSW

me.test.contract

13

Mostly none (local key storage); one test connects to the local test server as a custom server

activity.test.contract

7

Local test server, mock notify. Each test first arms fail fetch "https://hyper.media/hm/api/notify"

vault.test.contract

3

Local test server, mock vault

agents.test.contract

15

Mock agents server on port 3068, opened at the /agents-test route with the fixture key

crypto.test.contract

1

None. Runs the crypto self test inside the host runtime and compares three literals from the parity vectors

Total: 67 tests. The test vector phrase is legal winner thank year wave sausage worth useful legal winner thank yellow, a published BIP-39 vector, never a real identity. Fixture key files use a seed of 32 identical bytes.

Known baseline failures

The files carry no comments about expected failures. PR #1484 records that the Read contract had "three missing live-home child-0 failures, identical on clean main". Three tests in read.test.contract depend on child-0 on the live home ("a child document pushes and Back returns home", "document rows name their authors", "a failed load shows Retry and recovers"); that these are the three is inferred. This is the cost of asserting against live content; see Open site: implementation and evidence.

Do you like what you are reading? Subscribe to receive updates.

Unsubscribe anytime

Attributes
name
Contract UI tests
summary
The authored test language as used in Seed Exact, every *.test.contract file with its backend, and how to run them on web and iOS.