mirror of
https://github.com/callstack/agent-device.git
synced 2026-09-14 20:06:34 +08:00
d76e0f94e9
* refactor: migrate snapshot to device runtime * refactor: complete snapshot runtime policy cutover * test: enforce snapshot owner-facts admission * refactor: consolidate desktop snapshot capture * fix: scroll to visible iOS smoke targets * fix: close snapshot cutover alias bypasses * fix: constrain snapshot admission identity flow * fix: enforce snapshot admission through owner facts * fix: adapt replay source tests to snapshot runtime
65 lines
2.1 KiB
TypeScript
65 lines
2.1 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import { test } from 'node:test';
|
|
import { snapshotPlatformPolicyBranchViolations } from './runtime-command-cutover-snapshot.ts';
|
|
|
|
const ROUTE = 'src/daemon/snapshot-runtime.ts';
|
|
const BINDING = 'src/daemon/snapshot-runtime-binding.ts';
|
|
|
|
function violationsFor(route: string, binding = ''): string[] {
|
|
return snapshotPlatformPolicyBranchViolations(
|
|
new Map([
|
|
[ROUTE, route],
|
|
[BINDING, binding],
|
|
]),
|
|
).map(({ message }) => message);
|
|
}
|
|
|
|
const FACTS_FIRST_ROUTE = `
|
|
async function dispatchSnapshotViaRuntime(params) {
|
|
const plan = resolveSnapshotRuntimePlan(normalizedIntent);
|
|
const admission = await inspectRequiredRuntimeUse({
|
|
device,
|
|
use: plan.use,
|
|
inspectFacts: params.inspectFacts,
|
|
});
|
|
if (!admission.admitted) return unavailable(admission);
|
|
return bindSnapshotCaptureRuntime(params.bindDevice, device, plan);
|
|
}
|
|
`;
|
|
|
|
test('R32 accepts the normalized plan through the shared facts-first seam', () => {
|
|
assert.deepEqual(violationsFor(FACTS_FIRST_ROUTE), []);
|
|
});
|
|
|
|
test('R32 rejects a locally reimplemented admission policy, including object-wrapped identity', () => {
|
|
assert.deepEqual(
|
|
violationsFor(
|
|
`
|
|
async function dispatchSnapshotViaRuntime(params) {
|
|
const plan = resolveSnapshotRuntimePlan(normalizedIntent);
|
|
return inspectSnapshotCaptureAdmission(params, plan);
|
|
}
|
|
`,
|
|
`
|
|
function inspectSnapshotCaptureAdmission(device) {
|
|
const wrapped = { device };
|
|
if (wrapped.device.platform === 'apple') return { admitted: true };
|
|
}
|
|
`,
|
|
),
|
|
[
|
|
'snapshot route must admit exactly once through inspectRequiredRuntimeUse(device, plan.use, inspectFacts)',
|
|
'snapshot admission must not be reimplemented beside the shared facts seam',
|
|
],
|
|
);
|
|
});
|
|
|
|
test('R32 rejects an admission call not coupled to the selected plan use', () => {
|
|
assert.deepEqual(
|
|
violationsFor(FACTS_FIRST_ROUTE.replace('use: plan.use', 'use: captureSnapshotUse')),
|
|
[
|
|
'snapshot route must admit exactly once through inspectRequiredRuntimeUse(device, plan.use, inspectFacts)',
|
|
],
|
|
);
|
|
});
|