Skip to content

Commit f93d8ea

Browse files
committed
test(android): assert typed reason of a zero-exit helper failure
1 parent da59b7a commit f93d8ea

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎packages/platform-android/src/__tests__/snapshot-helper-capture.test.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import assert from 'node:assert/strict';
22
import { beforeEach, test } from 'vitest';
3+
import { readAndroidCaptureFailureReason } from '@agent-device/contracts/android-snapshot-quality';
34
import { AppError } from '@agent-device/kernel/errors';
45
import { captureAndroidSnapshotWithHelper } from '../snapshot-helper-capture.ts';
56
import { resetAndroidSnapshotHelperRetirements } from '../snapshot-helper-retirement.ts';
@@ -140,8 +141,8 @@ test('a helper failure reported under a zero am exit status keeps its own reason
140141
exitCode: 0,
141142
stdout: [
142143
'INSTRUMENTATION_RESULT: agentDeviceProtocol=android-snapshot-helper-v1',
143-
'INSTRUMENTATION_RESULT: errorType=com.callstack.agentdevice.snapshothelper.AccessibilityCaptureStabilizer$IncompleteCaptureException',
144-
'INSTRUMENTATION_RESULT: message=Android accessibility capture remained incomplete after 500 ms',
144+
'INSTRUMENTATION_RESULT: errorType=java.util.concurrent.TimeoutException',
145+
'INSTRUMENTATION_RESULT: message=Timed out waiting for the accessibility hierarchy',
145146
'INSTRUMENTATION_RESULT: ok=false',
146147
'INSTRUMENTATION_CODE: 1',
147148
].join('\n'),
@@ -153,8 +154,8 @@ test('a helper failure reported under a zero am exit status keeps its own reason
153154
captureAndroidSnapshotWithHelper({ adb, deviceKey: 'android:emulator-5554' }),
154155
(error: unknown) =>
155156
error instanceof AppError &&
156-
error.message === 'Android accessibility capture remained incomplete after 500 ms' &&
157-
typeof error.details?.helper === 'object',
157+
readAndroidCaptureFailureReason(error) === 'accessibility-timeout' &&
158+
error.details?.errorType === 'java.util.concurrent.TimeoutException',
158159
);
159160
});
160161

0 commit comments

Comments
 (0)