agent-device 0.17.1 → 0.17.3
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/README.md +3 -3
- package/android-multitouch-helper/dist/{agent-device-android-multitouch-helper-0.17.1.apk → agent-device-android-multitouch-helper-0.17.3.apk} +0 -0
- package/android-multitouch-helper/dist/agent-device-android-multitouch-helper-0.17.3.apk.sha256 +1 -0
- package/android-multitouch-helper/dist/{agent-device-android-multitouch-helper-0.17.1.manifest.json → agent-device-android-multitouch-helper-0.17.3.manifest.json} +4 -4
- package/android-snapshot-helper/dist/{agent-device-android-snapshot-helper-0.17.1.apk → agent-device-android-snapshot-helper-0.17.3.apk} +0 -0
- package/android-snapshot-helper/dist/agent-device-android-snapshot-helper-0.17.3.apk.sha256 +1 -0
- package/android-snapshot-helper/dist/{agent-device-android-snapshot-helper-0.17.1.manifest.json → agent-device-android-snapshot-helper-0.17.3.manifest.json} +6 -6
- package/dist/src/123.js +1 -0
- package/dist/src/1231.js +1 -1
- package/dist/src/1352.js +1 -1
- package/dist/src/221.js +2 -2
- package/dist/src/2403.js +3 -0
- package/dist/src/2415.js +36 -30
- package/dist/src/4778.js +1 -1
- package/dist/src/5611.js +1 -0
- package/dist/src/5827.js +1 -0
- package/dist/src/6088.js +1 -0
- package/dist/src/6133.js +1 -0
- package/dist/src/7556.js +1 -1
- package/dist/src/7847.js +1 -1
- package/dist/src/8806.js +3 -3
- package/dist/src/9010.js +1 -0
- package/dist/src/9238.js +3 -3
- package/dist/src/9471.js +1 -1
- package/dist/src/9542.js +6 -3
- package/dist/src/9616.js +2 -0
- package/dist/src/9818.js +1 -1
- package/dist/src/android-adb.d.ts +12 -6
- package/dist/src/android-adb.js +1 -1
- package/dist/src/android-snapshot-helper.d.ts +15 -8
- package/dist/src/android.js +5 -5
- package/dist/src/apple.js +1 -1
- package/dist/src/apps.js +10 -10
- package/dist/src/args.js +53 -14
- package/dist/src/batch.d.ts +16 -4
- package/dist/src/batch.js +1 -1
- package/dist/src/cli-output.js +29 -0
- package/dist/src/cli.js +17 -42
- package/dist/src/command-surface.js +1 -1
- package/dist/src/contracts.d.ts +80 -4
- package/dist/src/contracts.js +1 -1
- package/dist/src/find.js +1 -1
- package/dist/src/finders.d.ts +3 -1
- package/dist/src/generic.js +7 -7
- package/dist/src/index.d.ts +250 -79
- package/dist/src/index.js +1 -1
- package/dist/src/input-actions.js +1 -1
- package/dist/src/interaction.js +1 -1
- package/dist/src/internal/png-worker.d.ts +26 -0
- package/dist/src/internal/png-worker.js +1 -0
- package/dist/src/metro.d.ts +3 -1
- package/dist/src/react-native.js +1 -1
- package/dist/src/record-trace-recording.js +3 -3
- package/dist/src/remote-config.d.ts +33 -7
- package/dist/src/selector-runtime.js +1 -1
- package/dist/src/selectors.d.ts +17 -3
- package/dist/src/selectors.js +1 -1
- package/dist/src/server.js +2 -2
- package/dist/src/session.js +8 -11
- package/dist/src/snapshot.js +2 -2
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/AgentDeviceRunnerUITests-Bridging-Header.h +1 -0
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.h +14 -0
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.m +297 -0
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AXSnapshotFallback.swift +328 -0
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +121 -172
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandJournal.swift +153 -5
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+FlatSnapshotFiltering.swift +171 -0
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +0 -10
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +64 -18
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScrollGesture.swift +200 -0
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SequenceExecution.swift +406 -0
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +82 -169
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCapturePlan.swift +425 -0
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift +77 -6
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Transport.swift +10 -1
- package/ios-runner/README.md +5 -5
- package/ios-runner/RUNNER_PROTOCOL.md +0 -1
- package/package.json +8 -5
- package/server.json +2 -2
- package/android-multitouch-helper/dist/agent-device-android-multitouch-helper-0.17.1.apk.sha256 +0 -1
- package/android-snapshot-helper/dist/agent-device-android-snapshot-helper-0.17.1.apk.sha256 +0 -1
- package/dist/src/1998.js +0 -1
- package/dist/src/2805.js +0 -1
- package/dist/src/4057.js +0 -1
- package/dist/src/5310.js +0 -1
- package/dist/src/5792.js +0 -1
- package/dist/src/6085.js +0 -1
- package/dist/src/6232.js +0 -1
- package/dist/src/7455.js +0 -1
- package/dist/src/8020.js +0 -1
- package/dist/src/8502.js +0 -1
- package/dist/src/8699.js +0 -1
- package/dist/src/940.js +0 -1
- package/dist/src/9404.js +0 -1
- package/dist/src/9533.js +0 -1
- package/dist/src/command-metadata.js +0 -1
- /package/dist/src/{1393.js → 3675.js} +0 -0
package/dist/src/find.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{context_contextFromFlags as
|
|
1
|
+
import{context_contextFromFlags as t,setSessionSnapshot as e,captureSnapshot as n,dispatchCommand as r,errorResponse as a,ensureDeviceReady as o,getActiveAndroidSnapshotFreshness as i,resolveTargetDevice as s,stripInternalInteractionFlags as l}from"./2415.js";import{findBestMatchesByLocator as c,parseFindArgs as f}from"./7556.js";import{dispatchFindReadOnlyViaRuntime as u,readTextForNode as d}from"./selector-runtime.js";import{resolveActionableTouchResolution as p,isSparseSnapshotQualityVerdict as h,isSnapshotNodeInteractionBlocked as g,resolveActionableTouchNode as _}from"./6133.js";import{centerOfRect as y}from"./9616.js";import{sleep as m}from"./4829.js";import{extractNodeText as w}from"./7847.js";async function A(t){var r,d,g,m;let A,{req:E,sessionName:U,logPath:P,sessionStore:O,invoke:H}=t,$=E.command;if("find"!==$)return null;let q=E.positionals??[];if(0===q.length)return a("INVALID_ARGS","find requires a locator or text");let{locator:B,query:Q,action:G,value:V,timeoutMs:T}=f(q);if(!Q)return a("INVALID_ARGS","find requires a value");if(E.flags?.findFirst&&E.flags?.findLast)return a("INVALID_ARGS","find accepts only one of --first or --last");let j=await u({req:E,sessionName:U,logPath:P,sessionStore:O});if(j)return j;let z=O.get(U),J="exists"===(r=G)||"wait"===r||"get_text"===r||"get_attrs"===r;if(!z&&!J)return a("SESSION_NOT_FOUND","No active session. Run open first.");let W=z?.device??await s(E.flags??{});z||await o(W);let X="click"===(d=G)||"focus"===d||"fill"===d||"type"===d,Y=L(B)&&!X?Q:void 0,Z=function(t){let{device:r,session:a,req:o,logPath:s,locator:l,query:c,scope:f,interactiveOnly:u}=t,{sessionStore:d,sessionName:p}=t,g=0,_=null,y=async(t,e)=>{let{snapshot:i}=await n({device:r,session:a,flags:{...o.flags,snapshotInteractiveOnly:e},outPath:o.flags?.out,logPath:s,snapshotScope:t});return i};return async()=>{var t;let n=Date.now();if(_&&n-g<750&&!i(a))return _;let r=await y(f,u);u&&!(t=r).snapshotQuality&&"xctest"===t.backend&&1===t.nodes.length&&t.nodes[0]?.type==="Application"?r=await N({capture:y,locator:l,query:c,scope:f}):u&&h(r.snapshotQuality)&&L(l)&&(r=await k({capture:y,query:c,snapshot:r}));let o={nodes:r.nodes,truncated:r.truncated,backend:r.backend,snapshotQuality:r.snapshotQuality};return g=n,_=o,a&&!h(r.snapshotQuality)&&(e(a,r),d.set(p,a)),o}}({device:W,session:z,req:E,logPath:P,locator:B,query:Q,scope:Y,interactiveOnly:X,sessionStore:O,sessionName:U}),tt={req:E,sessionName:U,logPath:P,sessionStore:O,invoke:H,session:z,device:W,command:$,locator:B,query:Q,publicFlags:{...l(E.flags)??{}}};if("wait"===G)return x(tt,Z,B,Q,T);let te=await Z();if(h(te.snapshotQuality))return S(te.snapshotQuality);let{nodes:tn}=te,tr=function(t){let{nodes:e,locator:n,query:r,requiresRect:o,flags:i}=t,s=c(o?e.filter(t=>!C(t,e[0])):e,n,r,{requireRect:o});if(o&&(s.matches=function(t,e){var n,r;let a=e[0]?.rect;if(!a)return t;let o=t.filter(t=>{if(!t.rect)return!1;let e=y(t.rect);return e.x>=a.x&&e.x<=a.x+a.width&&e.y>=a.y&&e.y<=a.y+a.height});return n=o.length>0?o:t,r=e,n.length<2?n:n.map((t,e)=>({node:t,index:e,score:function(t,e){var n,r;let a=p(e,t);if("covered"===a.reason)return 0;let o=(n=a,r=e[0],n.node.rect?"semantic-target"===n.reason||"same-rect-descendant"===n.reason?4:2*!("hittable-ancestor"!==n.reason||C(n.node,r)):0);return o>0?o:t.hittable&&t.rect&&!C(t,e[0])?3:+!!t.rect}(t,r)})).sort((t,e)=>e.score!==t.score?e.score-t.score:v(t.node)-v(e.node)||t.index-e.index).map(t=>t.node)}(s.matches,e)),o&&s.matches.length>1){var l,f,u,d,h;let t=(l=s.matches,f=i,f?.findFirst?[l[0]]:f?.findLast?[l[l.length-1]]:null);if(!t){let t;return{ok:!1,response:(u=s.matches,d=n,h=r,t=u.slice(0,8).map(t=>{let e=w(t)||t.label||t.identifier||t.type||"";return`@${t.ref}${e?`(${e})`:""}`}),a("AMBIGUOUS_MATCH",`find matched ${u.length} elements for ${d} "${h}". Use a more specific locator or selector.`,{locator:d,query:h,matches:u.length,candidates:t}))}}s.matches=t}let g=s.matches[0]??null;return g?{ok:!0,node:g}:{ok:!1,response:a("COMMAND_FAILED","find did not match any element")}}({nodes:tn,locator:B,query:Q,requiresRect:X,flags:E.flags});if(!tr.ok)return tr.response;let ta=tr.node,to=X?C(A=_(g=tn,m=ta),g[0])&&m.rect?m:A:ta,ti=`@${to.ref}`,ts={node:ta,resolvedNode:to,ref:ti,nodes:tn,actionFlags:{...E.flags??{},noRecord:!0}},tl={exists:()=>M(tt),get_text:()=>I(tt,ts),get_attrs:()=>D(tt,ts),click:()=>R(tt,ts),fill:()=>F(tt,ts,V),focus:()=>K(tt,ts),type:()=>b(tt,ts,V)}[G];return tl?tl():null}async function k(t){let{capture:e,query:n,snapshot:r}=t;try{return await e(n,!1)}catch{return r}}async function N(t){let{capture:e,locator:n,query:r,scope:a}=t;try{return await e(a,!1)}catch(t){if(!L(n))throw t;return await e(r,!1)}}function S(t){return a("COMMAND_FAILED","find could not read the current accessibility tree",{reason:t.reason,hint:"The snapshot quality verdict is sparse. Use screenshot as visual truth, navigate with coordinates if needed, then retry find after reaching a readable screen."})}function v(t){return t.rect?t.rect.width*t.rect.height:1/0}function C(t,e){var n,r;if(!e?.rect||!t.rect)return!1;let a=t.type?.toLowerCase()??"";return(!!a.includes("application")||!!a.includes("window"))&&(n=t.rect,r=e.rect,n.x===r.x&&n.y===r.y&&n.width===r.width&&n.height===r.height)}async function x(t,e,n,r,o){let i,{req:s,sessionStore:l,session:f,command:u,publicFlags:d}=t,p=o??1e4,g=Date.now();for(;Date.now()-g<p;){let{nodes:t,snapshotQuality:a}=await e();if(h(a)){i=a,await m(300);continue}if(c(t,n,r,{requireRect:!1}).matches[0])return f&&l.recordAction(f,{command:u,positionals:s.positionals??[],flags:d,result:{found:!0,waitedMs:Date.now()-g}}),{ok:!0,data:{found:!0,waitedMs:Date.now()-g}};await m(300)}return i?S(i):a("COMMAND_FAILED","find wait timed out")}async function M(t){let{req:e,sessionStore:n,session:r,command:a,publicFlags:o}=t;return r&&n.recordAction(r,{command:a,positionals:e.positionals??[],flags:o,result:{found:!0}}),{ok:!0,data:{found:!0}}}async function I(e,n){let{req:r,sessionStore:a,session:o,command:i,device:s,logPath:l,publicFlags:c}=e,f=await d({device:s,node:n.node,flags:r.flags,appBundleId:o?.appBundleId,traceOutPath:o?.trace?.outPath,surface:o?.surface,contextFromFlags:(e,n,r)=>t(l,e,n,r)});return o&&a.recordAction(o,{command:i,positionals:r.positionals??[],flags:c,result:{ref:n.ref,action:"get text",text:f}}),{ok:!0,data:{ref:n.ref,text:f,node:n.node}}}async function D(t,e){let{req:n,sessionStore:r,session:a,command:o,publicFlags:i}=t;return a&&r.recordAction(a,{command:o,positionals:n.positionals??[],flags:i,result:{ref:e.ref,action:"get attrs"}}),{ok:!0,data:{ref:e.ref,node:e.node}}}async function R(t,e){let{req:n,sessionName:r,sessionStore:a,session:o,invoke:i,command:s,locator:l,query:c,publicFlags:f}=t,u=await i({token:n.token,session:r,command:"click",positionals:[e.ref],flags:e.actionFlags});if(!u.ok)return u;let d=e.resolvedNode.rect?y(e.resolvedNode.rect):e.node.rect?y(e.node.rect):null,p={ref:e.ref,locator:l,query:c};return d&&(p.x=d.x,p.y=d.y),o&&a.recordAction(o,{command:s,positionals:n.positionals??[],flags:f,result:{ref:e.ref,action:"click",locator:l,query:c}}),{ok:!0,data:p}}async function F(t,e,n){let{req:r,sessionName:o,sessionStore:i,session:s,invoke:l,command:c,publicFlags:f}=t;if(!n)return a("INVALID_ARGS","find fill requires text");let u=await l({token:r.token,session:o,command:"fill",positionals:[e.ref,n],flags:e.actionFlags});return u.ok&&s&&i.recordAction(s,{command:c,positionals:r.positionals??[],flags:f,result:{ref:e.ref,action:"fill"}}),u}async function K(t,e){let n=await E(t,e);return n.ok&&U(t,e,"focus"),n}async function b(e,n,o){let{req:i,device:s,logPath:l,session:c}=e;if(!o)return a("INVALID_ARGS","find type requires text");let f=await E(e,n);if(!f.ok)return f;let u=await r(s,"type",[o],i.flags?.out,{...t(l,i.flags,c?.appBundleId,c?.trace?.outPath)});return U(e,n,"type"),{ok:!0,data:u??{ref:n.ref}}}async function E(e,n){var o;let i,{req:s,device:l,logPath:c,session:f}=e,u=(i=[(o=n).resolvedNode,o.node].find(g))?a("COMMAND_FAILED",`Matched element ${o.ref} is covered by another visible element and cannot be focused safely`,{ref:`@${i.ref}`,interactionBlocked:i.interactionBlocked,hint:"Use a different visible target, scroll it clear of the overlay, or inspect with snapshot/screenshot before retrying."}):null;if(u)return u;let d=n.resolvedNode.rect?y(n.resolvedNode.rect):null;return d?{ok:!0,data:await r(l,"focus",[String(d.x),String(d.y)],s.flags?.out,{...t(c,s.flags,f?.appBundleId,f?.trace?.outPath)})??{ref:n.ref}}:a("COMMAND_FAILED","matched element has no bounds")}function U(t,e,n){let{req:r,sessionStore:a,session:o,command:i,publicFlags:s}=t;o&&a.recordAction(o,{command:i,positionals:r.positionals??[],flags:s,result:{ref:e.ref,action:n}})}function L(t){return"role"!==t}export{parseFindArgs}from"./7556.js";export{A as handleFindCommands};
|
package/dist/src/finders.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
declare const FIND_LOCATORS: readonly ["any", "text", "label", "value", "role", "id"];
|
|
2
|
+
|
|
1
3
|
declare type FindAction = {
|
|
2
4
|
kind: 'click';
|
|
3
5
|
} | {
|
|
@@ -24,7 +26,7 @@ export declare function findBestMatchesByLocator(nodes: SnapshotNode[], locator:
|
|
|
24
26
|
score: number;
|
|
25
27
|
};
|
|
26
28
|
|
|
27
|
-
export declare type FindLocator =
|
|
29
|
+
export declare type FindLocator = (typeof FIND_LOCATORS)[number];
|
|
28
30
|
|
|
29
31
|
export declare type FindMatchOptions = {
|
|
30
32
|
requireRect?: boolean;
|
package/dist/src/generic.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import t from"node:fs";import e from"node:path";import{formatDurationSeconds as r}from"./9542.js";import{AppError as s}from"./9152.js";import{
|
|
1
|
+
import t from"node:fs";import e from"node:path";import{formatDurationSeconds as r}from"./9542.js";import{AppError as s}from"./9152.js";import{printJson as n}from"./cli-output.js";import{runCliCommandWithOutput as i,writeCommandOutput as o}from"./cli.js";import{readCommandMessage as a}from"./6133.js";function u(s){var n,i;if("skipped"===s.status)return[];let o=(n=s).artifactsDir?e.join(n.artifactsDir,`attempt-${n.attempts}`,"replay-timing.ndjson"):void 0;if(!o)return[];let a=function(e){try{return t.readFileSync(e,"utf8").split(/\r?\n/).filter(t=>t.trim().length>0).flatMap(t=>{try{let e=JSON.parse(t);return c(e)?[e]:[]}catch{return[]}})}catch{return[]}}(o);if(0===a.length)return[];let u=[],m=[];for(let t of a){if("replay_action_start"===(i=t).type&&d(i)&&f(i,"line")&&l(i,"command")&&(void 0===i.positionals||Array.isArray(i.positionals))){u.push(t);continue}(function(t){var e;return["replay_action_stop"===t.type&&d(t)&&f(t,"line")&&l(t,"command"),void 0===(e=t).ok||"boolean"==typeof e.ok,f(t,"durationMs"),l(t,"errorCode"),void 0===t.resultTiming||c(t.resultTiming)].every(Boolean)})(t)&&m.push({stop:t,start:function(t,e){let r=e.command,s=t.findIndex(t=>t.step===e.step&&(void 0===r||void 0===t.command||t.command===r));if(!(s<0))return t.splice(s,1)[0]}(u,t)})}return 0===m.length?[]:[s.attempts>1?`steps (attempt ${s.attempts}):`:"steps:",...m.map(({stop:t,start:e})=>{var s,n,i,o,a,u;let d,f,l;return s=t,n=e,d=!1===s.ok?"[FAIL] ":!0===s.ok?"":"[info] ",` ${d}${i=n,o=s,[function(t){if(!t)return"unknown";if(!t.startsWith("__maestro"))return t;let e=t.slice(9);return e.length>0?e[0].toLowerCase()+e.slice(1):t}(i?.command??o.command),...(i?.positionals??[]).map(p)].join(" ")}${a=s,u=n,(l=["number"==typeof(f=u?.line??a.line)?`line ${f}`:"","number"==typeof a.durationMs?r(a.durationMs):"",a.errorCode??"",a.resultTiming?`timing ${JSON.stringify(a.resultTiming)}`:""].filter(Boolean)).length>0?` (${l.join(", ")})`:""}`})]}function d(t){return"number"==typeof t.step}function f(t,e){return void 0===t[e]||"number"==typeof t[e]}function l(t,e){return void 0===t[e]||"string"==typeof t[e]}function p(t){return"string"==typeof t?JSON.stringify(t):"number"==typeof t||"boolean"==typeof t?String(t):JSON.stringify(t)}function c(t){return!!t&&"object"==typeof t&&!Array.isArray(t)}function m(t){var r,s;let n,i,o,a=t.attempts>1?` after ${t.attempts} attempts`:"",d=y(t);for(let u of(process.stdout.write(`FAIL ${(n=h(r=t),i=e.basename(r.file),o=n&&n.length>0?`${JSON.stringify(n)} in ${i}`:i,`${o}${M(r)}`)}${a}${d}
|
|
2
2
|
`),process.stdout.write(` ${t.error?.message??"Unknown test failure"}
|
|
3
|
-
`),[A((s=t).error),w(s,"artifacts"),
|
|
3
|
+
`),[A((s=t).error),w(s,"artifacts"),C(s.error,"log"),b(s.error,"diagnostic")].filter(k)))process.stdout.write(` ${u}
|
|
4
4
|
`);for(let e of u(t))process.stdout.write(` ${e}
|
|
5
|
-
`)}function $(t){return"passed"===t.status&&t.attempts>1}function g(t){let r=h(t),s=r&&r.length>0?JSON.stringify(r):e.basename(t.file);return`${s}${M(t)}`}function h(t){let e=t.title?.trim();return e&&e.length>0?e:void 0}function y(t){if("passed"===t.status&&t.attempts>1)return v(t);if("failed"===t.status&&t.attempts>1&&t.durationMs>0)return` (total ${r(t.durationMs)})`;let e="passed"===t.status&&"number"==typeof t.finalAttemptDurationMs?t.finalAttemptDurationMs:t.durationMs;return e>0?` (${r(e)})`:""}function v(t){let e=["number"==typeof t.finalAttemptDurationMs?`passed attempt ${r(t.finalAttemptDurationMs)}`:"",t.durationMs>0?`total ${r(t.durationMs)}`:""].filter(Boolean);return e.length>0?` (${e.join(", ")})`:""}function M(t){if(!("shardIndex"in t)||"number"!=typeof t.shardIndex)return"";let e="number"==typeof t.shardCount?t.shardCount:"?",r="string"==typeof t.deviceId?` ${t.deviceId}`:"";return` [shard ${t.shardIndex+1}/${e}${r}]`}function
|
|
6
|
-
`}(n),"utf8")}catch(e){let t=e instanceof Error?e.message:String(e);throw new s("COMMAND_FAILED",`Failed to write JUnit report to ${r}: ${t}`)}}(
|
|
5
|
+
`)}function $(t){return"passed"===t.status&&t.attempts>1}function g(t){let r=h(t),s=r&&r.length>0?JSON.stringify(r):e.basename(t.file);return`${s}${M(t)}`}function h(t){let e=t.title?.trim();return e&&e.length>0?e:void 0}function y(t){if("passed"===t.status&&t.attempts>1)return v(t);if("failed"===t.status&&t.attempts>1&&t.durationMs>0)return` (total ${r(t.durationMs)})`;let e="passed"===t.status&&"number"==typeof t.finalAttemptDurationMs?t.finalAttemptDurationMs:t.durationMs;return e>0?` (${r(e)})`:""}function v(t){let e=["number"==typeof t.finalAttemptDurationMs?`passed attempt ${r(t.finalAttemptDurationMs)}`:"",t.durationMs>0?`total ${r(t.durationMs)}`:""].filter(Boolean);return e.length>0?` (${e.join(", ")})`:""}function M(t){if(!("shardIndex"in t)||"number"!=typeof t.shardIndex)return"";let e="number"==typeof t.shardCount?t.shardCount:"?",r="string"==typeof t.deviceId?` ${t.deviceId}`:"";return` [shard ${t.shardIndex+1}/${e}${r}]`}function _(t,e,r={}){r.includeMessage&&t.push(`errorMessage: ${e.message}`),I(t,A(e)),I(t,b(e,"diagnosticId")),I(t,C(e,"logPath")),!1!==r.includeDetails&&S(t,e,r.detailsIndent)}function S(t,e,r){let s=e.details?JSON.stringify(e.details,null,r):void 0;s&&t.push(`details: ${s}`)}function w(t,e){return"artifactsDir"in t&&t.artifactsDir?`${e}: ${t.artifactsDir}`:void 0}function A(t){return t.hint?`hint: ${t.hint}`:void 0}function b(t,e){return t.diagnosticId?`${e}: ${t.diagnosticId}`:void 0}function C(t,e){return t.logPath?`${e}: ${t.logPath}`:void 0}function I(t,e){e&&t.push(e)}function k(t){return void 0!==t}function D(t){return"passed"!==t.status?[]:(t.warnings??[]).map(t=>`warning: ${t}`)}function j(t){return(Math.max(0,t)/1e3).toFixed(3)}function x(t){return t.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}async function N({command:d,positionals:f,flags:l,client:p}){var c,A,b,C,k;let{result:P,cliOutput:F}=await i({client:p,command:d,positionals:f,flags:l});if(F){c=l,A=F,!c.json&&A.stderr&&process.stderr.write(A.stderr),o(c,c.json?A.jsonData??A.data:A.data,()=>A.text)}else{let i=(b=d,C=l,k=P,"test"===b?function(i){let{suite:o,json:a,verbose:d,reportJunit:f}=i;return(f&&function(r,n){let i=e.dirname(r);try{t.mkdirSync(i,{recursive:!0}),t.writeFileSync(r,function(t){let r=['<?xml version="1.0" encoding="UTF-8"?>',"<testsuites>",` <testsuite name="agent-device replay suite" tests="${t.total}" failures="${t.failed}" skipped="${t.skipped}" time="${j(t.durationMs)}">`];for(let s of t.tests)r.push(...function(t){let r=x(`${h(t)??e.basename(t.file)}${M(t)}`),s=x(`${"."===e.dirname(t.file)?t.file:e.dirname(t.file)}${M(t)}`),n=x(t.file),i=j(t.durationMs),o=[` <testcase classname="${s}" name="${r}" file="${n}" time="${i}">`];"failed"===t.status?o.push(` <failure message="${x(t.error.message)}">${x(function(t){let e=[t.error.message];return _(e,t.error,{includeDetails:!1}),I(e,w(t,"artifactsDir")),S(e,t.error,2),e.join("\n")}(t))}</failure>`):"skipped"===t.status&&o.push(` <skipped message="${x(t.message)}" />`);let a=function(t){let e=[`status: ${t.status}`,`durationMs: ${t.durationMs}`];return function(t,e){var r,s,n,i;for(let r of(I(t,"attempts"in e?`attempts: ${e.attempts}`:void 0),I(t,"session"in e?`session: ${e.session}`:void 0),I(t,"replayed"in e?`replayed: ${e.replayed}`:void 0),I(t,"healed"in e?`healed: ${e.healed}`:void 0),D(e)))t.push(r);I(t,w(e,"artifactsDir")),r=t,s=e,"shardIndex"in s&&"number"==typeof s.shardIndex&&(r.push(`shardIndex: ${s.shardIndex}`),I(r,"number"==typeof s.shardCount?`shardCount: ${s.shardCount}`:void 0),I(r,"string"==typeof s.deviceId?`deviceId: ${s.deviceId}`:void 0)),"failed"===e.status&&(n=t,i=e,n.push(`errorCode: ${i.error.code}`),_(n,i.error,{includeMessage:!0})),I(t,$(e)?"flaky: true":void 0)}(e,t),e.join("\n")}(t);return a&&o.push(` <system-out>${x(a)}</system-out>`),o.push(" </testcase>"),o}(s));return r.push(" </testsuite>"),r.push("</testsuites>"),`${r.join("\n")}
|
|
6
|
+
`}(n),"utf8")}catch(e){let t=e instanceof Error?e.message:String(e);throw new s("COMMAND_FAILED",`Failed to write JUnit report to ${r}: ${t}`)}}(f,o),a)?(n({success:!0,data:o}),+(o.failed>0)):function(t,e={}){let s=t.tests.filter($);if(e.verbose)for(let e of t.tests)!function(t){var e;if("failed"===t.status)return m(t);let r=y(t);for(let s of(process.stdout.write(`${"passed"===(e=t).status?"PASS":"skipped"===e.status?"SKIP":"INFO"} ${g(t)}${r}
|
|
7
7
|
`),"skipped"===t.status&&process.stdout.write(` ${t.message??"skipped"}
|
|
8
|
-
`),
|
|
8
|
+
`),D(t)))process.stdout.write(` ${s}
|
|
9
9
|
`);for(let e of u(t))process.stdout.write(` ${e}
|
|
10
10
|
`)}(e);else for(let e of t.tests)!function(t){if("failed"===t.status)return m(t);if("passed"===t.status)for(let e of(process.stdout.write(`PASS ${g(t)}${y(t)}
|
|
11
|
-
`),
|
|
11
|
+
`),D(t)))process.stdout.write(` ${e}
|
|
12
12
|
`)}(e);let n="number"==typeof t.durationMs?t.durationMs:void 0,i=s.length>0?`, ${s.length} flaky`:"",o=void 0!==n?` in ${r(n)}`:"";return process.stdout.write(`Test summary: ${t.passed} passed, ${t.failed} failed${i}${o}
|
|
13
13
|
`),function(t){if(0!==t.length)for(let e of(process.stdout.write("Flaky tests:\n"),t))for(let t of(process.stdout.write(` PASS ${g(e)} after ${e.attempts} attempts${v(e)}
|
|
14
14
|
`),e.attemptFailures??[])){let e="number"==typeof t.durationMs?` (${r(t.durationMs)})`:"";process.stdout.write(` attempt ${t.attempt} failed${e}: ${t.message}
|
|
15
|
-
`)}}(s),+(t.failed>0)}(o,{verbose:d})}({suite:k,verbose:
|
|
15
|
+
`)}}(s),+(t.failed>0)}(o,{verbose:d})}({suite:k,verbose:C.verbose,json:C.json,reportJunit:C.reportJunit}):(o(C,k,()=>a(k)),0));0!==i&&process.exit(i)}return!0}export{N as runGenericClientBackedCommand};
|