-
Notifications
You must be signed in to change notification settings - Fork 167
Expand file tree
/
Copy pathboot-diagnostics.test.ts
More file actions
59 lines (52 loc) · 2.07 KB
/
Copy pathboot-diagnostics.test.ts
File metadata and controls
59 lines (52 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import test from 'node:test';
import assert from 'node:assert/strict';
import { bootFailureHint, classifyBootFailure } from '../boot-diagnostics.ts';
import { AppError } from '../../utils/errors.ts';
test('classifyBootFailure maps timeout errors', () => {
const reason = classifyBootFailure({
message: 'bootstatus timed out after 120s',
context: { platform: 'ios', phase: 'boot' },
});
assert.equal(reason, 'IOS_BOOT_TIMEOUT');
});
test('classifyBootFailure maps adb offline errors', () => {
const reason = classifyBootFailure({
stderr: 'error: device offline',
context: { platform: 'android', phase: 'transport' },
});
assert.equal(reason, 'ADB_TRANSPORT_UNAVAILABLE');
});
test('classifyBootFailure maps tool missing from AppError code (android)', () => {
const reason = classifyBootFailure({
error: new AppError('TOOL_MISSING', 'adb not found in PATH'),
context: { platform: 'android', phase: 'transport' },
});
assert.equal(reason, 'ADB_TRANSPORT_UNAVAILABLE');
});
test('classifyBootFailure maps tool missing from AppError code (ios)', () => {
const reason = classifyBootFailure({
error: new AppError('TOOL_MISSING', 'xcrun not found in PATH'),
context: { platform: 'ios', phase: 'boot' },
});
assert.equal(reason, 'IOS_TOOL_MISSING');
});
test('classifyBootFailure reads stderr from AppError details', () => {
const reason = classifyBootFailure({
error: new AppError('COMMAND_FAILED', 'adb failed', {
stderr: 'error: device unauthorized',
}),
context: { platform: 'android', phase: 'transport' },
});
assert.equal(reason, 'ADB_TRANSPORT_UNAVAILABLE');
});
test('bootFailureHint returns actionable guidance', () => {
const hint = bootFailureHint('IOS_RUNNER_CONNECT_TIMEOUT');
assert.equal(hint.includes('xcodebuild logs'), true);
});
test('connect phase does not classify non-timeout errors as connect timeout', () => {
const reason = classifyBootFailure({
message: 'Runner returned malformed JSON payload',
context: { platform: 'ios', phase: 'connect' },
});
assert.equal(reason, 'BOOT_COMMAND_FAILED');
});