From cf367c29f457d22a422a6a47b25bca901ac79147 Mon Sep 17 00:00:00 2001 From: Jochen Delabie Date: Wed, 2 Sep 2026 13:06:51 +0200 Subject: [PATCH] cli: report the device that actually ran in --json output A run requested with a wildcard or partial device name ("*", "iPhone") showed that request as the device in --json, which is useless in a report. Prefer the environment the run executed on, falling back to the capability when it is not yet known. --- src/providers/maestro.ts | 12 +++++++++++- tests/providers/maestro.test.ts | 28 ++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/providers/maestro.ts b/src/providers/maestro.ts index b95d87d..02ada87 100644 --- a/src/providers/maestro.ts +++ b/src/providers/maestro.ts @@ -2515,8 +2515,18 @@ export default class Maestro extends BaseProvider { }; }); + const base = super.runToJson(run); return { - ...super.runToJson(run), + ...base, + // Prefer the device that actually ran over the requested capability: + // a wildcard or partial name like "*" is meaningless in a report. + device: { + name: run.environment?.device || base.device.name, + platform: base.device.platform, + ...((run.environment?.version || base.device.version) && { + version: run.environment?.version || base.device.version, + }), + }, passed: this.runPassed(run), flows: jsonFlows, }; diff --git a/tests/providers/maestro.test.ts b/tests/providers/maestro.test.ts index 3cdf121..79bc1bf 100644 --- a/tests/providers/maestro.test.ts +++ b/tests/providers/maestro.test.ts @@ -6741,6 +6741,34 @@ onFlowStart: expect(run.flows?.[2]).not.toHaveProperty('durationSeconds'); }); + it('reports the device that actually ran instead of a wildcard request', () => { + maestro['appId'] = 1234; + const runs = [ + { + id: 1, + status: 'DONE', + capabilities: { deviceName: '*', platformName: 'iOS' }, + environment: { + device: 'iPhone 13', + name: 'iOS 18.5', + version: '18.5', + }, + success: 1, + flows: [], + }, + ] as unknown as import('../../src/providers/maestro').MaestroRunInfo[]; + const json = maestro.toJsonOutput({ + success: true, + outcome: 'passed', + runs, + }); + expect(json.runs[0].device).toEqual({ + name: 'iPhone 13', + platform: 'iOS', + version: '18.5', + }); + }); + it('marks a run as passed when every latest attempt passed', () => { maestro['appId'] = 1234; const runs = [