@ultimat3/testing 30.8.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 +49 -62
- 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 +41 -11
- 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-input.ts +22 -9
- package/src/exercise-override-line.ts +98 -0
- package/src/exercise-report.ts +30 -51
- package/src/exercise-sweeps.ts +3 -1
- package/src/exercise.ts +38 -19
- 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 +50 -15
- 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/plan-oracle.ts +10 -3
- package/src/plan-sweep.ts +37 -12
- 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/scale-sweep-run.ts +3 -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/sealed-dns-resolver.ts +56 -0
- package/src/sealed-dns.ts +63 -64
- package/src/sealed-network.ts +13 -12
- package/src/sealed-node-sockets.ts +63 -0
- package/src/sealed-sockets.ts +13 -8
- package/src/sealed-udp.ts +118 -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
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// The `images` port's contract as shared examples: `behavesLike(imageTransformDriverConformance, ()
|
|
2
|
+
// => ({ driver, src }))` — `src` resolves to `IMAGE_CONFORMANCE_SOURCE`, a 64×32 PNG. What a
|
|
3
|
+
// variant says it is (type, width, height) is what the box the browser reserves is built from, so
|
|
4
|
+
// every claim is read back off the bytes the driver answered.
|
|
5
|
+
|
|
6
|
+
import { expect, test } from 'bun:test';
|
|
7
|
+
import { blankRaster, encodeImage, isUltimateError, probeImage } from '@ultimat3/core';
|
|
8
|
+
import type { ImageTransformDriver } from '@ultimat3/seo/adapter';
|
|
9
|
+
import type { SharedExamples } from './shared-examples';
|
|
10
|
+
import { sharedExamples } from './shared-examples';
|
|
11
|
+
|
|
12
|
+
export interface ImageTransformSubject {
|
|
13
|
+
readonly driver: ImageTransformDriver;
|
|
14
|
+
/** A source this driver reads as `IMAGE_CONFORMANCE_SOURCE`. */
|
|
15
|
+
readonly src: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface ImageTransformCheck {
|
|
19
|
+
readonly name: string;
|
|
20
|
+
run(subject: ImageTransformSubject): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** 64×32, so a halving and a clamp are both visible in the height. */
|
|
24
|
+
export const IMAGE_CONFORMANCE_SOURCE: Uint8Array = encodeImage(blankRaster(64, 32));
|
|
25
|
+
|
|
26
|
+
const codeOf = (pending: Promise<unknown>): Promise<string> =>
|
|
27
|
+
pending.then(
|
|
28
|
+
() => 'answered',
|
|
29
|
+
(error: unknown) => (isUltimateError(error) ? error.code : `not coded: ${String(error)}`),
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
export const IMAGE_TRANSFORM_CHECKS: readonly ImageTransformCheck[] = [
|
|
33
|
+
{
|
|
34
|
+
name: 'a variant is the width asked, the aspect kept, and says exactly what its bytes are',
|
|
35
|
+
async run({ driver, src }) {
|
|
36
|
+
expect(driver.name.length).toBeGreaterThan(0);
|
|
37
|
+
const image = await driver.transform({ src, width: 32, format: 'png' });
|
|
38
|
+
const probed = probeImage(image.bytes);
|
|
39
|
+
expect([image.width, image.height, image.contentType]).toEqual([32, 16, 'image/png']);
|
|
40
|
+
expect([probed.width, probed.height, probed.format]).toEqual([32, 16, 'png']);
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'each format asked for is the format answered, and the content type names it',
|
|
45
|
+
async run({ driver, src }) {
|
|
46
|
+
for (const [format, type] of [
|
|
47
|
+
['jpeg', 'image/jpeg'],
|
|
48
|
+
['webp', 'image/webp'],
|
|
49
|
+
] as const) {
|
|
50
|
+
const image = await driver.transform({ src, width: 16, format });
|
|
51
|
+
expect([probeImage(image.bytes).format, image.contentType]).toEqual([format, type]);
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'a width past the source is clamped, and the answer reports the size it really is',
|
|
57
|
+
async run({ driver, src }) {
|
|
58
|
+
const image = await driver.transform({ src, width: 512 });
|
|
59
|
+
const probed = probeImage(image.bytes);
|
|
60
|
+
expect([image.width, image.height]).toEqual([probed.width, probed.height]);
|
|
61
|
+
expect(probed.width).toBeLessThanOrEqual(64);
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'a format that names nothing is refused X_IMAGE_UNSUPPORTED, never a guess',
|
|
66
|
+
async run({ driver, src }) {
|
|
67
|
+
expect(await codeOf(driver.transform({ src, width: 16, format: 'bitmap-ish' }))).toBe(
|
|
68
|
+
'X_IMAGE_UNSUPPORTED',
|
|
69
|
+
);
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: 'blurPlaceholder answers a small base64 image data URI',
|
|
74
|
+
async run({ driver, src }) {
|
|
75
|
+
const uri = await driver.blurPlaceholder(src);
|
|
76
|
+
expect(uri).toMatch(/^data:image\/[a-z]+;base64,[A-Za-z0-9+/]+=*$/);
|
|
77
|
+
expect(uri.length).toBeLessThan(4_096);
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
export const imageTransformDriverConformance: SharedExamples<ImageTransformSubject> =
|
|
83
|
+
sharedExamples('an image transform driver', (subject) => {
|
|
84
|
+
for (const check of IMAGE_TRANSFORM_CHECKS) {
|
|
85
|
+
test(check.name, async () => {
|
|
86
|
+
await check.run(subject());
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
});
|
package/src/index.ts
CHANGED
|
@@ -5,14 +5,7 @@ export type {
|
|
|
5
5
|
FixtureRegistration,
|
|
6
6
|
Fixtures,
|
|
7
7
|
} from './fixtures';
|
|
8
|
-
export {
|
|
9
|
-
clearFixtures,
|
|
10
|
-
defineFixtures,
|
|
11
|
-
fixtureSnapshot,
|
|
12
|
-
fixtureTest,
|
|
13
|
-
registeredFixtures,
|
|
14
|
-
requestedFixtures,
|
|
15
|
-
} from './fixtures';
|
|
8
|
+
export { defineFixtures, fixtureSnapshot, fixtureTest, requestedFixtures } from './fixtures';
|
|
16
9
|
// Public API of @ultimat3/testing. Explicit re-exports: the preload has its own entry point so a
|
|
17
10
|
// bunfig can load side effects without importing the whole harness.
|
|
18
11
|
|
|
@@ -31,29 +24,19 @@ export { authRequest } from './auth-request';
|
|
|
31
24
|
// tree, its rules, and the reasoned per-test `allow`.
|
|
32
25
|
export type { AxNode, AxTreeNode } from './ax-node';
|
|
33
26
|
export { toAxNode, toAxTreeNodes } from './ax-node';
|
|
34
|
-
export type { BudgetStoreLike } from './budget-store-conformance';
|
|
35
|
-
export { budgetStoreConformance } from './budget-store-conformance';
|
|
36
27
|
// Recorded vendor answers, replayed through `mockFetch` with the network sealed; recorded only by
|
|
37
28
|
// hand (`ULTIMATE_CASSETTE=record`, never under CI), with the written bytes scanned for secrets.
|
|
38
29
|
export type { Cassette, CassetteOptions } from './cassette';
|
|
39
|
-
export {
|
|
40
|
-
export type { RecordRefusal, UnusedEntry } from './cassette-errors';
|
|
41
|
-
export {
|
|
42
|
-
CassetteMissingError,
|
|
43
|
-
CassetteRecordRefusedError,
|
|
44
|
-
CassetteSecretError,
|
|
45
|
-
CassetteUnusedError,
|
|
46
|
-
} from './cassette-errors';
|
|
47
|
-
export type { CassetteEntry, CassetteFile } from './cassette-format';
|
|
30
|
+
export { cassette } from './cassette';
|
|
48
31
|
// The browser-backed e2e driver and the raw-CDP browser under it — moved here from
|
|
49
32
|
// `@ultimat3/cli` in 22.0.0. `installE2eDriver` is the ONE entry point an app's test preload calls;
|
|
50
33
|
// `openE2eBrowserIfAvailable()` answers `undefined` on a machine with no Chrome, so a
|
|
51
34
|
// browser-backed suite SKIPS rather than turning a gate red. RAW CDP over Bun's own `WebSocket`:
|
|
52
|
-
// no dependency,
|
|
35
|
+
// no dependency. The launcher, the connection, their errors and `LAUNCHED_CLOSE_MS` are imported
|
|
36
|
+
// from `@ultimat3/scraping/cdp` since 31.0.0 — their one home, which `pdf()` prints through.
|
|
53
37
|
export type { E2eBrowser, OpenE2eBrowserOptions } from './cdp-browser';
|
|
54
38
|
export {
|
|
55
39
|
DEFAULT_CDP_TIMEOUT_MS,
|
|
56
|
-
E2E_BROWSER_CLOSE_MS,
|
|
57
40
|
E2E_BROWSER_OPEN_MS,
|
|
58
41
|
E2E_GOTO_MS,
|
|
59
42
|
E2E_TAB_OPEN_MS,
|
|
@@ -62,42 +45,10 @@ export {
|
|
|
62
45
|
} from './cdp-browser';
|
|
63
46
|
export type { E2eBrowserLease, RunEndHook } from './cdp-browser-lease';
|
|
64
47
|
export { closeE2eBrowsersAtRunEnd, leaseE2eBrowser } from './cdp-browser-lease';
|
|
65
|
-
export type {
|
|
66
|
-
CdpConnection,
|
|
67
|
-
CdpConnectionOptions,
|
|
68
|
-
CdpEventListener,
|
|
69
|
-
CdpResult,
|
|
70
|
-
CdpTransport,
|
|
71
|
-
} from './cdp-connection';
|
|
72
|
-
export { cdpConnect, cdpConnectOver } from './cdp-connection';
|
|
73
48
|
export type { CdpE2eTabOptions, E2eTab } from './cdp-e2e-page';
|
|
74
49
|
export { cdpE2eTab } from './cdp-e2e-page';
|
|
75
50
|
export type { CdpE2eSessionOptions, E2eSession } from './cdp-e2e-session';
|
|
76
51
|
export { cdpE2eSession } from './cdp-e2e-session';
|
|
77
|
-
export type {
|
|
78
|
-
CdpLaunchAttempt,
|
|
79
|
-
CdpTargetGone,
|
|
80
|
-
CdpTimeoutObservation,
|
|
81
|
-
CdpTimeoutReading,
|
|
82
|
-
} from './cdp-errors';
|
|
83
|
-
export {
|
|
84
|
-
CdpBrowserMissingError,
|
|
85
|
-
CdpCallFailedError,
|
|
86
|
-
CdpLaunchFailedError,
|
|
87
|
-
CdpTimeoutError,
|
|
88
|
-
} from './cdp-errors';
|
|
89
|
-
export type { LaunchedBrowser, LaunchOptions } from './cdp-launch';
|
|
90
|
-
export {
|
|
91
|
-
CHROME_CANDIDATES,
|
|
92
|
-
CHROME_PATH_ENV,
|
|
93
|
-
CONTAINER_CHROME_ARGS,
|
|
94
|
-
findChrome,
|
|
95
|
-
LAUNCH_ATTEMPTS,
|
|
96
|
-
LAUNCH_BUDGET_MS,
|
|
97
|
-
LAUNCH_TIMEOUT_MS,
|
|
98
|
-
launchChrome,
|
|
99
|
-
launchFoundChrome,
|
|
100
|
-
} from './cdp-launch';
|
|
101
52
|
// The exercise pass (plan 101 / 40, phase 2): an app's per-primitive overrides — 39's
|
|
102
53
|
// `.contract({ exercise })` option, one shape — and the pass over every action, query and job.
|
|
103
54
|
export type { ExerciseAppOptions, ExerciseOverride, ExerciseOverrides } from './define-exercise';
|
|
@@ -122,7 +73,6 @@ export {
|
|
|
122
73
|
restoreCapturedDeterminism,
|
|
123
74
|
restoreDeterminism,
|
|
124
75
|
seededRandom,
|
|
125
|
-
seededUuid,
|
|
126
76
|
setFrozenClock,
|
|
127
77
|
withFrozenClock,
|
|
128
78
|
} from './determinism';
|
|
@@ -137,13 +87,13 @@ export type { DrillTarget } from './drill-load';
|
|
|
137
87
|
export type { DrillReport } from './drill-run';
|
|
138
88
|
export { runDrill } from './drill-run';
|
|
139
89
|
export type { DrillDeclarations } from './drill-services';
|
|
140
|
-
export {
|
|
90
|
+
export { drillServices } from './drill-services';
|
|
141
91
|
export type { DrillSyncEvidence, DrillSyncLane, DrillSyncOptions } from './drill-sync';
|
|
142
92
|
export { startDrillSync } from './drill-sync';
|
|
143
93
|
export type { DrillBudgets, DrillEvidence, DrillFailure, DrillProperty } from './drill-verdict';
|
|
144
94
|
export { judgeDrill } from './drill-verdict';
|
|
145
|
-
export type {
|
|
146
|
-
export {
|
|
95
|
+
export type { DrillWrites } from './drill-writes';
|
|
96
|
+
export { drillWriteTargets } from './drill-writes';
|
|
147
97
|
export type { Drill, DrillName, DrillRole, DrillService } from './drills';
|
|
148
98
|
export { DRILL_NAMES, DRILLS, drillNamed, drillRoles } from './drills';
|
|
149
99
|
export type { A11yFinding, A11yRule } from './e2e-a11y';
|
|
@@ -160,8 +110,7 @@ export { E2E_APP_START_MS, E2E_APP_STOP_MS, startE2eApp } from './e2e-app';
|
|
|
160
110
|
export { E2E_ROOT_ENV, e2eApp, e2eBaseUrl, e2eBrowser } from './e2e-browser-handle';
|
|
161
111
|
export type { E2eDriverOptions } from './e2e-driver';
|
|
162
112
|
export { e2eFixtures, installE2eDriver } from './e2e-driver';
|
|
163
|
-
export
|
|
164
|
-
export { E2E_ERROR_CODES, E2E_ERROR_TITLES } from './e2e-error-codes';
|
|
113
|
+
export { E2E_ERROR_CODES } from './e2e-error-codes';
|
|
165
114
|
export {
|
|
166
115
|
E2eAppFailedError,
|
|
167
116
|
E2eEvaluateCapturedError,
|
|
@@ -171,20 +120,11 @@ export {
|
|
|
171
120
|
E2eLocatorEmptyError,
|
|
172
121
|
E2eServiceWorkerAbsentError,
|
|
173
122
|
} from './e2e-errors';
|
|
174
|
-
export type { EvaluablePage } from './e2e-evaluate';
|
|
175
|
-
export { closureSource, evaluateClosure, evaluateExpression } from './e2e-evaluate';
|
|
176
123
|
export type { LocatablePage } from './e2e-locator';
|
|
177
|
-
export { e2eLocator
|
|
124
|
+
export { e2eLocator } from './e2e-locator';
|
|
178
125
|
export type { AxTreeRequest, E2eBrowserPage, E2ePageOptions } from './e2e-page';
|
|
179
126
|
export { DEFAULT_E2E_TIMEOUT_MS, DEFAULT_SERVICE_WORKER_TIMEOUT_MS, e2ePage } from './e2e-page';
|
|
180
|
-
export type {
|
|
181
|
-
export {
|
|
182
|
-
MARK_ATTRIBUTE,
|
|
183
|
-
markSelector,
|
|
184
|
-
selectionCall,
|
|
185
|
-
selectionExpression,
|
|
186
|
-
unmarkExpression,
|
|
187
|
-
} from './e2e-selection';
|
|
127
|
+
export type { E2eSelection } from './e2e-selection';
|
|
188
128
|
export type { TestingErrorCode } from './errors';
|
|
189
129
|
export {
|
|
190
130
|
AppNotBootedError,
|
|
@@ -193,18 +133,16 @@ export {
|
|
|
193
133
|
NetworkSealedError,
|
|
194
134
|
NondeterministicError,
|
|
195
135
|
RegistryLeakError,
|
|
196
|
-
TESTING_ERROR_CODES,
|
|
197
|
-
TESTING_ERROR_TITLES,
|
|
198
136
|
TestDatabaseUnavailableError,
|
|
199
137
|
} from './errors';
|
|
200
138
|
export type { ExercisePassOptions } from './exercise';
|
|
201
139
|
export { runExercisePass } from './exercise';
|
|
202
140
|
export type { ActorChoice, RoleGrants } from './exercise-actor';
|
|
203
141
|
export type { ExerciseDefect } from './exercise-defect';
|
|
142
|
+
export { type OverrideActor, type OverrideHint, overrideLine } from './exercise-override-line';
|
|
204
143
|
export type {
|
|
205
144
|
CrashFinding,
|
|
206
145
|
CrashProof,
|
|
207
|
-
EffectPayload,
|
|
208
146
|
ExerciseEffect,
|
|
209
147
|
ExerciseOutcome,
|
|
210
148
|
ExercisePhaseMs,
|
|
@@ -214,23 +152,43 @@ export type {
|
|
|
214
152
|
TenantLeg,
|
|
215
153
|
TenantProof,
|
|
216
154
|
} from './exercise-report';
|
|
217
|
-
export { overrideLine } from './exercise-report';
|
|
218
155
|
export type { ExerciseSetup, ExerciseSetupHandle } from './exercise-setup';
|
|
156
|
+
export { defineFactory } from './factories';
|
|
157
|
+
export type { AnyFactory, Factory, FactoryExtension, FactoryOptions } from './factory-api';
|
|
158
|
+
export type { BelongsToOptions, HasManyOptions } from './factory-associations';
|
|
159
|
+
export { belongsTo, hasMany } from './factory-associations';
|
|
160
|
+
export type { FactoryFinding } from './factory-errors';
|
|
161
|
+
export type { FactorySet } from './factory-lint';
|
|
162
|
+
export { assertFactoriesValid, lintFactories } from './factory-lint';
|
|
163
|
+
export type { Persister, PersisterTarget } from './factory-persist';
|
|
164
|
+
export {
|
|
165
|
+
clearPersister,
|
|
166
|
+
entityPersister,
|
|
167
|
+
persisterInstalled,
|
|
168
|
+
usePersister,
|
|
169
|
+
} from './factory-persist';
|
|
170
|
+
export type { EntityRegistry, FactoryRegistry } from './factory-registry';
|
|
171
|
+
export { factoriesFor } from './factory-registry';
|
|
219
172
|
export type {
|
|
220
|
-
|
|
221
|
-
|
|
173
|
+
AttributesFor,
|
|
174
|
+
BelongsTo,
|
|
175
|
+
BelongsToMap,
|
|
176
|
+
Built,
|
|
177
|
+
Created,
|
|
222
178
|
EntityLike,
|
|
223
|
-
|
|
179
|
+
FactoryContext,
|
|
224
180
|
FactoryIds,
|
|
225
|
-
|
|
181
|
+
FactoryLike,
|
|
182
|
+
FactoryOverrides,
|
|
183
|
+
ForeignKeysOf,
|
|
184
|
+
HasMany,
|
|
185
|
+
HasManyMap,
|
|
186
|
+
None,
|
|
187
|
+
StoredOf,
|
|
226
188
|
Trait,
|
|
227
189
|
TraitMap,
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
export type { Persister } from './factory-persist';
|
|
231
|
-
export { clearPersister, persisterInstalled, usePersister } from './factory-persist';
|
|
232
|
-
export type { EntityRegistry, FactoryRegistry } from './factory-registry';
|
|
233
|
-
export { factoriesFor } from './factory-registry';
|
|
190
|
+
WriteBound,
|
|
191
|
+
} from './factory-types';
|
|
234
192
|
export type {
|
|
235
193
|
FakeIdentityProvider,
|
|
236
194
|
FakeIdentityProviderInput,
|
|
@@ -239,12 +197,11 @@ export type {
|
|
|
239
197
|
} from './fake-identity-provider';
|
|
240
198
|
export { fakeIdentityProvider } from './fake-identity-provider';
|
|
241
199
|
export type { FaultMode, FaultProxy, FaultProxyCounts } from './fault-proxy';
|
|
242
|
-
export { faultProxy
|
|
200
|
+
export { faultProxy } from './fault-proxy';
|
|
243
201
|
export type { TestClock, TestDuration } from './fixture-clock';
|
|
244
202
|
export { testClock } from './fixture-clock';
|
|
245
203
|
export type {
|
|
246
204
|
DriverFixtureName,
|
|
247
|
-
DriverFixtures,
|
|
248
205
|
LiveFeed,
|
|
249
206
|
LiveFeedPatch,
|
|
250
207
|
LiveTarget,
|
|
@@ -253,7 +210,7 @@ export type {
|
|
|
253
210
|
TestBudget,
|
|
254
211
|
TestDeploy,
|
|
255
212
|
} from './fixture-drivers';
|
|
256
|
-
export {
|
|
213
|
+
export { unavailableFixture } from './fixture-drivers';
|
|
257
214
|
// The island fixture. `build` is a PARAMETER — `buildIslands` lives in `@ultimat3/cli`, which is
|
|
258
215
|
// tier 5 like this package and whose one declared edge points the other way, so an app supplies it:
|
|
259
216
|
// `mountIsland({ build: buildIslands, root, file })`.
|
|
@@ -280,14 +237,14 @@ export { testMail } from './fixture-mail';
|
|
|
280
237
|
export type { TestNetwork } from './fixture-network';
|
|
281
238
|
export { testNetwork } from './fixture-network';
|
|
282
239
|
export type { TestPush, TestPushMessage } from './fixture-push';
|
|
283
|
-
export {
|
|
240
|
+
export type { SeededRow, SeedFixtureOptions, SeedHandle } from './fixture-seed';
|
|
241
|
+
export { seedFixture } from './fixture-seed';
|
|
284
242
|
export type { ObservedStatement, StatementShape, TestStatements } from './fixture-statements';
|
|
285
243
|
export { testStatements } from './fixture-statements';
|
|
286
244
|
export type { SubscribeDriver } from './fixture-subscribe';
|
|
287
245
|
export { subscribeDriver } from './fixture-subscribe';
|
|
288
246
|
export { fixtureTest as test } from './fixtures';
|
|
289
247
|
export {
|
|
290
|
-
ALL_FIXTURE_NAMES,
|
|
291
248
|
DRIVER_FIXTURE_NAMES,
|
|
292
249
|
FRAMEWORK_FIXTURE_NAMES,
|
|
293
250
|
registerFrameworkFixtures,
|
|
@@ -296,10 +253,9 @@ export type { AppHandle, AppOptions, BootedApp } from './harness';
|
|
|
296
253
|
export { describeApp, testApp } from './harness';
|
|
297
254
|
// Type-only: the micro-DOM is the fixture's to build, and a test only ever names what it handed back.
|
|
298
255
|
export type { FakeElement, FakeNode, FakeText } from './island-dom';
|
|
299
|
-
export type {
|
|
256
|
+
export type { ResizeInput } from './island-observers';
|
|
300
257
|
export type { IslandAddress, IslandShotTarget } from './island-shot-targets';
|
|
301
258
|
export {
|
|
302
|
-
isIslandTheme,
|
|
303
259
|
islandAddress,
|
|
304
260
|
islandShotFile,
|
|
305
261
|
islandShotPlan,
|
|
@@ -312,11 +268,7 @@ export { islandStatesFile } from './island-state-errors';
|
|
|
312
268
|
// One declared state, mounted: `describeIslandState` owns a block's mount and teardown,
|
|
313
269
|
// `mountIslandState` is the one mount a single test asks for with `using`.
|
|
314
270
|
export type { IslandStateMountOptions, IslandStateSuiteOptions } from './island-state-mount';
|
|
315
|
-
export {
|
|
316
|
-
describeIslandState,
|
|
317
|
-
ISLAND_MOUNT_TIMEOUT_MS,
|
|
318
|
-
mountIslandState,
|
|
319
|
-
} from './island-state-mount';
|
|
271
|
+
export { describeIslandState, mountIslandState } from './island-state-mount';
|
|
320
272
|
export type {
|
|
321
273
|
IslandRouteStub,
|
|
322
274
|
IslandState,
|
|
@@ -327,45 +279,16 @@ export type {
|
|
|
327
279
|
IslandTheme,
|
|
328
280
|
IslandViewport,
|
|
329
281
|
} from './island-states';
|
|
330
|
-
export {
|
|
331
|
-
DEFAULT_ISLAND_THEME,
|
|
332
|
-
DEFAULT_ISLAND_VIEWPORT,
|
|
333
|
-
ISLAND_SHOT_TIME_ZONE,
|
|
334
|
-
ISLAND_STATES,
|
|
335
|
-
ISLAND_THEMES,
|
|
336
|
-
isIslandStatesManifest,
|
|
337
|
-
islandStatesName,
|
|
338
|
-
} from './island-states';
|
|
282
|
+
export { ISLAND_SHOT_TIME_ZONE, isIslandStatesManifest } from './island-states';
|
|
339
283
|
export type { JsonFault } from './island-states-check';
|
|
340
|
-
export {
|
|
341
|
-
|
|
342
|
-
isStateId,
|
|
343
|
-
isStubMatch,
|
|
344
|
-
isTimeZone,
|
|
345
|
-
jsonFault,
|
|
346
|
-
slugifyStateId,
|
|
347
|
-
} from './island-states-check';
|
|
348
|
-
export type {
|
|
349
|
-
IslandFaultKind,
|
|
350
|
-
IslandStatesFault,
|
|
351
|
-
ModuleEdge,
|
|
352
|
-
} from './island-states-pure';
|
|
353
|
-
export {
|
|
354
|
-
assertIslandStatesPure,
|
|
355
|
-
importSpecifiers,
|
|
356
|
-
impureSpecifier,
|
|
357
|
-
islandStatesFault,
|
|
358
|
-
islandStatesImportFault,
|
|
359
|
-
moduleEdges,
|
|
360
|
-
} from './island-states-pure';
|
|
284
|
+
export { isPinnedInstant, isStubMatch, isTimeZone, jsonFault } from './island-states-check';
|
|
285
|
+
export { assertIslandStatesPure } from './island-states-pure';
|
|
361
286
|
export {
|
|
362
287
|
assertIslandFiles,
|
|
363
288
|
assertUniqueIslandStates,
|
|
364
289
|
findIslandStates,
|
|
365
290
|
islandStatesMatching,
|
|
366
291
|
islandStatesNames,
|
|
367
|
-
missingIslandFiles,
|
|
368
|
-
normalizeIslandName,
|
|
369
292
|
} from './island-states-resolve';
|
|
370
293
|
export { ISOLATED_ENV, releasePluginsAfterIsolatedFile } from './isolated-plugins';
|
|
371
294
|
export { CRASH_POINT_BOUND } from './job-crash-points';
|
|
@@ -377,17 +300,10 @@ export type {
|
|
|
377
300
|
CrashRerun,
|
|
378
301
|
} from './job-crash-proof';
|
|
379
302
|
export { crashProof } from './job-crash-proof';
|
|
380
|
-
export { jobDriverConformance } from './job-driver-conformance';
|
|
381
303
|
export type { SimEffect } from './job-sim-effects';
|
|
382
|
-
export {
|
|
383
|
-
crashEffectPlace,
|
|
384
|
-
JobCrashDivergedError,
|
|
385
|
-
JobCrashUnboundedError,
|
|
386
|
-
JobSimInvariantError,
|
|
387
|
-
JobSimNondeterministicError,
|
|
388
|
-
} from './job-sim-errors';
|
|
304
|
+
export { crashEffectPlace, JobCrashDivergedError, JobCrashUnboundedError } from './job-sim-errors';
|
|
389
305
|
export type { JobFaultKind } from './job-sim-schedule';
|
|
390
|
-
export { ALL_FAULTS
|
|
306
|
+
export { ALL_FAULTS } from './job-sim-schedule';
|
|
391
307
|
export type {
|
|
392
308
|
SimulatedJob,
|
|
393
309
|
SimulatedRun,
|
|
@@ -401,23 +317,21 @@ export { liveNode } from './live-node';
|
|
|
401
317
|
// The store a mutator's `local()` half writes into under test — the Map every app hand-rolled.
|
|
402
318
|
export type { LocalRows, MemoryLocalTx } from './local-tx';
|
|
403
319
|
export { memoryLocalTx } from './local-tx';
|
|
320
|
+
export type { EnqueuedJobRef, MatcherMailRef, SentMailMatch } from './matcher-surface';
|
|
404
321
|
/**
|
|
405
322
|
* The budget `toBeVisible(options?)` takes. Exported because it is in a public matcher's signature;
|
|
406
323
|
* `retryUntil` and `RetryBudget` deliberately are NOT — nothing outside this package calls them,
|
|
407
324
|
* and an export nothing calls is the unwired declaration this matcher exists to have closed.
|
|
408
325
|
*/
|
|
409
326
|
export type { VisibleOptions } from './matcher-visible';
|
|
410
|
-
export
|
|
411
|
-
export { matchersInstalled, recordSteps } from './matchers';
|
|
327
|
+
export { recordSteps } from './matchers';
|
|
412
328
|
export type { MockHandler, MockRoute } from './mock-route';
|
|
413
329
|
// The plan and scale sweeps (plan 101 / 40-next-query-plans): every statement the pass sent planned
|
|
414
330
|
// with no index but the declared ones, every reached primitive again at 2 and 8 rows a table.
|
|
415
|
-
export type {
|
|
416
|
-
export { judgePlan, planRoot } from './plan-oracle';
|
|
331
|
+
export type { PlanVerdictCode } from './plan-oracle';
|
|
417
332
|
export type { PlanExempt, PlanProof, SentStatement } from './plan-sweep';
|
|
418
333
|
export { QueryPlanUnavailableError, sweepPlans } from './plan-sweep';
|
|
419
334
|
export type { PlanFinding } from './plan-sweep-fix';
|
|
420
|
-
export { planFindings } from './plan-sweep-fix';
|
|
421
335
|
export type { SweepFinding } from './plan-sweep-report';
|
|
422
336
|
export { planSweepFindings, planSweepLines } from './plan-sweep-report';
|
|
423
337
|
// `isolateEntityRegistry` is deliberately NOT here — it is `@ultimat3/testing/registry-isolation`.
|
|
@@ -426,10 +340,9 @@ export { planSweepFindings, planSweepLines } from './plan-sweep-report';
|
|
|
426
340
|
// registry into every test in the framework. Every other package this harness touches is imported
|
|
427
341
|
// dynamically inside the fixture that needs it; a helper that must stay synchronous cannot do that,
|
|
428
342
|
// so it gets its own entry point instead.
|
|
429
|
-
export type { RegistryLeak
|
|
430
|
-
export { installRegistryLeakGuard
|
|
343
|
+
export type { RegistryLeak } from './registry-leak-guard';
|
|
344
|
+
export { installRegistryLeakGuard } from './registry-leak-guard';
|
|
431
345
|
export type { ProcessRegistrySnapshot } from './registry-snapshot';
|
|
432
|
-
export { captureProcessRegistries, restoreProcessRegistries } from './registry-snapshot';
|
|
433
346
|
// What the server renders, for a unit test. `@ultimat3/render` is imported inside the two
|
|
434
347
|
// functions, so a tier-0 test importing this barrel for `expect` still loads no renderer.
|
|
435
348
|
export type { RenderedRoute, RenderedView, RouteModule, RouteRequest } from './render-view';
|
|
@@ -438,8 +351,7 @@ export { renderRoute, renderView } from './render-view';
|
|
|
438
351
|
export type { JobFailure, ReproduceOptions, ReproOutcome } from './repro';
|
|
439
352
|
export { reproduce, reproJob } from './repro';
|
|
440
353
|
export type { LoggedRequest } from './request-log';
|
|
441
|
-
export
|
|
442
|
-
export { restoreDatabase, reusableDatabase, snapshotDatabase } from './reusable-database';
|
|
354
|
+
export { reusableDatabase } from './reusable-database';
|
|
443
355
|
export type { ScaleProof, ScaleShape, StatementTally } from './scale-sweep';
|
|
444
356
|
export { judgeScale, SCALE_SIZES } from './scale-sweep';
|
|
445
357
|
export type { NetworkSnapshot, NetworkState } from './sealed-network';
|
|
@@ -449,24 +361,22 @@ export type { NetworkSnapshot, NetworkState } from './sealed-network';
|
|
|
449
361
|
export {
|
|
450
362
|
allowHost,
|
|
451
363
|
captureNetwork,
|
|
452
|
-
isNetworkSealed,
|
|
453
364
|
MOCKED_HOST_ADDRESS,
|
|
454
365
|
mockFetch,
|
|
455
366
|
mockJson,
|
|
456
|
-
networkState,
|
|
457
367
|
requestLog,
|
|
458
368
|
resetNetwork,
|
|
459
|
-
restoreCapturedNetwork,
|
|
460
369
|
sealNetwork,
|
|
461
370
|
unsealNetwork,
|
|
462
371
|
} from './sealed-network';
|
|
372
|
+
export { factorySeed } from './seed-factories';
|
|
463
373
|
// Rows for every table with no factory written (plan 101 / 40, phase 1): parents first, same-tenant
|
|
464
374
|
// keys, values off each column's declaration. Types only from `@ultimat3/entity`, so no registry.
|
|
465
375
|
export { seedGraph } from './seed-graph';
|
|
466
376
|
export type { SeedGraphUnsatisfiedInput } from './seed-graph-error';
|
|
467
377
|
// A seed graph written through each entity's own repository — a pinned client (Postgres, PGlite) or
|
|
468
378
|
// the app's driver (memory, `testDriver()`). Loads `@ultimat3/entity` on its first write, not here.
|
|
469
|
-
export {
|
|
379
|
+
export { SeedGraphUnsatisfiedError } from './seed-graph-error';
|
|
470
380
|
export type {
|
|
471
381
|
SeedCanary,
|
|
472
382
|
SeedFactory,
|
|
@@ -483,9 +393,14 @@ export type { EntitySeedWriterOptions, SeedWriterTarget } from './seed-writer';
|
|
|
483
393
|
export { entitySeedWriter } from './seed-writer';
|
|
484
394
|
export type { SharedExamples } from './shared-examples';
|
|
485
395
|
export { behavesLike, sharedExamples } from './shared-examples';
|
|
396
|
+
// Test doubles: `stub(primitive)` replaces an action's, an llm()'s or a job's body, `swapAdapter`
|
|
397
|
+
// an adapter port; both are put back after the test that made them (`test-scope.ts`).
|
|
398
|
+
export { stub } from './stub';
|
|
399
|
+
export type { Stub, StubCall } from './stub-script';
|
|
486
400
|
export type { SubjectProofOptions, SubjectProofResult } from './subject-proof';
|
|
487
401
|
export { subjectProof } from './subject-proof';
|
|
488
|
-
export {
|
|
402
|
+
export type { SwappableAdapters, SwappablePort } from './swap-adapter';
|
|
403
|
+
export { swapAdapter, UNSWAPPED } from './swap-adapter';
|
|
489
404
|
export type {
|
|
490
405
|
DisposableWorkerDatabase,
|
|
491
406
|
SqlRunner,
|
|
@@ -495,12 +410,9 @@ export type {
|
|
|
495
410
|
export {
|
|
496
411
|
acquireWorkerDatabase,
|
|
497
412
|
cloneSql,
|
|
498
|
-
DEFAULT_TEMPLATE,
|
|
499
|
-
databaseNameFor,
|
|
500
413
|
dropSql,
|
|
501
414
|
lockSql,
|
|
502
415
|
templateSql,
|
|
503
|
-
unlockSql,
|
|
504
416
|
urlFor,
|
|
505
417
|
workerId,
|
|
506
418
|
} from './template-db';
|
|
@@ -508,7 +420,7 @@ export {
|
|
|
508
420
|
// are what `x exercise` prints; `tenancy:cross` is `@ultimat3/entity`'s `CROSS_TENANT_SCOPE`.
|
|
509
421
|
export type { TenantProofFinding } from './tenant-proof-report';
|
|
510
422
|
export { tenantFindingLines, tenantProofFindings } from './tenant-proof-report';
|
|
511
|
-
export { paced, TEST_PACE_ENV
|
|
423
|
+
export { paced, TEST_PACE_ENV } from './test-pace';
|
|
512
424
|
// `x exercise` is a test process too: it hands itself the same key, judged by the same rule.
|
|
513
425
|
export { testSealKeyEnv } from './test-seal-key';
|
|
514
426
|
export type {
|
|
@@ -519,7 +431,6 @@ export type {
|
|
|
519
431
|
EvalCase,
|
|
520
432
|
EvalOptions,
|
|
521
433
|
LocatorLike,
|
|
522
|
-
OpenApiLike,
|
|
523
434
|
PageLike,
|
|
524
435
|
TestOptions,
|
|
525
436
|
TestType,
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// The `IsrStore` contract as shared examples: `behavesLike(isrStoreConformance, () => store)` runs
|
|
2
|
+
// every check against a store of your own — memory, over a disk, over your database. Each check
|
|
3
|
+
// writes paths of its own, so one shared store serves every test and asserts containment only.
|
|
4
|
+
|
|
5
|
+
import { expect, test } from 'bun:test';
|
|
6
|
+
import type { IsrEntry, IsrStore } from '@ultimat3/render/server';
|
|
7
|
+
import type { SharedExamples } from './shared-examples';
|
|
8
|
+
import { sharedExamples } from './shared-examples';
|
|
9
|
+
|
|
10
|
+
export interface IsrStoreCheck {
|
|
11
|
+
readonly name: string;
|
|
12
|
+
run(store: IsrStore): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const scopeOf = (): string => `/conformance-${crypto.randomUUID()}`;
|
|
16
|
+
|
|
17
|
+
const entryOf = (path: string, html = `<p>${path}</p>`): IsrEntry => ({
|
|
18
|
+
path,
|
|
19
|
+
html,
|
|
20
|
+
hash: `h-${html.length}`,
|
|
21
|
+
generatedAt: 1_000,
|
|
22
|
+
ttlMs: 60_000,
|
|
23
|
+
stale: false,
|
|
24
|
+
status: 200,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export const ISR_STORE_CHECKS: readonly IsrStoreCheck[] = [
|
|
28
|
+
{
|
|
29
|
+
name: 'a set entry reads back whole, and an unheld path is undefined',
|
|
30
|
+
async run(store) {
|
|
31
|
+
const path = `${scopeOf()}/a`;
|
|
32
|
+
expect(await store.get(path)).toBeUndefined();
|
|
33
|
+
const entry = { ...entryOf(path), status: 404 };
|
|
34
|
+
await store.set(entry);
|
|
35
|
+
expect(await store.get(path)).toEqual(entry);
|
|
36
|
+
expect(await store.paths()).toContain(path);
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'the query is part of the key: /p?page=2 and /p?page=3 are two pages',
|
|
41
|
+
async run(store) {
|
|
42
|
+
const base = `${scopeOf()}/precios-espa%C3%B1a`;
|
|
43
|
+
const [two, three] = [`${base}?page=2&__x_locale=es`, `${base}?page=3&__x_locale=es`];
|
|
44
|
+
await store.set(entryOf(two, 'two'));
|
|
45
|
+
await store.set(entryOf(three, 'three'));
|
|
46
|
+
expect([(await store.get(two))?.html, (await store.get(three))?.html]).toEqual([
|
|
47
|
+
'two',
|
|
48
|
+
'three',
|
|
49
|
+
]);
|
|
50
|
+
expect(await store.get(base)).toBeUndefined();
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'a re-set replaces the page, its html and its stale mark alike',
|
|
55
|
+
async run(store) {
|
|
56
|
+
const path = `${scopeOf()}/r`;
|
|
57
|
+
await store.set(entryOf(path, 'old'));
|
|
58
|
+
await store.markStale(path);
|
|
59
|
+
await store.set(entryOf(path, 'new'));
|
|
60
|
+
expect(await store.get(path)).toMatchObject({ html: 'new', stale: false });
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'markStale marks a held page in place, and answers false for one it never held',
|
|
65
|
+
async run(store) {
|
|
66
|
+
const path = `${scopeOf()}/s`;
|
|
67
|
+
await store.set(entryOf(path));
|
|
68
|
+
expect(await store.markStale(path)).toBe(true);
|
|
69
|
+
expect(await store.get(path)).toEqual({ ...entryOf(path), stale: true });
|
|
70
|
+
expect(await store.markStale(`${scopeOf()}/never`)).toBe(false);
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: 'delete takes the page out of get, markStale and paths',
|
|
75
|
+
async run(store) {
|
|
76
|
+
const path = `${scopeOf()}/d`;
|
|
77
|
+
await store.set(entryOf(path));
|
|
78
|
+
await store.delete(path);
|
|
79
|
+
expect(await store.get(path)).toBeUndefined();
|
|
80
|
+
expect(await store.markStale(path)).toBe(false);
|
|
81
|
+
expect(await store.paths()).not.toContain(path);
|
|
82
|
+
await store.delete(path);
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: 'a tag fence refuses a write whose reading a bump made void, and takes a current one',
|
|
87
|
+
async run(store) {
|
|
88
|
+
// Optional on the port: a store without one is refused at boot when a route purges.
|
|
89
|
+
const fence = store.tagFence;
|
|
90
|
+
if (fence === undefined) return;
|
|
91
|
+
const [path, entity] = [`${scopeOf()}/f`, `e${crypto.randomUUID().slice(0, 8)}`];
|
|
92
|
+
const stale = await fence.sample([entity]);
|
|
93
|
+
await fence.bump([entity]);
|
|
94
|
+
expect(await fence.setIfCurrent(entryOf(path), [entity], stale)).toBe(false);
|
|
95
|
+
expect(await store.get(path)).toBeUndefined();
|
|
96
|
+
const current = await fence.sample([entity]);
|
|
97
|
+
expect(current).not.toBe(stale);
|
|
98
|
+
expect(await fence.setIfCurrent(entryOf(path), [entity], current)).toBe(true);
|
|
99
|
+
expect((await store.get(path))?.html).toBe(entryOf(path).html);
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
];
|
|
103
|
+
|
|
104
|
+
export const isrStoreConformance: SharedExamples<IsrStore | Promise<IsrStore>> = sharedExamples(
|
|
105
|
+
'an ISR store',
|
|
106
|
+
(subject) => {
|
|
107
|
+
for (const check of ISR_STORE_CHECKS) {
|
|
108
|
+
test(check.name, async () => {
|
|
109
|
+
await check.run(await subject());
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
);
|