Skip to content

Commit c7236cb

Browse files
committed
fix(maestro): the snapshot signature weighs checked, so a toggle tap is not a no-op to retap
maestroSnapshotSignature hashed label, value, enabled, selected, focused and bounds; a switch, checkbox or radio whose only observable effect is its checked state produced the same signature before and after the tap, so the settle and the no-change retry read the tap as a no-op and could tap it back. checked joins the hashed object the way the interaction outcome key already weighs it.
1 parent 4be8eba commit c7236cb

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

‎packages/maestro/src/daemon-port/__tests__/daemon-runtime-port-observation.test.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,12 +359,26 @@ test('normalizes absent attributes like Maestro iOS hierarchy mapping', () => {
359359
enabled: false,
360360
selected: false,
361361
focused: false,
362+
checked: false,
362363
},
363364
]);
364365

365366
expect(maestroSnapshotSignature(first)).toBe(maestroSnapshotSignature(second));
366367
});
367368

369+
test('a checked-only flip changes the snapshot signature', () => {
370+
// An Android switch tapped on: nothing about it moves or renames, only `checked` flips. The
371+
// same signature before and after would read the tap as a no-op and retap it off again.
372+
const off = makeSnapshot([
373+
{ index: 0, type: 'android.widget.Switch', label: 'Wi-Fi', checked: false },
374+
]);
375+
const on = makeSnapshot([
376+
{ index: 0, type: 'android.widget.Switch', label: 'Wi-Fi', checked: true },
377+
]);
378+
379+
expect(maestroSnapshotSignature(off)).not.toBe(maestroSnapshotSignature(on));
380+
});
381+
368382
test('excludes agent-device presentation metadata from Maestro hierarchy signatures', () => {
369383
const first = makeSnapshot([
370384
{

‎packages/maestro/src/daemon-port/daemon-runtime-port-observation.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,9 @@ export function maestroSnapshotSignature(snapshot: SnapshotState): string {
408408
enabled: node.enabled ?? false,
409409
selected: node.selected ?? false,
410410
focused: node.focused ?? false,
411+
// A toggle whose only observable effect is its checked state must not read as a no-op:
412+
// the tap settle and the no-change retap both compare this signature.
413+
checked: node.checked ?? false,
411414
bounds: maestroSnapshotBounds(node.rect),
412415
})),
413416
),

0 commit comments

Comments
 (0)