Skip to content

Commit 3682be6

Browse files
committed
fix: make helper-backed CI deterministic
1 parent 7352d32 commit 3682be6

16 files changed

Lines changed: 62 additions & 71 deletions

File tree

apple-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ extension RunnerTests {
263263
}
264264
let command = try runnerCommandFixture(
265265
"""
266-
{"command":"gesture","commandId":"gesture-fling-fallback","gesturePlan":{"topology":"single","intent":"fling","durationMs":100,"viewport":{"x":0,"y":0,"width":200,"height":300},"pointers":[{"pointerId":0,"samples":[{"offsetMs":0,"point":{"x":160,"y":150}},{"offsetMs":100,"point":{"x":40,"y":150}}]}]}}
266+
{"command":"gesture","commandId":"gesture-fling-fallback","gesturePlan":{"topology":"single","intent":"fling","executionProfile":"endpoint-hold","durationMs":100,"viewport":{"x":0,"y":0,"width":200,"height":300},"pointers":[{"pointerId":0,"samples":[{"offsetMs":0,"point":{"x":160,"y":150}},{"offsetMs":100,"point":{"x":40,"y":150}}]}]}}
267267
"""
268268
)
269269

src/__tests__/test-utils/android-snapshot-helper.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,31 @@
11
import type { AndroidAdbExecutor } from '../../platforms/android/adb-executor.ts';
2+
import type { AndroidSnapshotHelperArtifact } from '../../platforms/android/snapshot-helper-types.ts';
3+
import { fileURLToPath } from 'node:url';
24

35
const SNAPSHOT_HELPER_PACKAGE = 'com.callstack.agentdevice.snapshothelper';
6+
const SNAPSHOT_HELPER_FIXTURE_APK_PATH = fileURLToPath(
7+
new URL('./fixtures/android-helper-apk.fixture', import.meta.url),
8+
);
9+
const SNAPSHOT_HELPER_FIXTURE_APK_SHA256 =
10+
'a5f6a2fba1163bba2f13026bd3a192f52ba2816524b7cfa83c6b7ca568f6710a';
11+
12+
export const ANDROID_SNAPSHOT_HELPER_FIXTURE_ARTIFACT: AndroidSnapshotHelperArtifact = {
13+
apkPath: SNAPSHOT_HELPER_FIXTURE_APK_PATH,
14+
manifest: {
15+
name: 'android-snapshot-helper',
16+
version: '0.13.3',
17+
apkUrl: null,
18+
sha256: SNAPSHOT_HELPER_FIXTURE_APK_SHA256,
19+
packageName: SNAPSHOT_HELPER_PACKAGE,
20+
versionCode: 13003,
21+
instrumentationRunner: `${SNAPSHOT_HELPER_PACKAGE}/.SnapshotInstrumentation`,
22+
minSdk: 23,
23+
targetSdk: 36,
24+
outputFormat: 'uiautomator-xml',
25+
statusProtocol: 'android-snapshot-helper-v1',
26+
installArgs: ['install', '-r', '-t'],
27+
},
28+
};
429

