Skip to content

Commit a836be1

Browse files
committed
test: drop cases that re-assert their own input or a stronger sibling
Eight tests could not fail for a reason worth hearing. Each was checked against its production owner, its callers, and the stronger test that already covers it. - `ax-digest.test.ts`: `computeAxDigest(nodes)` compared against a second call to the same pure function — true by construction. The empty-array case kept its `nodeCount` assertion and lost its self-comparison. - `ios-snapshot-engine/conformance.test.ts`: replayed `contracts/fixtures/ios-snapshot-capture-hint.json` through `createIosSnapshotRequest` + `deriveIosCaptureHint` with the same four assertions `ios-snapshot-planning.test.ts` makes one file away. The golden table keeps its owning leg; only the second copy goes. - `replay-coordinator-ownership.test.ts`: the divergence-chain import ban is a strict subset of the `src/daemon/replay/`-wide scan beside it, same module and same predicate, so it cannot fire without that one firing first. - `device-claim-rule.test.ts`: compared production against a hand-copied test table of the three rules the same file already asserts directly. Exhaustiveness is production's own default-less switch. - `snapshot-viewport-root.test.ts`: over the complete 31-name iOS vocabulary the preceding case fixes, "equals `Application` or `Window`" is the same proposition as "filters to exactly those two". - `install-source-public.test.ts`: asserted the URL its sibling asserts at the owner, plus a `typeof` probe. The subpath is proven by `package-exports` and by the installed-tarball probe that calls through it. - `metro-protocol-public.test.ts`: its runtime half repeated `metro-public.test.ts` verbatim; the compile-time wire fixtures it also carried move there, so the public metro surface has one test file mirroring `src/sdk/metro.ts`. - `session-replay-command-trust.test.ts`: mocked the replay façade and read the command field back. `session-replay-maestro-remote-evalscript.test.ts` drives the same two real handlers and asserts the terminal `trustedScripts` the engine receives. Proven by mutation: dropping the mapping in `replay-dispatch-envelope.ts` turns that suite's two remote cases red.
1 parent 2db7c42 commit a836be1

9 files changed

Lines changed: 48 additions & 268 deletions

File tree

