mirror of
https://github.com/callstack/agent-device.git
synced 2026-09-14 20:06:34 +08:00
d77a9211ab
* feat: add android snapshot helper * fix: harden android snapshot helper packaging * fix: harden android xml attribute parsing * fix: capture android helper window roots * fix: validate android helper install args * fix: harden android helper manifest and traversal * refactor: drop unused helper timeout parameter * feat: bundle android snapshot helper in npm package * feat: enable bundled android snapshot helper by default * refactor: simplify android snapshot helper resolution * fix: harden android snapshot helper artifacts * refactor: split android snapshot helper modules * fix: use type-only snapshot helper imports
133 lines
3.0 KiB
TypeScript
133 lines
3.0 KiB
TypeScript
import { test } from 'vitest';
|
|
import assert from 'node:assert/strict';
|
|
import {
|
|
serializeInstallFromSourceResult,
|
|
serializeOpenResult,
|
|
serializeSnapshotResult,
|
|
serializeSessionListEntry,
|
|
} from '../client-shared.ts';
|
|
|
|
test('serializeSessionListEntry preserves legacy android session payload shape', () => {
|
|
const data = serializeSessionListEntry({
|
|
name: 'qa',
|
|
createdAt: 123,
|
|
device: {
|
|
platform: 'android',
|
|
target: 'mobile',
|
|
id: 'emulator-5554',
|
|
name: 'Pixel 9',
|
|
identifiers: {
|
|
session: 'qa',
|
|
deviceId: 'emulator-5554',
|
|
deviceName: 'Pixel 9',
|
|
serial: 'emulator-5554',
|
|
},
|
|
android: {
|
|
serial: 'emulator-5554',
|
|
},
|
|
},
|
|
identifiers: {
|
|
session: 'qa',
|
|
deviceId: 'emulator-5554',
|
|
deviceName: 'Pixel 9',
|
|
serial: 'emulator-5554',
|
|
},
|
|
});
|
|
|
|
assert.deepEqual(data, {
|
|
name: 'qa',
|
|
platform: 'android',
|
|
target: 'mobile',
|
|
device: 'Pixel 9',
|
|
id: 'emulator-5554',
|
|
createdAt: 123,
|
|
});
|
|
});
|
|
|
|
test('serializeOpenResult includes android serial for open payloads', () => {
|
|
const data = serializeOpenResult({
|
|
session: 'qa',
|
|
device: {
|
|
platform: 'android',
|
|
target: 'mobile',
|
|
id: 'emulator-5554',
|
|
name: 'Pixel 9',
|
|
identifiers: {
|
|
session: 'qa',
|
|
deviceId: 'emulator-5554',
|
|
deviceName: 'Pixel 9',
|
|
serial: 'emulator-5554',
|
|
},
|
|
android: {
|
|
serial: 'emulator-5554',
|
|
},
|
|
},
|
|
identifiers: {
|
|
session: 'qa',
|
|
deviceId: 'emulator-5554',
|
|
deviceName: 'Pixel 9',
|
|
serial: 'emulator-5554',
|
|
},
|
|
});
|
|
|
|
assert.deepEqual(data, {
|
|
session: 'qa',
|
|
platform: 'android',
|
|
target: 'mobile',
|
|
device: 'Pixel 9',
|
|
id: 'emulator-5554',
|
|
serial: 'emulator-5554',
|
|
message: 'Opened: qa',
|
|
});
|
|
});
|
|
|
|
test('serializeInstallFromSourceResult uses install-family package naming', () => {
|
|
const data = serializeInstallFromSourceResult({
|
|
launchTarget: 'com.example.demo',
|
|
appName: 'Demo',
|
|
appId: 'com.example.demo',
|
|
packageName: 'com.example.demo',
|
|
identifiers: {
|
|
appId: 'com.example.demo',
|
|
package: 'com.example.demo',
|
|
},
|
|
});
|
|
|
|
assert.deepEqual(data, {
|
|
launchTarget: 'com.example.demo',
|
|
appName: 'Demo',
|
|
appId: 'com.example.demo',
|
|
package: 'com.example.demo',
|
|
message: 'Installed: Demo',
|
|
});
|
|
});
|
|
|
|
test('serializeSnapshotResult includes Android backend metadata', () => {
|
|
const data = serializeSnapshotResult({
|
|
nodes: [],
|
|
truncated: false,
|
|
androidSnapshot: {
|
|
backend: 'android-helper',
|
|
helperVersion: '0.13.3',
|
|
installReason: 'current',
|
|
waitForIdleTimeoutMs: 500,
|
|
nodeCount: 12,
|
|
},
|
|
identifiers: {
|
|
session: 'qa',
|
|
},
|
|
});
|
|
|
|
assert.deepEqual(data, {
|
|
nodes: [],
|
|
truncated: false,
|
|
androidSnapshot: {
|
|
backend: 'android-helper',
|
|
helperVersion: '0.13.3',
|
|
installReason: 'current',
|
|
waitForIdleTimeoutMs: 500,
|
|
nodeCount: 12,
|
|
},
|
|
});
|
|
});
|