Skip to content

Commit d9f43ff

Browse files
committed
test(ios): preserve origin and readiness facts through snapshot clones
1 parent da16cba commit d9f43ff

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

‎packages/command-runtime/src/commands/interaction/runtime/__tests__/test-utils/index.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ export function createInteractionDevice(
352352
| 'longPress'
353353
| 'scroll'
354354
| 'performGesture'
355+
| 'readPressReadiness'
355356
| 'confirmOffscreenTargetVisible'
356357
>
357358
> & {
@@ -383,6 +384,7 @@ export function createInteractionDevice(
383384
: undefined,
384385
scroll: overrides.scroll ? async (...args) => await overrides.scroll?.(...args) : undefined,
385386
performGesture: overrides.performGesture,
387+
readPressReadiness: overrides.readPressReadiness,
386388
// #1542: undefined by default, so every existing test keeps proving the
387389
// fail-closed refusal unchanged; only tests that opt in exercise the
388390
// rescue/agreement paths.

‎packages/command-runtime/src/commands/interaction/runtime/target-visibility-stages-screen-origin.test.ts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ function geometrySnapshot(kind: IosViewportEvidence['kind']) {
2626
label: 'Geometry action',
2727
rect: { x: root.x + 240, y: root.y + 90, width: 220, height: 42 },
2828
hittable: true,
29+
nativePressTarget: {
30+
type: 9,
31+
identifier: 'geometry-action',
32+
label: 'Geometry action',
33+
rect: { x: root.x + 240, y: root.y + 90, width: 220, height: 42 },
34+
},
2935
},
3036
];
3137
attachSnapshotViewportEvidence(
@@ -126,6 +132,10 @@ for (const kind of ['derived', 'missing'] as const) {
126132
const calls: unknown[] = [];
127133
const snapshot = geometrySnapshot(kind);
128134
const device = createInteractionDevice(snapshot, {
135+
readPressReadiness: async () => {
136+
calls.push('readiness');
137+
return 'ready';
138+
},
129139
tap: async (_context, point) => {
130140
calls.push(point);
131141
},
@@ -158,20 +168,35 @@ for (const kind of ['derived', 'missing'] as const) {
158168

159169
test('reported screen geometry still activates the resolved selector and saved ref', async () => {
160170
const taps: Point[] = [];
171+
const readinessTargets: unknown[] = [];
161172
const device = createInteractionDevice(geometrySnapshot('reported'), {
173+
readPressReadiness: async (_context, target) => {
174+
readinessTargets.push(target);
175+
return 'ready';
176+
},
162177
tap: async (_context, point) => {
163178
taps.push(point);
164179
},
165180
});
166181
const observed = await device.capture.snapshot({ session: 'default' });
167182
const target = observed.nodes.find((node) => node.identifier === 'geometry-action');
168183
assert.ok(target?.ref);
184+
assert.equal('nativePressTarget' in target, false);
169185
await device.interactions.press(selector('id=geometry-action'), { session: 'default' });
170186
await device.interactions.press(ref(`@${target.ref}`), { session: 'default' });
171187
assert.deepEqual(taps, [
172188
{ x: 591, y: 335 },
173189
{ x: 591, y: 335 },
174190
]);
191+
assert.equal(readinessTargets.length, 2);
192+
for (const binding of readinessTargets) {
193+
assert.deepEqual(binding, {
194+
type: 9,
195+
identifier: 'geometry-action',
196+
label: 'Geometry action',
197+
rect: { x: 481, y: 314, width: 220, height: 42 },
198+
});
199+
}
175200
});
176201

177202
test('unknown capture authority refuses before an offscreen rescue can replace geometry', async () => {

0 commit comments

Comments
 (0)