Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions packages/capture-kit/src/ios-snapshot-engine/conformance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ import fs from 'node:fs';
import assert from 'node:assert/strict';
import path from 'node:path';
import { test } from 'vitest';
import type { CaptureHint, IosSnapshotRequestInput } from '@agent-device/contracts/ios-snapshot';
import {
createIosSnapshotRequest,
deriveIosCaptureHint,
} from '@agent-device/capture-kit/ios-snapshot-planning';
import { IosSnapshotEngineError, presentIosSnapshot, publishIosSnapshot } from './index.ts';
import { runTypeScriptCase, writeDifferentialFailureArtifact } from './conformance-harness.ts';
import {
Expand All @@ -16,35 +11,6 @@ import {
requestForGoldenCase,
} from './conformance-fixture.ts';

const CAPTURE_HINT_FIXTURE_PATH = path.resolve(
import.meta.dirname,
'..',
'..',
'..',
'..',
'contracts',
'fixtures',
'ios-snapshot-capture-hint.json',
);

type CaptureHintFixture = Readonly<{
name: string;
request: IosSnapshotRequestInput;
expected: CaptureHint;
}>;

test('the independent capture-hint corpus agrees with the engine request boundary', () => {
const fixtures = JSON.parse(
fs.readFileSync(CAPTURE_HINT_FIXTURE_PATH, 'utf8'),
) as CaptureHintFixture[];
assert.ok(fixtures.length > 0);
assert.equal(new Set(fixtures.map((fixture) => fixture.name)).size, fixtures.length);
for (const fixture of fixtures) {
const request = createIosSnapshotRequest(fixture.request);
assert.deepEqual(deriveIosCaptureHint(request), fixture.expected, fixture.name);
}
});

test('the authored iOS snapshot corpus covers each contract seam', () => {
const fixture = readIosSnapshotEngineFixture();
assert.equal(fixture.version, 1);
Expand Down
16 changes: 2 additions & 14 deletions packages/capture-kit/src/snapshot/__tests__/ax-digest.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
import { expect, test } from 'vitest';
import { computeAxDigest } from '../snapshot-evidence.ts';

test('digest is stable across repeated calls for the same nodes', () => {
const nodes = [
{ type: 'button', label: 'Continue', identifier: 'continue-btn' },
{ type: 'text', label: 'Welcome' },
];

expect(computeAxDigest(nodes)).toEqual(computeAxDigest(nodes));
});

test('digest is order-independent over the node multiset', () => {
const a = [
{ type: 'button', label: 'Continue', identifier: 'continue-btn' },
Expand Down Expand Up @@ -54,11 +45,8 @@ test('digest changes when node count changes even with the same multiset otherwi
expect(one.nodeCount).toBe(1);
});

test('digest for an empty node array is stable and reports zero nodes', () => {
const result = computeAxDigest([]);

expect(result.nodeCount).toBe(0);
expect(result.digest).toBe(computeAxDigest([]).digest);
test('digest reports zero nodes for an empty node array', () => {
expect(computeAxDigest([]).nodeCount).toBe(0);
});

test('digest is prefixed for forward-compatible versioning', () => {
Expand Down
7 changes: 0 additions & 7 deletions packages/contracts/src/snapshot-viewport-root.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,6 @@ describe('isViewportRootNode over emitted backend vocabulary', () => {
expect(roots).toEqual(['Application', 'Window']);
});

test('iOS: substring and equality agree, so the collapse of the `===` spelling was a no-op', () => {
for (const type of IOS_EMITTED_TYPES) {
const equality = type === 'Application' || type === 'Window';
expect({ type, root: isViewportRootNode({ type }) }).toEqual({ type, root: equality });
}
});

// The load-bearing one. Android has no root node, so `resolveViewportRect`'s
// third fallback (largest containing rect of any node) is the only arm that
// ever returns on Android — and the resolvers that lack it return null there.
Expand Down
12 changes: 0 additions & 12 deletions src/__tests__/install-source-public.test.ts

This file was deleted.

52 changes: 0 additions & 52 deletions src/__tests__/metro-protocol-public.test.ts

This file was deleted.

43 changes: 42 additions & 1 deletion src/__tests__/metro-public.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { test } from 'vitest';
import assert from 'node:assert/strict';
import { buildBundleUrl, normalizeBaseUrl, resolveRuntimeTransport } from '../sdk/metro.ts';
import {
buildBundleUrl,
normalizeBaseUrl,
resolveRuntimeTransport,
type MetroBridgeDescriptor,
type MetroTunnelRequestMessage,
type MetroTunnelResponseMessage,
} from '../sdk/metro.ts';

test('public metro entrypoint exposes url and transport helpers', () => {
assert.equal(normalizeBaseUrl('https://bridge.example.test///'), 'https://bridge.example.test');
Expand All @@ -27,3 +34,37 @@ test('public metro entrypoint does not expose runtime hint builders', async () =
assert.equal(metro.buildIosRuntimeHints, undefined);
assert.equal(metro.buildAndroidRuntimeHints, undefined);
});

// Type-only contract fixtures — these verify that the public subpath types remain structurally
// stable. A rename or breaking shape change will fail the compile, not a runtime assertion.
({
enabled: true,
base_url: 'https://bridge.example.test',
ios_runtime: {
metro_host: 'runtime-1.metro.agent-device.dev',
metro_port: 443,
metro_bundle_url: 'https://runtime-1.metro.agent-device.dev/index.bundle?platform=ios',
},
android_runtime: {
metro_host: 'bridge.example.test',
metro_port: 443,
metro_bundle_url:
'https://bridge.example.test/api/metro/runtimes/runtime-1/index.bundle?platform=android',
},
upstream: { bundle_url: 'http://127.0.0.1:8081/index.bundle?platform=ios' },
probe: { reachable: true, status_code: 200, latency_ms: 4, detail: 'ok' },
}) satisfies MetroBridgeDescriptor;

({
type: 'ws-frame',
streamId: 'stream-1',
dataBase64: 'aGVsbG8=',
binary: false,
}) satisfies MetroTunnelRequestMessage;

({
type: 'http-response',
requestId: 'req-1',
status: 200,
headers: { 'content-type': 'application/json' },
}) satisfies MetroTunnelResponseMessage;
14 changes: 0 additions & 14 deletions src/daemon/__tests__/replay-coordinator-ownership.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,20 +429,6 @@ test('the divergence-report chain never imports the coordinator factory', () =>
}
});

test('the divergence-report chain never imports the P4a ReplaySessionTransaction projection', () => {
for (const file of DIVERGENCE_CHAIN_FILES) {
for (const site of collectImportSites(file)) {
assert.equal(
importsAnyBinding(site, TRANSACTION_MODULE),
false,
`${file} imports session-replay-transaction.ts directly — repair-transaction writes must ` +
`route through the request's ReplayCoordinator/ReplayResumeStamper, never this P4a ` +
`projection reached from a lower handler.`,
);
}
}
});

test('the divergence-report chain never imports SessionStore', () => {
for (const file of DIVERGENCE_CHAIN_FILES) {
for (const site of collectImportSites(file)) {
Expand Down
21 changes: 4 additions & 17 deletions src/daemon/device/__tests__/device-claim-rule.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,14 @@ import {
localRuntimeOwner,
managedLocalRuntimeOwner,
providerRuntimeOwner,
type RuntimeOwnerRef,
} from '@agent-device/contracts/platform-runtime';
import { deviceClaimRuleForOwner, type DeviceClaimRule } from '../device-claim-rule.ts';

// Every owner kind names its rule here, so a fourth kind fails to compile until it does.
const RULE_BY_OWNER_KIND: Readonly<Record<RuntimeOwnerRef['kind'], DeviceClaimRule>> = {
'local-family': 'ordinary',
'managed-local': 'allocator-held',
'provider-runtime': 'none',
};
import { deviceClaimRuleForOwner } from '../device-claim-rule.ts';

// Production owns the exhaustiveness: `deviceClaimRuleForOwner` is a switch with no default arm, so
// a fourth owner kind fails to compile until it names a rule. This table would restate that claim
// as test data that no caller reads.
test('the device-claim rule selects ordinary for a local family, allocator-held for a managed local owner, and none for a provider runtime', () => {
assert.equal(deviceClaimRuleForOwner(localRuntimeOwner('android')), 'ordinary');
assert.equal(deviceClaimRuleForOwner(managedLocalRuntimeOwner('sim-a')), 'allocator-held');
assert.equal(deviceClaimRuleForOwner(providerRuntimeOwner('limrun', 'instance-1')), 'none');
});

test.each([
localRuntimeOwner('apple'),
managedLocalRuntimeOwner('sim-b'),
providerRuntimeOwner('webdriver', 'tenant-a'),
])('the device-claim rule is exhaustive over owner kinds: $kind', (owner) => {
assert.equal(deviceClaimRuleForOwner(owner), RULE_BY_OWNER_KIND[owner.kind]);
});
117 changes: 0 additions & 117 deletions src/daemon/handlers/__tests__/session-replay-command-trust.test.ts

This file was deleted.

Loading