Skip to content

Commit 7af8e5c

Browse files
committed
test: align maestro input provider guard
1 parent ba3308e commit 7af8e5c

3 files changed

Lines changed: 32 additions & 35 deletions

File tree

src/compat/maestro/__tests__/replay-flow.test.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ test('parseMaestroReplayFlow keeps focused inputText and pressKey Enter as separ
223223
assert.deepEqual(parsed.actionLines, [3, 4, 5]);
224224
});
225225

226-
test('parseMaestroReplayFlow coalesces tapOn inputText without requiring Enter', () => {
226+
test('parseMaestroReplayFlow marks tapOn before inputText for snapshot tap focus', () => {
227227
const parsed = parseMaestroReplayFlow(`appId: com.callstack.agentdevicelab
228228
---
229229
- tapOn:
@@ -234,12 +234,11 @@ test('parseMaestroReplayFlow coalesces tapOn inputText without requiring Enter',
234234
assert.deepEqual(
235235
parsed.actions.map((entry) => [entry.command, entry.positionals]),
236236
[
237-
['wait', ['id="editableNameInput"', '30000']],
238-
['fill', ['id="editableNameInput"', 'Saved list']],
237+
['__maestroTapOn', ['id="editableNameInput"']],
238+
['type', ['Saved list']],
239239
],
240240
);
241-
assert.deepEqual(parsed.actionLines, [3, 3]);
242-
assert.equal(parsed.actions[1]?.flags?.maestro?.allowNonHittableCoordinateFallback, true);
241+
assert.equal(parsed.actions[0]?.flags?.maestro?.allowNonHittableCoordinateFallback, undefined);
243242
});
244243

245244
test('parseMaestroReplayFlow coalesces tapOn inputText while preserving pressKey Enter submit', () => {
@@ -659,10 +658,10 @@ test('parseMaestroReplayFlow parses the test-app Maestro suite fixture', () => {
659658
'__maestroAssertVisible',
660659
'__maestroTapOn',
661660
'__maestroAssertVisible',
662-
'wait',
663-
'fill',
664-
'wait',
665-
'fill',
661+
'__maestroTapOn',
662+
'type',
663+
'__maestroTapOn',
664+
'type',
666665
'__maestroTapOn',
667666
'__maestroAssertVisible',
668667
'__maestroAssertVisible',

src/compat/maestro/replay-flow.ts

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -113,32 +113,27 @@ function optimizeTypedAfterTap(
113113
if (!isLikelyTextEntrySelector(tapSelector)) {
114114
return { actions: [clearMaestroNonHittableTap(action)], actionLines: [line], consumed: 1 };
115115
}
116-
const fillActions: SessionAction[] = [
117-
{
118-
...action,
119-
command: 'wait',
120-
positionals: [tapSelector, '30000'],
121-
},
122-
{
123-
...nextAction,
124-
command: 'fill',
125-
positionals: [tapSelector, typedAfterTap],
126-
flags: action.flags,
127-
},
128-
];
129-
const fillActionLines = [line, line];
130116
const pressEnterAction = actions[index + 2];
131-
if (pressEnterAction?.command === MAESTRO_RUNTIME_COMMAND.pressEnter) {
132-
return {
133-
actions: [...fillActions, pressEnterAction],
134-
actionLines: [...fillActionLines, actionLines[index + 2] ?? line],
135-
consumed: 3,
136-
};
117+
if (pressEnterAction?.command !== MAESTRO_RUNTIME_COMMAND.pressEnter) {
118+
return { actions: [clearMaestroNonHittableTap(action)], actionLines: [line], consumed: 1 };
137119
}
138120
return {
139-
actions: fillActions,
140-
actionLines: fillActionLines,
141-
consumed: 2,
121+
actions: [
122+
{
123+
...action,
124+
command: 'wait',
125+
positionals: [tapSelector, '30000'],
126+
},
127+
{
128+
...nextAction,
129+
command: 'fill',
130+
positionals: [tapSelector, typedAfterTap],
131+
flags: action.flags,
132+
},
133+
pressEnterAction,
134+
],
135+
actionLines: [line, line, actionLines[index + 2] ?? line],
136+
consumed: 3,
142137
};
143138
}
144139

test/integration/provider-scenarios/android-test-suite.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ test('Provider-backed integration Android Maestro replay test suite discovers YA
172172
);
173173
});
174174

175-
test('Provider-backed integration Android Maestro fills tapOn inputText without trailing Enter', async () => {
175+
test('Provider-backed integration Android Maestro types after tapOn inputText without trailing Enter', async () => {
176176
await withProviderScenarioResource(
177177
async () => await createAndroidSettingsWorld({ nativeTextInjection: true }),
178178
async (world) => {
@@ -205,12 +205,15 @@ test('Provider-backed integration Android Maestro fills tapOn inputText without
205205
assert.equal(suite.failed, 0, JSON.stringify(suite));
206206
assert.deepEqual(world.textInjectionCalls, [
207207
{
208-
action: 'fill',
209-
target: { x: 195, y: 52 },
208+
action: 'type',
210209
text: 'Łódź café',
211210
delayMs: 0,
212211
},
213212
]);
213+
assert.deepEqual(
214+
world.adbCalls.find((call) => call.slice(0, 3).join(' ') === 'shell input tap'),
215+
['shell', 'input', 'tap', '195', '52'],
216+
);
214217
assert.equal(
215218
world.adbCalls.some(
216219
(call) => call[0] === 'shell' && call[1] === 'input' && call[2] === 'text',

0 commit comments

Comments
 (0)