@ultimat3/testing 30.9.0 → 31.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +46 -55
- package/README.md +179 -39
- package/package.json +23 -17
- package/src/ai-conformance-answer.ts +67 -0
- package/src/ai-gateway-conformance.ts +105 -0
- package/src/ai-provider-conformance.ts +69 -0
- package/src/ai-provider-transport-conformance.ts +170 -0
- package/src/audit-sink-conformance.ts +204 -0
- package/src/auth-adapter-conformance-credentials.ts +124 -0
- package/src/auth-adapter-conformance-mfa.ts +70 -0
- package/src/auth-adapter-conformance-passkeys.ts +133 -0
- package/src/auth-adapter-conformance-sessions.ts +115 -0
- package/src/auth-adapter-conformance-support.ts +71 -0
- package/src/auth-adapter-conformance-users.ts +128 -0
- package/src/auth-adapter-conformance.ts +34 -0
- package/src/auth-limiter-factory-conformance.ts +224 -0
- package/src/auth-server-store-conformance-records.ts +69 -0
- package/src/auth-server-store-conformance.ts +208 -0
- package/src/cache-tier-conformance-checks.ts +142 -0
- package/src/cache-tier-conformance.ts +24 -0
- package/src/cassette-format.ts +8 -13
- package/src/cassette-record.ts +1 -1
- package/src/cdp-browser.ts +10 -11
- package/src/cdp-e2e-page.ts +2 -2
- package/src/cdp-e2e-session.ts +2 -2
- package/src/cdp-network-probe.ts +1 -1
- package/src/cdp-offline-script.ts +2 -2
- package/src/clock-conformance.ts +126 -0
- package/src/conformance.ts +239 -0
- package/src/e2e-browser-handle.ts +1 -2
- package/src/e2e-error-codes.ts +17 -16
- package/src/e2e-run.ts +4 -3
- package/src/embedder-conformance.ts +101 -0
- package/src/entity-conformance-aggregates.ts +210 -0
- package/src/entity-conformance-batches.ts +216 -0
- package/src/entity-conformance-bulk.ts +379 -0
- package/src/entity-conformance-checks.ts +27 -0
- package/src/entity-conformance-entities.ts +52 -0
- package/src/entity-conformance-locks.ts +286 -0
- package/src/entity-conformance-matrix.ts +397 -0
- package/src/entity-conformance-reads.ts +241 -0
- package/src/entity-conformance-support.ts +56 -0
- package/src/entity-conformance-tenancy.ts +296 -0
- package/src/entity-conformance-values.ts +305 -0
- package/src/entity-conformance-versions.ts +60 -0
- package/src/entity-conformance-writes.ts +348 -0
- package/src/entity-driver-conformance.ts +103 -0
- package/src/error-groups-store-conformance.ts +198 -0
- package/src/error-reporter-conformance.ts +119 -0
- package/src/errors.ts +20 -2
- package/src/event-bus-conformance.ts +161 -0
- package/src/exercise-drift-hint.ts +4 -1
- package/src/exercise-judge.ts +5 -3
- package/src/exercise-override-line.ts +98 -0
- package/src/exercise-report.ts +30 -51
- package/src/exercise.ts +12 -6
- package/src/factories.ts +192 -179
- package/src/factory-api.ts +131 -0
- package/src/factory-associations.ts +67 -0
- package/src/factory-errors.ts +38 -0
- package/src/factory-lint.ts +92 -0
- package/src/factory-persist.ts +74 -16
- package/src/factory-pipeline.ts +191 -0
- package/src/factory-registry.ts +2 -1
- package/src/factory-types.ts +131 -0
- package/src/failure-store-conformance.ts +137 -0
- package/src/fixture-jobs.ts +27 -11
- package/src/fixture-mail.ts +7 -7
- package/src/fixture-seed.ts +111 -0
- package/src/fixture-statements.ts +68 -52
- package/src/framework-fixtures.ts +1 -1
- package/src/idempotency-store-conformance.ts +186 -0
- package/src/idempotency-store-replay-conformance.ts +140 -0
- package/src/idempotency-store-tx-conformance.ts +132 -0
- package/src/idempotency-store-world-conformance.ts +82 -0
- package/src/identity-provider-conformance.ts +144 -0
- package/src/image-transform-conformance.ts +89 -0
- package/src/index.ts +68 -157
- package/src/isr-store-conformance.ts +113 -0
- package/src/job-sim-effects.ts +19 -31
- package/src/job-sim-world.ts +6 -15
- package/src/lease-store-conformance.ts +195 -0
- package/src/mail-driver-conformance.ts +108 -0
- package/src/matcher-doubles.ts +104 -0
- package/src/matcher-stub.ts +78 -0
- package/src/matcher-surface.ts +21 -0
- package/src/matchers.ts +19 -1
- package/src/mcp-confirmation-store-conformance.ts +262 -0
- package/src/meter-store-conformance.ts +135 -0
- package/src/notify-digest-conformance.ts +133 -0
- package/src/notify-inbox-conformance.ts +130 -0
- package/src/notify-ledger-conformance.ts +134 -0
- package/src/notify-preference-conformance.ts +49 -0
- package/src/notify-stores-conformance.ts +73 -0
- package/src/outbox-store-conformance-claims.ts +112 -0
- package/src/outbox-store-conformance-subject.ts +65 -0
- package/src/outbox-store-conformance.ts +71 -0
- package/src/per-test-reset.ts +55 -20
- package/src/preload.ts +4 -2
- package/src/purge-conformance.ts +79 -0
- package/src/push-device-conformance.ts +124 -0
- package/src/push-subscription-conformance.ts +123 -0
- package/src/quiet-logs.ts +4 -4
- package/src/rate-limit-store-conformance.ts +178 -0
- package/src/registry-leak-error.ts +8 -1
- package/src/scrape-driver-conformance-frame-checks.ts +97 -0
- package/src/scrape-driver-conformance-page-checks.ts +114 -0
- package/src/scrape-driver-conformance-site.ts +84 -0
- package/src/scrape-driver-conformance.ts +34 -0
- package/src/search-index-conformance-list.ts +76 -0
- package/src/search-index-conformance-support.ts +69 -0
- package/src/search-index-conformance-versions.ts +66 -0
- package/src/search-index-conformance.ts +126 -0
- package/src/secret-source-conformance.ts +91 -0
- package/src/seed-factories.ts +57 -0
- package/src/seed-writer.ts +8 -19
- package/src/semantic-cache-factory-conformance.ts +86 -0
- package/src/sms-transport-conformance.ts +102 -0
- package/src/step-store-conformance.ts +171 -0
- package/src/storage-conformance-read-checks.ts +132 -0
- package/src/storage-conformance-shape.ts +121 -0
- package/src/storage-conformance-stream-checks.ts +226 -0
- package/src/storage-conformance.ts +34 -0
- package/src/stub-action.ts +24 -0
- package/src/stub-errors.ts +86 -0
- package/src/stub-job.ts +30 -0
- package/src/stub-query.ts +25 -0
- package/src/stub-script.ts +76 -0
- package/src/stub-stack.ts +29 -0
- package/src/stub.ts +73 -0
- package/src/swap-adapter.ts +135 -0
- package/src/test-scope.ts +96 -0
- package/src/test-types.ts +1 -1
- package/src/totp-replay-guard-conformance.ts +76 -0
- package/src/transport-conformance.ts +179 -0
- package/src/upload-scanner-conformance.ts +112 -0
- package/src/vector-store-conformance-checks.ts +174 -0
- package/src/vector-store-conformance.ts +21 -0
- package/src/cdp-connection.ts +0 -291
- package/src/cdp-errors.ts +0 -179
- package/src/cdp-launch-attempt.ts +0 -224
- package/src/cdp-launch-candidates.ts +0 -62
- package/src/cdp-launch-profile.ts +0 -106
- package/src/cdp-launch-reap.ts +0 -68
- package/src/cdp-launch-wire.ts +0 -171
- package/src/cdp-launch.ts +0 -175
- package/src/cdp-pipe.ts +0 -77
- package/src/cdp-wire-watch.ts +0 -113
package/src/job-sim-effects.ts
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
// The effect log a simulated run is judged by: row writes
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
1
|
+
// The effect log a simulated run is judged by: row writes, mail, calls out and enqueues, each
|
|
2
|
+
// attributed to the worker whose body made it — reads and process reports are not effects, and one
|
|
3
|
+
// made after its worker died is dropped. Every borrowed seam is chained onto what was installed and
|
|
4
|
+
// handed back; the rows are a bus subscription (`entity.row`/`entity.bulk`), released at dispose.
|
|
5
5
|
|
|
6
6
|
import type { AsyncContext } from '@ultimat3/core';
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
configureErrorReporting,
|
|
10
|
-
installedErrorReporter,
|
|
11
|
-
noopErrorReporter,
|
|
12
|
-
} from '@ultimat3/core';
|
|
13
|
-
import type { RowObserver } from '@ultimat3/entity';
|
|
7
|
+
import { asyncContext, noopErrorReporter, subscribe } from '@ultimat3/core';
|
|
8
|
+
import { installErrorReporter } from '@ultimat3/core/adapter';
|
|
14
9
|
import type { MailDriver } from '@ultimat3/mail';
|
|
15
10
|
|
|
16
11
|
export interface SimEffect {
|
|
@@ -53,9 +48,9 @@ const methodOf = (input: RequestInfo | URL, init: RequestInit | undefined): stri
|
|
|
53
48
|
).toUpperCase();
|
|
54
49
|
|
|
55
50
|
export async function openEffectLog(options: EffectLogOptions): Promise<EffectLog> {
|
|
56
|
-
const { setRowObserver } = await import('@ultimat3/entity');
|
|
57
51
|
const { currentStep } = await import('@ultimat3/jobs');
|
|
58
52
|
const mail = await import('@ultimat3/mail');
|
|
53
|
+
const mailAdapter = await import('@ultimat3/mail/adapter');
|
|
59
54
|
const scope = asyncContext<string>('the job simulation');
|
|
60
55
|
const log: SimEffect[] = [];
|
|
61
56
|
const lastStep = new Map<string, string>();
|
|
@@ -73,18 +68,12 @@ export async function openEffectLog(options: EffectLogOptions): Promise<EffectLo
|
|
|
73
68
|
});
|
|
74
69
|
};
|
|
75
70
|
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
onBulk: (change) => {
|
|
83
|
-
for (let i = 0; i < change.rows; i += 1) record(`row:${change.entity}:${change.op}`);
|
|
84
|
-
previousRows?.onBulk?.(change);
|
|
85
|
-
},
|
|
86
|
-
};
|
|
87
|
-
setRowObserver(rows);
|
|
71
|
+
const offRows = subscribe('entity', (event) => {
|
|
72
|
+
if (event.name === 'entity.row') record(`row:${event.payload.entity}:${event.payload.op}`);
|
|
73
|
+
if (event.name !== 'entity.bulk') return;
|
|
74
|
+
const { entity, op } = event.payload;
|
|
75
|
+
for (let i = 0; i < event.payload.rows; i += 1) record(`row:${entity}:${op}`);
|
|
76
|
+
});
|
|
88
77
|
|
|
89
78
|
// A send with no mail driver installed is answered by an in-memory one: the effect is the send.
|
|
90
79
|
const previousMail = mail.tryMailDriver();
|
|
@@ -97,14 +86,14 @@ export async function openEffectLog(options: EffectLogOptions): Promise<EffectLo
|
|
|
97
86
|
return sent;
|
|
98
87
|
},
|
|
99
88
|
};
|
|
100
|
-
|
|
89
|
+
const releaseMail = mailAdapter.installMailDriver(recording);
|
|
101
90
|
|
|
102
91
|
// Set aside, never chained: a report is the process telling its operator, not the body acting.
|
|
103
92
|
// An app's sink keeps state across runs (`errorGroupsSink` enqueues on a group's FIRST sighting),
|
|
104
93
|
// so chained, whichever simulated run reported first would carry its enqueue and every other
|
|
105
94
|
// run's count would differ — and a death planted here would land in the app's own error store.
|
|
106
|
-
|
|
107
|
-
|
|
95
|
+
// A frame above whatever is installed: its release restores exactly that, in any stop order.
|
|
96
|
+
const releaseReporter = installErrorReporter(noopErrorReporter);
|
|
108
97
|
|
|
109
98
|
// Recorded on the way out, then handed to whatever `fetch` is installed — the seal decides.
|
|
110
99
|
const previousFetch = globalThis.fetch;
|
|
@@ -130,10 +119,9 @@ export async function openEffectLog(options: EffectLogOptions): Promise<EffectLo
|
|
|
130
119
|
try {
|
|
131
120
|
globalThis.fetch = previousFetch;
|
|
132
121
|
} finally {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
setRowObserver(previousRows);
|
|
122
|
+
releaseReporter();
|
|
123
|
+
releaseMail();
|
|
124
|
+
offRows();
|
|
137
125
|
}
|
|
138
126
|
},
|
|
139
127
|
};
|
package/src/job-sim-world.ts
CHANGED
|
@@ -5,14 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import type { Ctx } from '@ultimat3/core';
|
|
7
7
|
import { ctxOf } from '@ultimat3/core';
|
|
8
|
-
import type {
|
|
9
|
-
EnqueueResult,
|
|
10
|
-
EventBus,
|
|
11
|
-
JobDriver,
|
|
12
|
-
JobExecution,
|
|
13
|
-
JobHandle,
|
|
14
|
-
JobRecord,
|
|
15
|
-
} from '@ultimat3/jobs';
|
|
8
|
+
import type { EnqueueResult, JobDriver, JobExecution, JobHandle, JobRecord } from '@ultimat3/jobs';
|
|
16
9
|
import {
|
|
17
10
|
captureDeterminism,
|
|
18
11
|
installDeterminism,
|
|
@@ -67,6 +60,7 @@ export interface SimWorld extends AsyncDisposable {
|
|
|
67
60
|
|
|
68
61
|
export async function openSimWorld(options: SimWorldOptions): Promise<SimWorld> {
|
|
69
62
|
const jobs = await import('@ultimat3/jobs');
|
|
63
|
+
const adapter = await import('@ultimat3/jobs/adapter');
|
|
70
64
|
const clock = captureDeterminism();
|
|
71
65
|
if (!clock.installed) installDeterminism();
|
|
72
66
|
Math.random = seededRandom(options.seed);
|
|
@@ -114,10 +108,8 @@ export async function openSimWorld(options: SimWorldOptions): Promise<SimWorld>
|
|
|
114
108
|
const ambientDriver: JobDriver = new Proxy(base, {
|
|
115
109
|
get: (_target, key) => Reflect.get(ambient(), key),
|
|
116
110
|
});
|
|
117
|
-
const
|
|
118
|
-
jobs.
|
|
119
|
-
const previousBus: EventBus = jobs.eventBus();
|
|
120
|
-
jobs.setEventBus(jobs.memoryEventBus());
|
|
111
|
+
const releaseDriver = adapter.installJobDriver(ambientDriver);
|
|
112
|
+
const releaseBus = adapter.installEventBus(jobs.memoryEventBus());
|
|
121
113
|
const renewals = frozenScheduler();
|
|
122
114
|
const anonymous = ctxOf({ role: 'worker' });
|
|
123
115
|
const context = options.context ?? (() => anonymous);
|
|
@@ -201,9 +193,8 @@ export async function openSimWorld(options: SimWorldOptions): Promise<SimWorld>
|
|
|
201
193
|
await effectLog[Symbol.asyncDispose]();
|
|
202
194
|
} finally {
|
|
203
195
|
renewals[Symbol.dispose]();
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
else jobs.setJobDriver(previousDriver);
|
|
196
|
+
releaseBus();
|
|
197
|
+
releaseDriver();
|
|
207
198
|
await base.close();
|
|
208
199
|
restoreCapturedDeterminism(clock);
|
|
209
200
|
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
// The `LeaseStore` contract of `@ultimat3/jobs` as shared examples: `behavesLike(
|
|
2
|
+
// leaseStoreConformance, () => ({ store, elapse }))`. Fleet-wide `job.concurrency` is only as true
|
|
3
|
+
// as this: never over-grant under a race, never revive a lapsed slot, never free another's. Time
|
|
4
|
+
// passes through `elapse` (a frozen clock advances, a database ages its rows), never the wall clock.
|
|
5
|
+
|
|
6
|
+
import { expect, test } from 'bun:test';
|
|
7
|
+
import type { HeldLease, LeaseStore } from '@ultimat3/jobs';
|
|
8
|
+
import type { SharedExamples } from './shared-examples';
|
|
9
|
+
import { sharedExamples } from './shared-examples';
|
|
10
|
+
|
|
11
|
+
/** The store under test, and how to let `ms` pass on the clock its expiry reads. */
|
|
12
|
+
export interface LeaseStoreSubject {
|
|
13
|
+
readonly store: LeaseStore;
|
|
14
|
+
/** Let `ms` pass for every slot: `clock.advance`, or `expires_at` moved back by `ms`. */
|
|
15
|
+
readonly elapse: (ms: number) => void | Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface LeaseStoreCheck {
|
|
19
|
+
readonly name: string;
|
|
20
|
+
run(subject: LeaseStoreSubject): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Outlives every round trip a check makes before its `elapse`, however loaded the runner. */
|
|
24
|
+
const SHORT_TTL_MS = 5_000;
|
|
25
|
+
const PAST_SHORT_TTL_MS = 10_000;
|
|
26
|
+
const LONG_TTL_MS = 60_000;
|
|
27
|
+
/** Concurrent acquirers, and the cap only some of them fit under. */
|
|
28
|
+
const RACERS = 12;
|
|
29
|
+
const RACE_LIMIT = 3;
|
|
30
|
+
|
|
31
|
+
let minted = 0;
|
|
32
|
+
/** A key of this check's own, so checks sharing one store never count each other's slots. */
|
|
33
|
+
const keyOf = (): string => {
|
|
34
|
+
minted += 1;
|
|
35
|
+
return `job:conformance-${process.pid.toString(36)}-${minted.toString(36)}`;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const elapse = async (subject: LeaseStoreSubject, ms: number): Promise<void> => {
|
|
39
|
+
await subject.elapse(ms);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const granted = (lease: HeldLease | undefined, what: string): HeldLease =>
|
|
43
|
+
lease ?? expect.unreachable(`${what}: the store refused a slot that was free`);
|
|
44
|
+
|
|
45
|
+
export const LEASE_STORE_CHECKS: readonly LeaseStoreCheck[] = [
|
|
46
|
+
{
|
|
47
|
+
name: 'slots are granted up to the limit, one each, and no further',
|
|
48
|
+
async run(subject) {
|
|
49
|
+
const { store } = subject;
|
|
50
|
+
const key = keyOf();
|
|
51
|
+
const a = granted(await store.acquire(key, 2, LONG_TTL_MS, 'a'), 'first');
|
|
52
|
+
const b = granted(await store.acquire(key, 2, LONG_TTL_MS, 'b'), 'second');
|
|
53
|
+
expect(a.slot).not.toBe(b.slot);
|
|
54
|
+
expect([a.key, a.holder, b.holder]).toEqual([key, 'a', 'b']);
|
|
55
|
+
expect(await store.acquire(key, 2, LONG_TTL_MS, 'c')).toBeUndefined();
|
|
56
|
+
expect(await store.held(key)).toBe(2);
|
|
57
|
+
expect(await store.acquire(key, 0, LONG_TTL_MS, 'd')).toBeUndefined();
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: `${RACERS} concurrent acquires never grant more than the limit`,
|
|
62
|
+
async run(subject) {
|
|
63
|
+
const { store } = subject;
|
|
64
|
+
const key = keyOf();
|
|
65
|
+
const leases = await Promise.all(
|
|
66
|
+
Array.from({ length: RACERS }, (_, n) =>
|
|
67
|
+
store.acquire(key, RACE_LIMIT, LONG_TTL_MS, `r${n}`),
|
|
68
|
+
),
|
|
69
|
+
);
|
|
70
|
+
const slots = leases.flatMap((lease) => (lease === undefined ? [] : [lease.slot]));
|
|
71
|
+
// A refusal under contention is allowed (one poll interval); an over-grant never is.
|
|
72
|
+
expect(slots.length).toBeGreaterThan(0);
|
|
73
|
+
expect(slots.length).toBeLessThanOrEqual(RACE_LIMIT);
|
|
74
|
+
expect(new Set(slots).size).toBe(slots.length);
|
|
75
|
+
expect(await store.held(key)).toBe(slots.length);
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: 'keys are independent: a full key leaves another free',
|
|
80
|
+
async run(subject) {
|
|
81
|
+
const { store } = subject;
|
|
82
|
+
const [full, other] = [keyOf(), keyOf()];
|
|
83
|
+
granted(await store.acquire(full, 1, LONG_TTL_MS, 'a'), 'full');
|
|
84
|
+
granted(await store.acquire(other, 1, LONG_TTL_MS, 'b'), 'other');
|
|
85
|
+
expect([await store.held(full), await store.held(other)]).toEqual([1, 1]);
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: 'renew lands for the holder inside the TTL and never for another holder',
|
|
90
|
+
async run(subject) {
|
|
91
|
+
const { store } = subject;
|
|
92
|
+
const key = keyOf();
|
|
93
|
+
const lease = granted(await store.acquire(key, 1, SHORT_TTL_MS, 'a'), 'renewed');
|
|
94
|
+
expect(await store.renew({ ...lease, holder: 'b' }, LONG_TTL_MS)).toBe(false);
|
|
95
|
+
expect(await store.renew(lease, LONG_TTL_MS)).toBe(true);
|
|
96
|
+
// Renewed past the short TTL it started with: still held once that has run out.
|
|
97
|
+
await elapse(subject, PAST_SHORT_TTL_MS);
|
|
98
|
+
expect(await store.held(key)).toBe(1);
|
|
99
|
+
expect(await store.acquire(key, 1, LONG_TTL_MS, 'b')).toBeUndefined();
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
// `worker-fleet-slots.ts` reads `false` as `X_JOB_SLOT_LOST`: a store that revives the slot
|
|
104
|
+
// keeps a run alive past a TTL every other worker has already seen expire.
|
|
105
|
+
name: 'a lapsed slot is lost, not renewed — even with nobody else holding it',
|
|
106
|
+
async run(subject) {
|
|
107
|
+
const { store } = subject;
|
|
108
|
+
const key = keyOf();
|
|
109
|
+
const lease = granted(await store.acquire(key, 1, SHORT_TTL_MS, 'a'), 'lapsing');
|
|
110
|
+
await elapse(subject, PAST_SHORT_TTL_MS);
|
|
111
|
+
expect(await store.held(key)).toBe(0);
|
|
112
|
+
expect(await store.renew(lease, LONG_TTL_MS)).toBe(false);
|
|
113
|
+
expect(await store.held(key)).toBe(0);
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: 'an expired slot is granted again, and its old holder cannot renew it back',
|
|
118
|
+
async run(subject) {
|
|
119
|
+
const { store } = subject;
|
|
120
|
+
const key = keyOf();
|
|
121
|
+
const dead = granted(await store.acquire(key, 1, SHORT_TTL_MS, 'dead'), 'dead');
|
|
122
|
+
expect(await store.acquire(key, 1, LONG_TTL_MS, 'live')).toBeUndefined();
|
|
123
|
+
await elapse(subject, PAST_SHORT_TTL_MS);
|
|
124
|
+
granted(await store.acquire(key, 1, LONG_TTL_MS, 'live'), 'reclaimed');
|
|
125
|
+
expect(await store.renew(dead, LONG_TTL_MS)).toBe(false);
|
|
126
|
+
expect(await store.holders(key)).toEqual(['live']);
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: 'release by a non-holder is a no-op; release by the holder frees the slot',
|
|
131
|
+
async run(subject) {
|
|
132
|
+
const { store } = subject;
|
|
133
|
+
const key = keyOf();
|
|
134
|
+
const lease = granted(await store.acquire(key, 1, LONG_TTL_MS, 'a'), 'released');
|
|
135
|
+
await store.release({ ...lease, holder: 'b' });
|
|
136
|
+
expect(await store.held(key)).toBe(1);
|
|
137
|
+
await store.release(lease);
|
|
138
|
+
expect(await store.held(key)).toBe(0);
|
|
139
|
+
granted(await store.acquire(key, 1, LONG_TTL_MS, 'b'), 'after release');
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
// `withLock`'s token: a write fenced on it refuses a smaller one, so a later holder must
|
|
144
|
+
// never show an earlier holder's number — not after a release, not after a takeover.
|
|
145
|
+
name: 'every grant carries a fence greater than every earlier one, takeovers included',
|
|
146
|
+
async run(subject) {
|
|
147
|
+
const { store } = subject;
|
|
148
|
+
const key = keyOf();
|
|
149
|
+
const fences: number[] = [];
|
|
150
|
+
const fenceOf = (lease: HeldLease | undefined, what: string): number => {
|
|
151
|
+
const { fence } = granted(lease, what);
|
|
152
|
+
if (typeof fence !== 'number' || !Number.isSafeInteger(fence)) {
|
|
153
|
+
return expect.unreachable(`${what}: the grant carries no whole-number fence`);
|
|
154
|
+
}
|
|
155
|
+
fences.push(fence);
|
|
156
|
+
return fence;
|
|
157
|
+
};
|
|
158
|
+
fenceOf(await store.acquire(key, 2, LONG_TTL_MS, 'a'), 'slot 0');
|
|
159
|
+
const second = granted(await store.acquire(key, 2, SHORT_TTL_MS, 'b'), 'slot 1');
|
|
160
|
+
fenceOf(second, 'slot 1');
|
|
161
|
+
// The same slot, released and granted again.
|
|
162
|
+
await store.release(second);
|
|
163
|
+
fenceOf(await store.acquire(key, 2, SHORT_TTL_MS, 'c'), 'slot 1 again');
|
|
164
|
+
// The same slot, lapsed and TAKEN OVER without a release.
|
|
165
|
+
await elapse(subject, PAST_SHORT_TTL_MS);
|
|
166
|
+
fenceOf(await store.acquire(key, 2, LONG_TTL_MS, 'd'), 'slot 1 taken over');
|
|
167
|
+
for (const [index, fence] of fences.entries()) {
|
|
168
|
+
if (index > 0) expect(fence).toBeGreaterThan(fences[index - 1] ?? Number.NaN);
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
name: 'holders names the live slots of one key in slot order, and nothing expired',
|
|
174
|
+
async run(subject) {
|
|
175
|
+
const { store } = subject;
|
|
176
|
+
const key = keyOf();
|
|
177
|
+
expect(await store.holders(key)).toEqual([]);
|
|
178
|
+
granted(await store.acquire(key, 3, LONG_TTL_MS, 'first'), 'slot 0');
|
|
179
|
+
granted(await store.acquire(key, 3, SHORT_TTL_MS, 'second'), 'slot 1');
|
|
180
|
+
granted(await store.acquire(key, 3, LONG_TTL_MS, 'third'), 'slot 2');
|
|
181
|
+
expect(await store.holders(key)).toEqual(['first', 'second', 'third']);
|
|
182
|
+
await elapse(subject, PAST_SHORT_TTL_MS);
|
|
183
|
+
expect(await store.holders(key)).toEqual(['first', 'third']);
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
];
|
|
187
|
+
|
|
188
|
+
export const leaseStoreConformance: SharedExamples<LeaseStoreSubject | Promise<LeaseStoreSubject>> =
|
|
189
|
+
sharedExamples('a lease store', (subject) => {
|
|
190
|
+
for (const check of LEASE_STORE_CHECKS) {
|
|
191
|
+
test(check.name, async () => {
|
|
192
|
+
await check.run(await subject());
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
});
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// The `MailDriver` contract of `@ultimat3/mail` as shared examples, for a transport of your own:
|
|
2
|
+
// `behavesLike(mailDriverConformance, () => driver)`. Asked through `send` alone — what a driver
|
|
3
|
+
// answers about a message, never how its wire looks — so a hand-written driver proves itself with
|
|
4
|
+
// one line. The subject is called once per test; a driver with no state may be handed back as is.
|
|
5
|
+
|
|
6
|
+
import { expect, test } from 'bun:test';
|
|
7
|
+
import { mailIdempotencyKey } from '@ultimat3/mail';
|
|
8
|
+
import type { MailDriver, MailMessage } from '@ultimat3/mail/adapter';
|
|
9
|
+
import type { SharedExamples } from './shared-examples';
|
|
10
|
+
import { sharedExamples } from './shared-examples';
|
|
11
|
+
|
|
12
|
+
export interface MailDriverCheck {
|
|
13
|
+
readonly name: string;
|
|
14
|
+
run(driver: MailDriver): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const TO = 'ada@example.test';
|
|
18
|
+
const CC = 'grace@example.test';
|
|
19
|
+
const BCC = 'ops@example.test';
|
|
20
|
+
const CONCURRENT_SENDS = 8;
|
|
21
|
+
|
|
22
|
+
/** A rendered envelope, by hand: the port receives one already built, whatever built it. */
|
|
23
|
+
export const conformanceMail = (overrides: Partial<MailMessage> = {}): MailMessage => ({
|
|
24
|
+
mailId: 'conformance-basic',
|
|
25
|
+
to: [TO],
|
|
26
|
+
subject: 'Hi Ada',
|
|
27
|
+
html: '<p>Your invite is waiting.</p>',
|
|
28
|
+
text: 'Your invite is waiting.',
|
|
29
|
+
locale: 'en',
|
|
30
|
+
tz: 'UTC',
|
|
31
|
+
...overrides,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const sorted = (values: readonly string[]): readonly string[] => [...values].sort();
|
|
35
|
+
|
|
36
|
+
export const MAIL_DRIVER_CHECKS: readonly MailDriverCheck[] = [
|
|
37
|
+
{
|
|
38
|
+
name: 'a send resolves a result naming this driver, delivered rather than queued',
|
|
39
|
+
async run(driver) {
|
|
40
|
+
expect(driver.name.length).toBeGreaterThan(0);
|
|
41
|
+
const result = await driver.send(conformanceMail());
|
|
42
|
+
expect([result.driver, result.queued]).toEqual([driver.name, false]);
|
|
43
|
+
expect(typeof result.id === 'string' && result.id.length > 0).toBe(true);
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
// Bcc is a recipient and never a header: a driver that reports only `to` lost the blind list.
|
|
48
|
+
name: 'accepted is every envelope recipient: to, cc and bcc',
|
|
49
|
+
async run(driver) {
|
|
50
|
+
const result = await driver.send(conformanceMail({ cc: [CC], bcc: [BCC] }));
|
|
51
|
+
expect(sorted(result.accepted)).toEqual(sorted([TO, CC, BCC]));
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
// A caller deduping its own retries reads this key; minted per attempt, it dedupes nothing.
|
|
56
|
+
name: 'the idempotency key is the content key, the same on every attempt',
|
|
57
|
+
async run(driver) {
|
|
58
|
+
const message = conformanceMail();
|
|
59
|
+
const first = await driver.send(message);
|
|
60
|
+
const second = await driver.send(message);
|
|
61
|
+
expect([first.idempotencyKey, second.idempotencyKey]).toEqual([
|
|
62
|
+
mailIdempotencyKey(message),
|
|
63
|
+
mailIdempotencyKey(message),
|
|
64
|
+
]);
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: 'a different recipient is a different idempotency key',
|
|
69
|
+
async run(driver) {
|
|
70
|
+
const ada = await driver.send(conformanceMail());
|
|
71
|
+
const ben = await driver.send(conformanceMail({ to: ['ben@example.test'] }));
|
|
72
|
+
expect(ben.idempotencyKey).not.toBe(ada.idempotencyKey);
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
// The id lands in logs and mail headers every recipient reads; the key holds the recipients.
|
|
77
|
+
name: 'the result id carries no recipient address and never the idempotency key',
|
|
78
|
+
async run(driver) {
|
|
79
|
+
const message = conformanceMail({ bcc: [BCC] });
|
|
80
|
+
const result = await driver.send(message);
|
|
81
|
+
for (const leak of [TO, BCC, mailIdempotencyKey(message)]) {
|
|
82
|
+
expect(result.id).not.toContain(leak);
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: `${CONCURRENT_SENDS} concurrent sends each answer for their own message`,
|
|
88
|
+
async run(driver) {
|
|
89
|
+
const messages = Array.from({ length: CONCURRENT_SENDS }, (_, index) =>
|
|
90
|
+
conformanceMail({ to: [`reader-${index.toString()}@example.test`] }),
|
|
91
|
+
);
|
|
92
|
+
const results = await Promise.all(messages.map((message) => driver.send(message)));
|
|
93
|
+
expect(results.map((result) => result.accepted)).toEqual(messages.map((m) => m.to));
|
|
94
|
+
expect(results.map((result) => result.idempotencyKey)).toEqual(
|
|
95
|
+
messages.map(mailIdempotencyKey),
|
|
96
|
+
);
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
];
|
|
100
|
+
|
|
101
|
+
export const mailDriverConformance: SharedExamples<MailDriver | Promise<MailDriver>> =
|
|
102
|
+
sharedExamples('a mail driver', (subject) => {
|
|
103
|
+
for (const check of MAIL_DRIVER_CHECKS) {
|
|
104
|
+
test(check.name, async () => {
|
|
105
|
+
await check.run(await subject());
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
});
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// Single responsibility: the two assertions on what a test's fixtures CAUGHT — a job on the
|
|
2
|
+
// `runJobs` queue (`toHaveEnqueued`) and a mail in the `mail` outbox (`toHaveSentMail`). Each reads
|
|
3
|
+
// the fixture it is handed and refuses any other receiver by code, synchronously: under `.not` a
|
|
4
|
+
// `pass: false` for a wrong receiver would read as a pass.
|
|
5
|
+
|
|
6
|
+
import { renderCauseValue } from '@ultimat3/core';
|
|
7
|
+
import type { JobRecord } from '@ultimat3/jobs';
|
|
8
|
+
import type { MatcherResult } from './matcher-result';
|
|
9
|
+
import type { EnqueuedJobRef, MatcherMailRef, SentMailMatch } from './matcher-surface';
|
|
10
|
+
import {
|
|
11
|
+
TestExpectedInputInvalidError,
|
|
12
|
+
TestMailExpectedError,
|
|
13
|
+
TestRunJobsExpectedError,
|
|
14
|
+
} from './stub-errors';
|
|
15
|
+
|
|
16
|
+
/** The `mail` fixture's reading half — all `toHaveSentMail` needs. */
|
|
17
|
+
interface OutboxLike {
|
|
18
|
+
outbox(): readonly {
|
|
19
|
+
readonly message: { readonly mailId: string; readonly to: readonly string[] };
|
|
20
|
+
}[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** The `runJobs` fixture's reading half — all `toHaveEnqueued` needs. */
|
|
24
|
+
interface QueueLike {
|
|
25
|
+
enqueued(handle: EnqueuedJobRef<unknown>): Promise<readonly JobRecord[]>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
29
|
+
(typeof value === 'object' || typeof value === 'function') && value !== null;
|
|
30
|
+
|
|
31
|
+
type Parsed =
|
|
32
|
+
| { readonly ok: true; readonly value: unknown }
|
|
33
|
+
| { readonly ok: false; readonly issue: unknown };
|
|
34
|
+
|
|
35
|
+
/** `raw` as `handle`'s body would receive it, or what its schema said instead. */
|
|
36
|
+
function parseJobInput(handle: EnqueuedJobRef<unknown>, raw: unknown): Parsed {
|
|
37
|
+
try {
|
|
38
|
+
return { ok: true, value: handle.parse(raw) };
|
|
39
|
+
} catch (error) {
|
|
40
|
+
return { ok: false, issue: error instanceof Error ? error.message : error };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* `await expect(runJobs).toHaveEnqueued(sendWelcome, { userId })` — a row for that job, in any
|
|
46
|
+
* state, whose input equals `input` once both are parsed by the job's own schema. No `input`: any
|
|
47
|
+
* row for the job.
|
|
48
|
+
*/
|
|
49
|
+
export function toHaveEnqueued(
|
|
50
|
+
received: unknown,
|
|
51
|
+
handle: EnqueuedJobRef<unknown>,
|
|
52
|
+
...rest: readonly unknown[]
|
|
53
|
+
): Promise<MatcherResult> {
|
|
54
|
+
if (!isRecord(received) || typeof received['enqueued'] !== 'function') {
|
|
55
|
+
throw new TestRunJobsExpectedError(received);
|
|
56
|
+
}
|
|
57
|
+
const queue = received as unknown as QueueLike;
|
|
58
|
+
const expected = rest.length === 0 ? undefined : parseJobInput(handle, rest[0]);
|
|
59
|
+
if (expected?.ok === false) {
|
|
60
|
+
throw new TestExpectedInputInvalidError('toHaveEnqueued', handle.name, expected.issue);
|
|
61
|
+
}
|
|
62
|
+
return queue.enqueued(handle).then((rows) => {
|
|
63
|
+
const inputs = rows.map((row) => {
|
|
64
|
+
const stored = parseJobInput(handle, row.input);
|
|
65
|
+
return stored.ok ? stored.value : row.input;
|
|
66
|
+
});
|
|
67
|
+
const pass =
|
|
68
|
+
expected === undefined
|
|
69
|
+
? rows.length > 0
|
|
70
|
+
: inputs.some((input) => Bun.deepEquals(input, expected.value));
|
|
71
|
+
const what = expected === undefined ? '' : ` with ${renderCauseValue(expected.value)}`;
|
|
72
|
+
return {
|
|
73
|
+
pass,
|
|
74
|
+
message: () =>
|
|
75
|
+
pass
|
|
76
|
+
? `expected "${handle.name}" not to have been enqueued${what}`
|
|
77
|
+
: `expected "${handle.name}" to have been enqueued${what}; the queue holds ${String(rows.length)}: ${renderCauseValue(inputs)}`,
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** `expect(mail).toHaveSentMail(welcomeMail, { to })` — that mail, to that address when named. */
|
|
83
|
+
export function toHaveSentMail(
|
|
84
|
+
received: unknown,
|
|
85
|
+
mail: MatcherMailRef,
|
|
86
|
+
match: SentMailMatch = {},
|
|
87
|
+
): MatcherResult {
|
|
88
|
+
if (!isRecord(received) || typeof received['outbox'] !== 'function') {
|
|
89
|
+
throw new TestMailExpectedError(received);
|
|
90
|
+
}
|
|
91
|
+
const id = typeof mail === 'string' ? mail : mail.id;
|
|
92
|
+
const sent = (received as unknown as OutboxLike).outbox().map((entry) => entry.message);
|
|
93
|
+
const pass = sent.some(
|
|
94
|
+
(message) => message.mailId === id && (match.to === undefined || message.to.includes(match.to)),
|
|
95
|
+
);
|
|
96
|
+
const to = match.to === undefined ? '' : ` to ${match.to}`;
|
|
97
|
+
return {
|
|
98
|
+
pass,
|
|
99
|
+
message: () =>
|
|
100
|
+
pass
|
|
101
|
+
? `expected "${id}" not to have been sent${to}`
|
|
102
|
+
: `expected "${id}" to have been sent${to}; the outbox holds ${renderCauseValue(sent.map((message) => ({ mailId: message.mailId, to: message.to })))}`,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// Single responsibility: `expect(stubbed).toHaveBeenCalledWith(input)` on a `stub()` — the expected
|
|
2
|
+
// input parsed by the primitive's own input schema first, so an assertion no call could ever have
|
|
3
|
+
// matched is a coded refusal, not a red that reads like a missing call. Every other receiver (a
|
|
4
|
+
// `mock()`, a `spyOn`) is handed to bun's own matcher unchanged: one name, one meaning.
|
|
5
|
+
|
|
6
|
+
import { expect } from 'bun:test';
|
|
7
|
+
import { renderCauseValue } from '@ultimat3/core';
|
|
8
|
+
import type { MatcherResult } from './matcher-result';
|
|
9
|
+
import { TestExpectedInputInvalidError } from './stub-errors';
|
|
10
|
+
import type { Stub } from './stub-script';
|
|
11
|
+
import { stubInputSchema } from './stub-script';
|
|
12
|
+
|
|
13
|
+
type Builtin = (this: unknown, ...expected: unknown[]) => void;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Bun's own, captured before this module replaces it. Kept on `globalThis` under a registered
|
|
17
|
+
* symbol: a second copy of this module (source and `dist/` in one process) would otherwise capture
|
|
18
|
+
* the FIRST copy's replacement as "the original" and recurse.
|
|
19
|
+
*/
|
|
20
|
+
const ORIGINAL = Symbol.for('ultimate.testing.toHaveBeenCalledWith');
|
|
21
|
+
const slots = globalThis as unknown as Record<symbol, Builtin | undefined>;
|
|
22
|
+
slots[ORIGINAL] ??= (
|
|
23
|
+
Object.getPrototypeOf(expect(0)) as { toHaveBeenCalledWith: Builtin }
|
|
24
|
+
).toHaveBeenCalledWith;
|
|
25
|
+
const builtin = slots[ORIGINAL] as Builtin;
|
|
26
|
+
|
|
27
|
+
interface MatcherContext {
|
|
28
|
+
readonly isNot: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** The expected input as the stubbed body would have received it — or a coded refusal. */
|
|
32
|
+
function parsed(stub: Stub<unknown, unknown>, raw: unknown): unknown {
|
|
33
|
+
const schema = stubInputSchema(stub);
|
|
34
|
+
if (schema === undefined) return raw;
|
|
35
|
+
const result = schema['~standard'].validate(raw);
|
|
36
|
+
if (result instanceof Promise) {
|
|
37
|
+
throw new TestExpectedInputInvalidError('toHaveBeenCalledWith', stub.name, [
|
|
38
|
+
'an async input schema cannot be checked inside a synchronous matcher',
|
|
39
|
+
]);
|
|
40
|
+
}
|
|
41
|
+
if (result.issues !== undefined) {
|
|
42
|
+
throw new TestExpectedInputInvalidError('toHaveBeenCalledWith', stub.name, result.issues);
|
|
43
|
+
}
|
|
44
|
+
return result.value;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Bun's verdict on a receiver that is not a stub, as a matcher result rather than a throw. */
|
|
48
|
+
function delegated(context: MatcherContext, received: unknown, args: unknown[]): MatcherResult {
|
|
49
|
+
try {
|
|
50
|
+
builtin.apply(context.isNot ? expect(received).not : expect(received), args);
|
|
51
|
+
return { pass: !context.isNot, message: () => 'bun toHaveBeenCalledWith' };
|
|
52
|
+
} catch (error) {
|
|
53
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
54
|
+
return { pass: context.isNot, message: () => message };
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const isStub = (value: unknown): value is Stub<unknown, unknown> =>
|
|
59
|
+
stubInputSchema(value) !== undefined;
|
|
60
|
+
|
|
61
|
+
expect.extend({
|
|
62
|
+
toHaveBeenCalledWith(received: unknown, ...args: unknown[]): MatcherResult {
|
|
63
|
+
const context = this as unknown as MatcherContext;
|
|
64
|
+
if (!isStub(received)) return delegated(context, received, args);
|
|
65
|
+
const expected = parsed(received, args[0]);
|
|
66
|
+
const inputs = received.calls.map((call) => call.input);
|
|
67
|
+
return {
|
|
68
|
+
pass: inputs.some((input) => Bun.deepEquals(input, expected)),
|
|
69
|
+
message: () =>
|
|
70
|
+
context.isNot
|
|
71
|
+
? `expected "${received.name}" not to have been called with ${renderCauseValue(expected)}`
|
|
72
|
+
: `expected "${received.name}" to have been called with ${renderCauseValue(expected)}; its ${String(inputs.length)} call(s): ${renderCauseValue(inputs)}`,
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
/** Imported for its side effect by `matchers.ts`. */
|
|
78
|
+
export const stubMatcherInstalled = true;
|
package/src/matcher-surface.ts
CHANGED
|
@@ -6,6 +6,20 @@
|
|
|
6
6
|
import type { VisibleOptions } from './matcher-visible';
|
|
7
7
|
import type { OpenApiLike } from './test-types';
|
|
8
8
|
|
|
9
|
+
/** A `defineMail()` handle, or its id. Structural, so this file imports no package. */
|
|
10
|
+
export type MatcherMailRef = string | { readonly id: string };
|
|
11
|
+
|
|
12
|
+
/** Who a mail must have gone to, beside which mail it was. */
|
|
13
|
+
export interface SentMailMatch {
|
|
14
|
+
readonly to?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** The two members of a job handle `toHaveEnqueued` reads; `I` types the expected input. */
|
|
18
|
+
export interface EnqueuedJobRef<I> {
|
|
19
|
+
readonly name: string;
|
|
20
|
+
parse(raw: unknown): I;
|
|
21
|
+
}
|
|
22
|
+
|
|
9
23
|
/**
|
|
10
24
|
* One entry per `expect.extend` implementation in `matchers.ts`, and `T` is what the matcher
|
|
11
25
|
* answers with. Adding a matcher is one edit here: `matchers.ts` will not compile until it has an
|
|
@@ -38,6 +52,13 @@ export interface UltimateMatchers<T> {
|
|
|
38
52
|
* assertion: it fails on a page that simply has not painted yet.
|
|
39
53
|
*/
|
|
40
54
|
toBeVisible(options?: VisibleOptions): Promise<T>;
|
|
55
|
+
/**
|
|
56
|
+
* On the `runJobs` fixture: a row for `job`, in any state, whose input equals `input` once both
|
|
57
|
+
* are parsed by the job's schema (an input it refuses is `X_TEST_EXPECTED_INPUT_INVALID`).
|
|
58
|
+
*/
|
|
59
|
+
toHaveEnqueued<I>(job: EnqueuedJobRef<I>, input?: I): Promise<T>;
|
|
60
|
+
/** On the `mail` fixture: that mail was sent — to `to`, when named. */
|
|
61
|
+
toHaveSentMail(mail: MatcherMailRef, match?: SentMailMatch): T;
|
|
41
62
|
}
|
|
42
63
|
|
|
43
64
|
declare module 'bun:test' {
|