@devicecloud.dev/dcd 5.11.0-beta.6 → 5.11.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/cloud.js +6 -1
- package/dist/commands/device.js +24 -2
- package/dist/gateways/device-gateway.d.ts +1 -1
- package/dist/gateways/device-gateway.js +2 -2
- package/dist/mcp/tools/run-cloud-test.js +1 -1
- package/dist/services/execution-plan.service.d.ts +6 -0
- package/dist/services/execution-plan.service.js +8 -0
- package/dist/types/domain/device-session.types.d.ts +14 -0
- package/dist/utils/device-run.js +8 -0
- package/package.json +1 -1
package/dist/commands/cloud.js
CHANGED
|
@@ -6,7 +6,7 @@ import { flags as allFlags } from '../constants.js';
|
|
|
6
6
|
import { ApiGateway } from '../gateways/api-gateway.js';
|
|
7
7
|
import { uploadBinary, uploadFlowZip, verifyAppZip, writeJSONFile, } from '../methods.js';
|
|
8
8
|
import { DeviceValidationService } from '../services/device-validation.service.js';
|
|
9
|
-
import { plan } from '../services/execution-plan.service.js';
|
|
9
|
+
import { countExtendedRuntimeFlows, plan } from '../services/execution-plan.service.js';
|
|
10
10
|
import { isSubmitEndpointMissing, submitWithRetry, } from '../services/flow-submit.service.js';
|
|
11
11
|
import { buildTestMetadataMap, computeCommonRoot, } from '../services/flow-paths.js';
|
|
12
12
|
import { MoropoService } from '../services/moropo.service.js';
|
|
@@ -523,6 +523,11 @@ export const cloudCommand = defineCommand({
|
|
|
523
523
|
submitRows.push(colors.dim(`${flowPath.replace(process.cwd(), '.')}:`));
|
|
524
524
|
submitRows.push(...ui.fields(Object.entries(overrides).map(([key, value]) => [key, colors.highlight(String(value))])));
|
|
525
525
|
}
|
|
526
|
+
// The 2x is charged per flow, so say it before the run, not on the bill.
|
|
527
|
+
const extendedFlows = countExtendedRuntimeFlows(flowOverrides);
|
|
528
|
+
if (extendedFlows > 0) {
|
|
529
|
+
submitRows.push('', ui.note(`${extendedFlows} flow${extendedFlows === 1 ? '' : 's'} with extended runtime: up to 20 min each, billed at 2×`));
|
|
530
|
+
}
|
|
526
531
|
}
|
|
527
532
|
out(ui.section('Submitting new job'));
|
|
528
533
|
out(ui.branch(submitRows));
|
package/dist/commands/device.js
CHANGED
|
@@ -583,13 +583,21 @@ const modelsSub = defineCommand({
|
|
|
583
583
|
});
|
|
584
584
|
const inspectSub = defineCommand({
|
|
585
585
|
meta: { name: 'inspect', description: 'The screen as compact JSON: each element with text, an id or a label' },
|
|
586
|
-
args: {
|
|
586
|
+
args: {
|
|
587
|
+
...commonArgs,
|
|
588
|
+
id: idArg,
|
|
589
|
+
all: {
|
|
590
|
+
type: 'boolean',
|
|
591
|
+
default: false,
|
|
592
|
+
description: 'Also list the keyboard keys and the System UI (status and navigation bars)',
|
|
593
|
+
},
|
|
594
|
+
},
|
|
587
595
|
async run({ args }) {
|
|
588
596
|
const json = Boolean(args.json);
|
|
589
597
|
await runDeviceCommand(json, async () => {
|
|
590
598
|
const ctx = await context(args);
|
|
591
599
|
const id = await resolveSessionId(ctx.apiUrl, ctx.auth, args.id);
|
|
592
|
-
const { screen, session } = await DeviceGateway.inspect(ctx.apiUrl, ctx.auth, id);
|
|
600
|
+
const { screen, session } = await DeviceGateway.inspect(ctx.apiUrl, ctx.auth, id, Boolean(args.all));
|
|
593
601
|
return {
|
|
594
602
|
session,
|
|
595
603
|
data: { screen },
|
|
@@ -597,6 +605,14 @@ const inspectSub = defineCommand({
|
|
|
597
605
|
logger.log(ui.section(`Screen ${screen.width}x${screen.height}, ${screen.elements.length} elements` +
|
|
598
606
|
(screen.fresh ? '' : colors.dim(' (no new frame; this is the latest)'))));
|
|
599
607
|
logger.log(ui.branch(screen.elements.map((el) => formatElement(el))));
|
|
608
|
+
const notes = [];
|
|
609
|
+
if (screen.keyboard_open)
|
|
610
|
+
notes.push('A keyboard is open.');
|
|
611
|
+
if (screen.hidden && (screen.hidden.keyboard > 0 || screen.hidden.system > 0)) {
|
|
612
|
+
notes.push(`Left out ${screen.hidden.keyboard} keyboard and ${screen.hidden.system} System UI elements (--all shows them).`);
|
|
613
|
+
}
|
|
614
|
+
if (notes.length > 0)
|
|
615
|
+
logger.log(ui.note(notes.join(' ')));
|
|
600
616
|
},
|
|
601
617
|
};
|
|
602
618
|
});
|
|
@@ -613,6 +629,12 @@ export function formatElement(el) {
|
|
|
613
629
|
parts.push(`id:${el.rid}`);
|
|
614
630
|
if (el.hint)
|
|
615
631
|
parts.push(`hint:"${el.hint}"`);
|
|
632
|
+
for (const state of ['checked', 'selected', 'focused']) {
|
|
633
|
+
if (el[state])
|
|
634
|
+
parts.push(state);
|
|
635
|
+
}
|
|
636
|
+
if (el.enabled === false)
|
|
637
|
+
parts.push('disabled');
|
|
616
638
|
return `${parts.join(' ')} ${colors.dim(el.b)}`;
|
|
617
639
|
}
|
|
618
640
|
/** `data:image/jpeg;base64,...` to bytes and a file extension. */
|
|
@@ -22,7 +22,7 @@ export declare const DeviceGateway: {
|
|
|
22
22
|
human: DeviceHumanStatus;
|
|
23
23
|
session: DeviceSession;
|
|
24
24
|
}>;
|
|
25
|
-
inspect(baseUrl: string, auth: AuthContext, id: string): Promise<{
|
|
25
|
+
inspect(baseUrl: string, auth: AuthContext, id: string, all?: boolean): Promise<{
|
|
26
26
|
screen: DeviceScreen;
|
|
27
27
|
session: DeviceSession;
|
|
28
28
|
}>;
|
|
@@ -97,8 +97,8 @@ export const DeviceGateway = {
|
|
|
97
97
|
human(baseUrl, auth, id) {
|
|
98
98
|
return request(baseUrl, auth, 'GET', `${sessionPath(id)}/human`);
|
|
99
99
|
},
|
|
100
|
-
inspect(baseUrl, auth, id) {
|
|
101
|
-
return request(baseUrl, auth, 'GET', `${sessionPath(id)}/inspect`);
|
|
100
|
+
inspect(baseUrl, auth, id, all = false) {
|
|
101
|
+
return request(baseUrl, auth, 'GET', `${sessionPath(id)}/inspect${all ? '?all=true' : ''}`);
|
|
102
102
|
},
|
|
103
103
|
install(baseUrl, auth, id, app) {
|
|
104
104
|
return request(baseUrl, auth, 'POST', `${sessionPath(id)}/install`, app);
|
|
@@ -95,7 +95,7 @@ export function registerRunCloudTest(server) {
|
|
|
95
95
|
.min(30)
|
|
96
96
|
.max(3600)
|
|
97
97
|
.optional()
|
|
98
|
-
.describe('Max seconds to wait when wait is true (default 600)'),
|
|
98
|
+
.describe('Max seconds to wait when wait is true (default 600). A flow with DEVICECLOUD_OVERRIDE_EXTENDED_RUNTIME: true in its env can run for up to 20 minutes, so raise this when the run includes one.'),
|
|
99
99
|
},
|
|
100
100
|
annotations: {
|
|
101
101
|
title: 'Run a cloud test',
|
|
@@ -37,6 +37,12 @@ interface IFlowSequence {
|
|
|
37
37
|
continueOnFailure?: boolean;
|
|
38
38
|
flows: string[];
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* How many flows opt into the extended test runtime (up to 20 minutes, billed
|
|
42
|
+
* accepts: YAML `true` or the string `'true'`.
|
|
43
|
+
* accepts: YAML `true` or the string `'true'`.
|
|
44
|
+
*/
|
|
45
|
+
export declare function countExtendedRuntimeFlows(flowOverrides: Record<string, Record<string, unknown>>): number;
|
|
40
46
|
/**
|
|
41
47
|
* Generate execution plan for test flows
|
|
42
48
|
*
|
|
@@ -83,6 +83,14 @@ function extractDeviceCloudOverrides(config) {
|
|
|
83
83
|
}
|
|
84
84
|
return overrides;
|
|
85
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* How many flows opt into the extended test runtime (up to 20 minutes, billed
|
|
88
|
+
* accepts: YAML `true` or the string `'true'`.
|
|
89
|
+
* accepts: YAML `true` or the string `'true'`.
|
|
90
|
+
*/
|
|
91
|
+
export function countExtendedRuntimeFlows(flowOverrides) {
|
|
92
|
+
return Object.values(flowOverrides).filter(({ EXTENDED_RUNTIME }) => EXTENDED_RUNTIME === true || EXTENDED_RUNTIME === 'true').length;
|
|
93
|
+
}
|
|
86
94
|
/**
|
|
87
95
|
* Generate execution plan for a single flow file
|
|
88
96
|
* @param normalizedInput - Normalized path to the flow file
|
|
@@ -105,6 +105,8 @@ export interface DeviceCommandResult {
|
|
|
105
105
|
/** Each flow of a run. Absent from APIs older than this field. */
|
|
106
106
|
flows?: DeviceFlowResult[];
|
|
107
107
|
output?: string;
|
|
108
|
+
/** A failed run: the app's visible text just after it failed. */
|
|
109
|
+
screen_text?: string[];
|
|
108
110
|
success: boolean;
|
|
109
111
|
}
|
|
110
112
|
/** One element of the compact screen (Maestro's key names). */
|
|
@@ -112,8 +114,13 @@ export interface DeviceScreenElement {
|
|
|
112
114
|
/** Bounds, "[left,top][right,bottom]". */
|
|
113
115
|
b: string;
|
|
114
116
|
a11y?: string;
|
|
117
|
+
checked?: true;
|
|
118
|
+
/** False when disabled; absent when enabled. */
|
|
119
|
+
enabled?: false;
|
|
120
|
+
focused?: true;
|
|
115
121
|
hint?: string;
|
|
116
122
|
rid?: string;
|
|
123
|
+
selected?: true;
|
|
117
124
|
txt?: string;
|
|
118
125
|
}
|
|
119
126
|
/** GET .../inspect: the elements worth targeting, and what each key means. */
|
|
@@ -122,6 +129,13 @@ export interface DeviceScreen {
|
|
|
122
129
|
/** False when no new frame came in time; this is then the latest. */
|
|
123
130
|
fresh: boolean;
|
|
124
131
|
height: number;
|
|
132
|
+
/** Keyboard keys and System UI left out (only when some were); --all shows them. */
|
|
133
|
+
hidden?: {
|
|
134
|
+
keyboard: number;
|
|
135
|
+
system: number;
|
|
136
|
+
};
|
|
137
|
+
/** An on-screen keyboard is showing (Android). */
|
|
138
|
+
keyboard_open?: true;
|
|
125
139
|
keys: Record<string, string>;
|
|
126
140
|
width: number;
|
|
127
141
|
}
|
package/dist/utils/device-run.js
CHANGED
|
@@ -65,6 +65,14 @@ export function runFailureMessage(result, report) {
|
|
|
65
65
|
* (a single flow's report has no file name).
|
|
66
66
|
*/
|
|
67
67
|
export function printRunResult(log, passed, result, label) {
|
|
68
|
+
printOutcome(log, passed, result, label);
|
|
69
|
+
// What the app showed after the failure: why an assertion missed.
|
|
70
|
+
if (!passed && result.screen_text?.length) {
|
|
71
|
+
log(ui.section('On screen after the failure'));
|
|
72
|
+
log(ui.branch(result.screen_text.map((t) => `"${t}"`)));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function printOutcome(log, passed, result, label) {
|
|
68
76
|
const report = parseRunReport(result);
|
|
69
77
|
if (!report || report.flows.length === 0) {
|
|
70
78
|
log(passed ? ui.success('Flow passed') : `${ui.statusSymbol('FAILED')} Flow failed`);
|
package/package.json
CHANGED