Skip to content

Commit 4691e5e

Browse files
committed
test(replay): validate drag fixture selectors
1 parent 8322a70 commit 4691e5e

3 files changed

Lines changed: 28 additions & 2 deletions

File tree

examples/test-app/replays/drag-android.ad

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ wait "Gesture lab" 30000
99
wait "gesture canary ready" 5000
1010
wait "drag completed no" 5000
1111

12-
gesture drag 'id="drag-source"' 'id="drag-destination"' 600 500 0
12+
gesture drag id="drag-source" id="drag-destination" 600 500 0
1313
wait "drag completed yes" 5000
1414

1515
close

examples/test-app/replays/drag.ad

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ wait "Gesture lab" 30000
88
wait "gesture canary ready" 5000
99
wait "drag completed no" 5000
1010

11-
gesture drag 'id="drag-source"' 'id="drag-destination"' 600 500 0
11+
gesture drag id="drag-source" id="drag-destination" 600 500 0
1212
wait "drag completed yes" 5000
1313

1414
close

test/integration/smoke-ios-simulator-coverage.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
unsupportedHintForDevice,
1717
} from '../../src/core/capabilities.ts';
1818
import { parseReplayScriptDetailed } from '@agent-device/ad-script';
19+
import { isValidSelectorExpression } from '@agent-device/selectors';
1920
import { IOS_SIMULATOR_BEHAVIOR_COVERAGE } from './ios-simulator-e2e/behavior-coverage.ts';
2021
import {
2122
IOS_SIMULATOR_E2E_COVERAGE,
@@ -207,6 +208,31 @@ test('fixture replay gestures fit the smallest supported iPhone viewport', () =>
207208
for (const replayPath of replayPaths) assertReplayFitsViewports(replayPath, compactViewports);
208209
});
209210

211+
test('drag replay fixtures use parseable source and destination selectors', () => {
212+
const replayPaths = [
213+
'examples/test-app/replays/drag.ad',
214+
'examples/test-app/replays/drag-android.ad',
215+
];
216+
217+
for (const replayPath of replayPaths) {
218+
const drag = parseReplayScriptDetailed(fs.readFileSync(replayPath, 'utf8')).actions.find(
219+
(action) => action.command === 'gesture' && action.positionals?.[0] === 'drag',
220+
);
221+
assert.ok(drag, `${replayPath} must contain a drag gesture`);
222+
223+
const source = drag.positionals?.[1];
224+
const destination = drag.positionals?.[2];
225+
assert.ok(
226+
source && isValidSelectorExpression(source),
227+
`${replayPath} source must be a selector`,
228+
);
229+
assert.ok(
230+
destination && isValidSelectorExpression(destination),
231+
`${replayPath} destination must be a selector`,
232+
);
233+
}
234+
});
235+
210236
test('fixture navigation uses edge-aware traversal without losing direct swipe evidence', () => {
211237
const actions = parseReplayScriptDetailed(
212238
fs.readFileSync('test/integration/replays/ios/fixture/01-navigation-scroll.ad', 'utf8'),

0 commit comments

Comments
 (0)