Files
callstack__agent-device/src/platform-runtime-android-deployment-executor.test.ts
Michał Pierzchała c7f42ccedc refactor: move Android family behind package exports (#2117)
* refactor: move Android family behind package exports

* fix: address Android W5 review feedback

* fix: update relocated routing fixture assertion
2026-08-28 13:02:28 +02:00

45 lines
1.6 KiB
TypeScript

import { expect, test, vi } from 'vitest';
import type { DeviceInfo } from '@agent-device/kernel/device';
const resolveAndroidApp = vi.hoisted(() => vi.fn());
vi.mock('@agent-device/platform-android/mechanics', () => ({
resolveAndroidApp,
withAndroidAppResolutionCacheInvalidated: async <Result>(
_device: DeviceInfo,
operation: () => Promise<Result>,
) => await operation(),
}));
import { createAndroidAppDeploymentExecutor } from './platform-runtime-android-deployment-executor.ts';
const device: DeviceInfo = {
platform: 'android',
id: 'android-executor',
name: 'Android executor',
kind: 'emulator',
target: 'mobile',
booted: true,
};
test('keeps root composition limited to artifact preparation and app identity resolution', async () => {
resolveAndroidApp.mockResolvedValueOnce({ type: 'package', value: 'com.example.app' });
const executor = createAndroidAppDeploymentExecutor();
await expect(executor.resolveAppPackage(device, 'Example')).resolves.toBe('com.example.app');
expect(resolveAndroidApp).toHaveBeenCalledWith(device, 'Example');
expect(Object.keys(executor).sort()).toEqual([
'bundletoolJar',
'prepareArtifact',
'resolveAppPackage',
'withInvalidatedAppResolutionCache',
]);
});
test('rejects an intent where uninstall requires an exact Android package', async () => {
resolveAndroidApp.mockResolvedValueOnce({ type: 'intent', value: 'example.intent' });
await expect(
createAndroidAppDeploymentExecutor().resolveAppPackage(device, 'example.intent'),
).rejects.toMatchObject({ code: 'INVALID_ARGS' });
});