‎packages/capture-kit/src/ios-snapshot-engine/conformance.test.ts‎

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@ import fs from 'node:fs';
22
import assert from 'node:assert/strict';
33
import path from 'node:path';
44
import { test } from 'vitest';
5-
import type { CaptureHint, IosSnapshotRequestInput } from '@agent-device/contracts/ios-snapshot';
6-
import {
7-
createIosSnapshotRequest,
8-
deriveIosCaptureHint,
9-
} from '@agent-device/capture-kit/ios-snapshot-planning';
105
import { IosSnapshotEngineError, presentIosSnapshot, publishIosSnapshot } from './index.ts';
116
import { runTypeScriptCase, writeDifferentialFailureArtifact } from './conformance-harness.ts';
127
import {
@@ -16,35 +11,6 @@ import {
1611
requestForGoldenCase,
1712
} from './conformance-fixture.ts';
1813

19-
const CAPTURE_HINT_FIXTURE_PATH = path.resolve(
20-
import.meta.dirname,
21-
'..',
22-
'..',
23-
'..',
24-
'..',
25-
'contracts',
26-
'fixtures',
27-
'ios-snapshot-capture-hint.json',
28-
);
29-
30-
type CaptureHintFixture = Readonly<{
31-
name: string;
32-
request: IosSnapshotRequestInput;
33-
expected: CaptureHint;
34-
}>;
35-
36-
test('the independent capture-hint corpus agrees with the engine request boundary', () => {
37-
const fixtures = JSON.parse(
38-
fs.readFileSync(CAPTURE_HINT_FIXTURE_PATH, 'utf8'),
39-
) as CaptureHintFixture[];
40-
assert.ok(fixtures.length > 0);
41-
assert.equal(new Set(fixtures.map((fixture) => fixture.name)).size, fixtures.length);
42-
for (const fixture of fixtures) {
43-
const request = createIosSnapshotRequest(fixture.request);
44-
assert.deepEqual(deriveIosCaptureHint(request), fixture.expected, fixture.name);
45-
}
46-
});
47-
4814
test('the authored iOS snapshot corpus covers each contract seam', () => {
4915
const fixture = readIosSnapshotEngineFixture();
5016
assert.equal(fixture.version, 1);

‎packages/capture-kit/src/snapshot/__tests__/ax-digest.test.ts‎

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
import { expect, test } from 'vitest';
22
import { computeAxDigest } from '../snapshot-evidence.ts';
33

4-
test('digest is stable across repeated calls for the same nodes', () => {
5-
const nodes = [
6-
{ type: 'button', label: 'Continue', identifier: 'continue-btn' },
7-
{ type: 'text', label: 'Welcome' },
8-
];
9-
10-
expect(computeAxDigest(nodes)).toEqual(computeAxDigest(nodes));
11-
});
12-
134
test('digest is order-independent over the node multiset', () => {
145
const a = [
156
{ type: 'button', label: 'Continue', identifier: 'continue-btn' },
@@ -54,11 +45,8 @@ test('digest changes when node count changes even with the same multiset otherwi
5445
expect(one.nodeCount).toBe(1);
5546
});
5647

57-
test('digest for an empty node array is stable and reports zero nodes', () => {
58-
const result = computeAxDigest([]);
59-
60-
expect(result.nodeCount).toBe(0);
61-
expect(result.digest).toBe(computeAxDigest([]).digest);
48+
test('digest reports zero nodes for an empty node array', () => {
49+
expect(computeAxDigest([]).nodeCount).toBe(0);
6250
});
6351

6452
test('digest is prefixed for forward-compatible versioning', () => {

‎packages/contracts/src/snapshot-viewport-root.test.ts‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,6 @@ describe('isViewportRootNode over emitted backend vocabulary', () => {
167167
expect(roots).toEqual(['Application', 'Window']);
168168
});
169169

170-
test('iOS: substring and equality agree, so the collapse of the `===` spelling was a no-op', () => {
171-
for (const type of IOS_EMITTED_TYPES) {
172-
const equality = type === 'Application' || type === 'Window';
173-
expect({ type, root: isViewportRootNode({ type }) }).toEqual({ type, root: equality });
174-
}
175-
});
176-
177170
// The load-bearing one. Android has no root node, so `resolveViewportRect`'s
178171
// third fallback (largest containing rect of any node) is the only arm that
179172
// ever returns on Android — and the resolvers that lack it return null there.

‎src/__tests__/install-source-public.test.ts‎

Lines changed: 0 additions & 12 deletions
This file was deleted.

‎src/__tests__/metro-protocol-public.test.ts‎

Lines changed: 0 additions & 52 deletions
This file was deleted.

‎src/__tests__/metro-public.test.ts‎

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import { test } from 'vitest';
22
import assert from 'node:assert/strict';
3-
import { buildBundleUrl, normalizeBaseUrl, resolveRuntimeTransport } from '../sdk/metro.ts';
3+
import {
4+
buildBundleUrl,
5+
normalizeBaseUrl,
6+
resolveRuntimeTransport,
7+
type MetroBridgeDescriptor,
8+
type MetroTunnelRequestMessage,
9+
type MetroTunnelResponseMessage,
10+
} from '../sdk/metro.ts';
411

512
test('public metro entrypoint exposes url and transport helpers', () => {
613
assert.equal(normalizeBaseUrl('https://bridge.example.test///'), 'https://bridge.example.test');
@@ -27,3 +34,37 @@ test('public metro entrypoint does not expose runtime hint builders', async () =
2734
assert.equal(metro.buildIosRuntimeHints, undefined);
2835
assert.equal(metro.buildAndroidRuntimeHints, undefined);
2936
});
37+
38+
// Type-only contract fixtures — these verify that the public subpath types remain structurally
39+
// stable. A rename or breaking shape change will fail the compile, not a runtime assertion.
40+
({
41+
enabled: true,
42+
base_url: 'https://bridge.example.test',
43+
ios_runtime: {
44+
metro_host: 'runtime-1.metro.agent-device.dev',
45+
metro_port: 443,
46+
metro_bundle_url: 'https://runtime-1.metro.agent-device.dev/index.bundle?platform=ios',
47+
},
48+
android_runtime: {
49+
metro_host: 'bridge.example.test',
50+
metro_port: 443,
51+
metro_bundle_url:
52+
'https://bridge.example.test/api/metro/runtimes/runtime-1/index.bundle?platform=android',
53+
},
54+
upstream: { bundle_url: 'http://127.0.0.1:8081/index.bundle?platform=ios' },
55+
probe: { reachable: true, status_code: 200, latency_ms: 4, detail: 'ok' },
56+
}) satisfies MetroBridgeDescriptor;
57+
58+
({
59+
type: 'ws-frame',
60+
streamId: 'stream-1',
61+
dataBase64: 'aGVsbG8=',
62+
binary: false,
63+
}) satisfies MetroTunnelRequestMessage;
64+
65+
({
66+
type: 'http-response',
67+
requestId: 'req-1',
68+
status: 200,
69+
headers: { 'content-type': 'application/json' },
70+
}) satisfies MetroTunnelResponseMessage;

‎src/daemon/__tests__/replay-coordinator-ownership.test.ts‎

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -429,20 +429,6 @@ test('the divergence-report chain never imports the coordinator factory', () =>
429429
}
430430
});
431431

432-
test('the divergence-report chain never imports the P4a ReplaySessionTransaction projection', () => {
433-
for (const file of DIVERGENCE_CHAIN_FILES) {
434-
for (const site of collectImportSites(file)) {
435-
assert.equal(
436-
importsAnyBinding(site, TRANSACTION_MODULE),
437-
false,
438-
`${file} imports session-replay-transaction.ts directly — repair-transaction writes must ` +
439-
`route through the request's ReplayCoordinator/ReplayResumeStamper, never this P4a ` +
440-
`projection reached from a lower handler.`,
441-
);
442-
}
443-
}
444-
});
445-
446432
test('the divergence-report chain never imports SessionStore', () => {
447433
for (const file of DIVERGENCE_CHAIN_FILES) {
448434
for (const site of collectImportSites(file)) {

‎src/daemon/device/__tests__/device-claim-rule.test.ts‎

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,14 @@ import {
44
localRuntimeOwner,
55
managedLocalRuntimeOwner,
66
providerRuntimeOwner,
7-
type RuntimeOwnerRef,
87
} from '@agent-device/contracts/platform-runtime';
9-
import { deviceClaimRuleForOwner, type DeviceClaimRule } from '../device-claim-rule.ts';
10-
11-
// Every owner kind names its rule here, so a fourth kind fails to compile until it does.
12-
const RULE_BY_OWNER_KIND: Readonly<Record<RuntimeOwnerRef['kind'], DeviceClaimRule>> = {
13-
'local-family': 'ordinary',
14-
'managed-local': 'allocator-held',
15-
'provider-runtime': 'none',
16-
};
8+
import { deviceClaimRuleForOwner } from '../device-claim-rule.ts';
179

10+
// Production owns the exhaustiveness: `deviceClaimRuleForOwner` is a switch with no default arm, so
11+
// a fourth owner kind fails to compile until it names a rule. This table would restate that claim
12+
// as test data that no caller reads.
1813
test('the device-claim rule selects ordinary for a local family, allocator-held for a managed local owner, and none for a provider runtime', () => {
1914
assert.equal(deviceClaimRuleForOwner(localRuntimeOwner('android')), 'ordinary');
2015
assert.equal(deviceClaimRuleForOwner(managedLocalRuntimeOwner('sim-a')), 'allocator-held');
2116
assert.equal(deviceClaimRuleForOwner(providerRuntimeOwner('limrun', 'instance-1')), 'none');
2217
});
23-
24-
test.each([
25-
localRuntimeOwner('apple'),
26-
managedLocalRuntimeOwner('sim-b'),
27-
providerRuntimeOwner('webdriver', 'tenant-a'),
28-
])('the device-claim rule is exhaustive over owner kinds: $kind', (owner) => {
29-
assert.equal(deviceClaimRuleForOwner(owner), RULE_BY_OWNER_KIND[owner.kind]);
30-
});

‎src/daemon/handlers/__tests__/session-replay-command-trust.test.ts‎

Lines changed: 0 additions & 117 deletions
This file was deleted.

0 commit comments

Comments
 (0)