mirror of
https://github.com/callstack/agent-device.git
synced 2026-09-14 20:06:34 +08:00
1f9d940bff
* refactor(capture-kit): relocate snapshot and recording zones into capture-kit
Move the ADR 0019 end-state capture zones into @agent-device/capture-kit:
- src/snapshot/** -> packages/capture-kit/src/snapshot/** (presentation,
freshness, scroll-edge-state, ios-snapshot-runtime, android occlusion)
- src/recording/** -> packages/capture-kit/src/recording/**
- src/core/snapshot-{chrome,state,tree-ingestion,node-lookup}.ts ->
packages/capture-kit/src/
- src/snapshot-quality/ test -> capture-kit presentation tree (directory
retires with its last file)
Pure renames: import re-pointing and gate updates follow in the next commit.
The snapshot-desktop-surface test parks in src/__tests__/ because it pins
the root eager-import-closure walker.
* refactor(capture-kit): re-point capture and recording consumers to the new subpaths
Rewires every consumer of the relocated snapshot/recording modules to the new @agent-device/capture-kit subpath exports, adds the 23 subpath entries to the capture-kit exports map, fixes the moved recording-scripts test's __dirname-relative paths for the deeper location, and records the completed migration in ADR 0019's end state.
* chore(gates): align layering, mutation, fallow and CI gates with the capture-kit relocation
Moves the executable-policy roots, presentation-owner constant, zone ranks, authority fixture, mutation sharding globs, stryker aliases, fallow baselines and the iOS workflow's android-owned paths-ignore entry onto the new packages/capture-kit paths, and extends the planted-red coverage to the new presentation-owner subpath.
* chore: point capture-domain source-of-truth comments at the relocated capture-kit modules
* test: point shutdown recording mock at capture-kit and cover interactor acquisition presentation
* test(capture-kit): update upstream presentation test imports
* chore(gates): follow relocated snapshot assembly in R74
* test(daemon): freeze prewarm deadline assertion clocks
105 lines
3.2 KiB
TypeScript
105 lines
3.2 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import { test } from 'node:test';
|
|
import {
|
|
IOS_SNAPSHOT_PRESENTATION_OWNER,
|
|
PROVIDER_SNAPSHOT_PRESENTATION_RULE,
|
|
providerSnapshotPresentationViolations,
|
|
} from './provider-snapshot-presentation-policy.ts';
|
|
import { resolveImportEdges } from './model.ts';
|
|
import { workspaceSpecifierTargets } from './package-boundaries.ts';
|
|
import { listTrackedProductionSources } from './tracked-sources.ts';
|
|
|
|
const repoRoot = path.resolve(import.meta.dirname, '../..');
|
|
const providerHelper = 'packages/provider-webdriver/src/provider-snapshot-helper.ts';
|
|
|
|
function currentSources(overrides: ReadonlyMap<string, string> = new Map()): Map<string, string> {
|
|
const sources = new Map(
|
|
listTrackedProductionSources(repoRoot).map((file) => [
|
|
file,
|
|
fs.readFileSync(path.join(repoRoot, file), 'utf8'),
|
|
]),
|
|
);
|
|
for (const [file, source] of overrides) sources.set(file, source);
|
|
return sources;
|
|
}
|
|
|
|
function violations(overrides: ReadonlyMap<string, string> = new Map()) {
|
|
const sources = currentSources(overrides);
|
|
return providerSnapshotPresentationViolations(
|
|
sources,
|
|
resolveImportEdges(sources, workspaceSpecifierTargets(repoRoot)),
|
|
);
|
|
}
|
|
|
|
test('provider packages use the acquisition entrypoint and cannot reach presentation', () => {
|
|
assert.deepEqual(violations(), []);
|
|
});
|
|
|
|
test('R73 rejects an out-of-adapter provider presentation import', () => {
|
|
const result = violations(
|
|
new Map([
|
|
[
|
|
providerHelper,
|
|
`import { presentIosSnapshot } from '@agent-device/capture-kit/ios-snapshot-engine';\nvoid presentIosSnapshot;\n`,
|
|
],
|
|
]),
|
|
);
|
|
assert.ok(
|
|
result.some(
|
|
(entry) =>
|
|
entry.rule === PROVIDER_SNAPSHOT_PRESENTATION_RULE &&
|
|
entry.file === providerHelper &&
|
|
entry.message.includes(IOS_SNAPSHOT_PRESENTATION_OWNER),
|
|
),
|
|
JSON.stringify(result),
|
|
);
|
|
});
|
|
|
|
test('R73 rejects a provider import of the capture-kit presentation runtime subpath', () => {
|
|
const result = violations(
|
|
new Map([
|
|
[
|
|
providerHelper,
|
|
`import { presentIosSnapshot } from '@agent-device/capture-kit/ios-snapshot-runtime';\nvoid presentIosSnapshot;\n`,
|
|
],
|
|
]),
|
|
);
|
|
assert.ok(
|
|
result.some(
|
|
(entry) =>
|
|
entry.rule === PROVIDER_SNAPSHOT_PRESENTATION_RULE &&
|
|
entry.file === providerHelper &&
|
|
entry.message.includes(IOS_SNAPSHOT_PRESENTATION_OWNER),
|
|
),
|
|
JSON.stringify(result),
|
|
);
|
|
});
|
|
|
|
for (const planted of [
|
|
{
|
|
name: 'a planted provider residue discard',
|
|
source: 'export const discarded = { residue: [] };\n',
|
|
message: 'construct or discard acquisition residue',
|
|
},
|
|
{
|
|
name: 'a planted provider residue rewrite',
|
|
source: 'export function rewrite(carrier) { carrier.acquisition.residue = []; }\n',
|
|
message: 'rewrite acquisition residue',
|
|
},
|
|
]) {
|
|
test(`R73 rejects ${planted.name}`, () => {
|
|
const result = violations(new Map([[providerHelper, planted.source]]));
|
|
assert.ok(
|
|
result.some(
|
|
(entry) =>
|
|
entry.rule === PROVIDER_SNAPSHOT_PRESENTATION_RULE &&
|
|
entry.file === providerHelper &&
|
|
entry.message.includes(planted.message),
|
|
),
|
|
JSON.stringify(result),
|
|
);
|
|
});
|
|
}
|