530
export function createAndroidSnapshotHelperExecutor(options: {
631
readonly exec: AndroidAdbExecutor;

src/platforms/android/__tests__/fixtures/helper-apk.fixture renamed to src/__tests__/test-utils/fixtures/android-helper-apk.fixture

File renamed without changes.

src/__tests__/test-utils/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export {
2121
export { makeSnapshotState } from './snapshot-builders.ts';
2222

2323
export {
24+
ANDROID_SNAPSHOT_HELPER_FIXTURE_ARTIFACT,
2425
androidSnapshotHelperOutput,
2526
createAndroidSnapshotHelperExecutor,
2627
isAndroidSnapshotHelperCapture,

src/compat/maestro/support-matrix.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ export const MAESTRO_COMPAT_SUPPORTED_CAPABILITIES = [
1818

1919
export const MAESTRO_COMPAT_TRACKER_URL = 'https://github.com/callstack/agent-device/issues/558';
2020

21-
export const MAESTRO_NEW_ISSUE_URL = 'https://github.com/callstack/agent-device/issues/new';
22-
2321
export function formatMaestroSupportedSubsetForCli(): string {
2422
return `Supported subset: ${formatMaestroCapabilityList(MAESTRO_COMPAT_SUPPORTED_CAPABILITIES)}.`;
2523
}

src/contracts/scroll-gesture.test.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
buildInPageSwipeGesturePlan,
77
buildScrollGesturePlan,
88
clampGestureCoordinate,
9-
pointFromPercentInFrame,
109
} from './scroll-gesture.ts';
1110

1211
test('buildInPageSwipeGesturePlan applies one inset lane policy in every direction', () => {
@@ -201,14 +200,6 @@ test('assertScrollGestureInput rejects non-positive or non-finite pixels', () =>
201200
}
202201
});
203202

204-
test('pointFromPercentInFrame preserves authored percentages within valid pixel bounds', () => {
205-
const frame = { referenceWidth: 400, referenceHeight: 800 };
206-
207-
assert.deepEqual(pointFromPercentInFrame(frame, 10, 30), { x: 40, y: 240 });
208-
assert.deepEqual(pointFromPercentInFrame(frame, 100, 0), { x: 399, y: 0 });
209-
assert.deepEqual(pointFromPercentInFrame(frame, -10, 100), { x: 0, y: 799 });
210-
});
211-
212203
test('clampGestureCoordinate rounds values and clamps them into the safe gesture band', () => {
213204
assert.equal(clampGestureCoordinate(10.4, 8, 100), 10);
214205
assert.equal(clampGestureCoordinate(10.6, 8, 100), 11);

src/contracts/scroll-gesture.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -247,19 +247,6 @@ function pointFromPercent(
247247
};
248248
}
249249

250-
export function pointFromPercentInFrame(
251-
frame: GestureReferenceFrame,
252-
xPercent: number,
253-
yPercent: number,
254-
): GesturePoint {
255-
const point = pointFromPercent(frame, xPercent, yPercent);
256-
// Frame dimensions are exclusive upper bounds for zero-based input coordinates.
257-
return {
258-
x: clampToRange(point.x, 0, Math.max(0, Math.round(frame.referenceWidth) - 1)),
259-
y: clampToRange(point.y, 0, Math.max(0, Math.round(frame.referenceHeight) - 1)),
260-
};
261-
}
262-
263250
function clampGesturePoint(
264251
point: GesturePoint,
265252
frame: GestureReferenceFrame,

src/platforms/android/__tests__/android-helper-artifact.fixtures.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/platforms/android/__tests__/ime-lifecycle.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ const PENDING_DIR = 'android-test-ime-pending';
1212
// the suite passes on a fresh checkout that hasn't packaged android-ime-helper/dist (CI Coverage).
1313
vi.mock('../ime-helper.ts', async (importOriginal) => {
1414
const actual = await importOriginal<typeof import('../ime-helper.ts')>();
15-
const fixture = await import('./android-helper-artifact.fixtures.ts');
15+
const fixture = await import('../../../__tests__/test-utils/android-snapshot-helper.ts');
1616
return {
1717
...actual,
1818
resolveAndroidImeHelperArtifact: vi.fn(async () => ({
19-
apkPath: fixture.ANDROID_HELPER_FIXTURE_APK_PATH,
19+
apkPath: fixture.ANDROID_SNAPSHOT_HELPER_FIXTURE_ARTIFACT.apkPath,
2020
manifest: {
2121
name: 'android-ime-helper' as const,
2222
version: '0.0.0',
2323
assetName: 'helper.apk',
24-
sha256: fixture.ANDROID_HELPER_FIXTURE_APK_SHA256,
24+
sha256: fixture.ANDROID_SNAPSHOT_HELPER_FIXTURE_ARTIFACT.manifest.sha256,
2525
packageName: 'com.callstack.agentdevice.imehelper',
2626
versionCode: 1,
2727
serviceComponent: HELPER_SERVICE,

src/platforms/android/__tests__/input-actions-fill.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { test } from 'vitest';
22
import assert from 'node:assert/strict';
33
import {
44
ANDROID_EMULATOR,
5+
ANDROID_SNAPSHOT_HELPER_FIXTURE_ARTIFACT,
56
createAndroidSnapshotHelperExecutor,
67
} from '../../../__tests__/test-utils/index.ts';
78
import { AppError } from '../../../kernel/errors.ts';
@@ -180,6 +181,7 @@ test('fillAndroid delegates target replacement to provider-native text injection
180181
let value = '';
181182
await withAndroidAdbProvider(
182183
{
184+
snapshotHelperArtifact: ANDROID_SNAPSHOT_HELPER_FIXTURE_ARTIFACT,
183185
exec: createAndroidSnapshotHelperExecutor({
184186
exec: async (args) => {
185187
throw new Error(`unexpected adb call: ${args.join(' ')}`);
@@ -376,7 +378,10 @@ async function withFillAdb(
376378
};
377379
const fn = maybeFn ?? (captureXmlOrFn as () => Promise<void>);
378380
await withAndroidAdbProvider(
379-
{ exec: createAndroidSnapshotHelperExecutor({ exec, captureXml }) },
381+
{
382+
exec: createAndroidSnapshotHelperExecutor({ exec, captureXml }),
383+
snapshotHelperArtifact: ANDROID_SNAPSHOT_HELPER_FIXTURE_ARTIFACT,
384+
},
380385
{ serial: ANDROID_EMULATOR.id },
381386
fn,
382387
);

0 commit comments

Comments
 (0)