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
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
|
|
import type { CliJsonResult } from './cli-json.ts';
|
|
import { searchForVisibleElement } from './ios-simulator-e2e/live-assertions.ts';
|
|
|
|
function result(status: number, details?: Record<string, unknown>): CliJsonResult {
|
|
return {
|
|
json: details === undefined ? undefined : { error: { details } },
|
|
status,
|
|
stderr: '',
|
|
stdout: '',
|
|
};
|
|
}
|
|
|
|
test('an existing offscreen element scrolls until the visibility probe passes', async () => {
|
|
const probes = [result(1), result(0)];
|
|
const probeAttempts: number[] = [];
|
|
const scrollAttempts: number[] = [];
|
|
|
|
await searchForVisibleElement(
|
|
'id="automation-longpress"',
|
|
async (attempt) => {
|
|
probeAttempts.push(attempt);
|
|
return probes.shift() ?? result(1);
|
|
},
|
|
async (attempt) => {
|
|
scrollAttempts.push(attempt);
|
|
},
|
|
);
|
|
|
|
assert.deepEqual(probeAttempts, [1, 2]);
|
|
assert.deepEqual(scrollAttempts, [1]);
|
|
});
|
|
|
|
test('a stalled capture retries without scrolling or consuming an attempt', async () => {
|
|
const probes = [result(1, { captureStalled: true }), result(0)];
|
|
const probeAttempts: number[] = [];
|
|
const scrollAttempts: number[] = [];
|
|
|
|
await searchForVisibleElement(
|
|
'id="automation-longpress"',
|
|
async (attempt) => {
|
|
probeAttempts.push(attempt);
|
|
return probes.shift() ?? result(1);
|
|
},
|
|
async (attempt) => {
|
|
scrollAttempts.push(attempt);
|
|
},
|
|
);
|
|
|
|
assert.deepEqual(probeAttempts, [1, 1]);
|
|
assert.deepEqual(scrollAttempts, []);
|
|
});
|