1+ import { dirname , resolve } from "node:path" ;
2+
13import { resolveAgentSelectionOutputDir , selectAgentTestPlan } from "@allurereport/plugin-agent" ;
2- import { epic , feature , label , story } from "allure-js-commons" ;
4+ import { attachment , epic , feature , label , story } from "allure-js-commons" ;
35import { run , UsageError } from "clipanion" ;
46import { type Mock , beforeEach , describe , expect , it , vi } from "vitest" ;
57
@@ -90,6 +92,8 @@ describe("agent select command", () => {
9092 it ( "should write the selected test plan and print selection summary when output is provided" , async ( ) => {
9193 const consoleModule = await import ( "node:console" ) ;
9294 const fsModule = await import ( "node:fs/promises" ) ;
95+ const outputPath = resolve ( "/cwd" , "./testplan.json" ) ;
96+ const outputDir = dirname ( outputPath ) ;
9397
9498 ( resolveAgentSelectionOutputDir as Mock ) . mockResolvedValueOnce ( "/tmp/agent-output" ) ;
9599 ( selectAgentTestPlan as Mock ) . mockResolvedValueOnce ( {
@@ -113,13 +117,18 @@ describe("agent select command", () => {
113117 "./testplan.json" ,
114118 ] ) ;
115119
116- expect ( fsModule . mkdir ) . toHaveBeenCalledWith ( "/cwd" , { recursive : true } ) ;
120+ await attachment (
121+ "selected test plan output path contract" ,
122+ JSON . stringify ( { outputPath, outputDir } , null , 2 ) ,
123+ "application/json" ,
124+ ) ;
125+ expect ( fsModule . mkdir ) . toHaveBeenCalledWith ( outputDir , { recursive : true } ) ;
117126 expect ( fsModule . writeFile ) . toHaveBeenCalledWith (
118- "/cwd/testplan.json" ,
127+ outputPath ,
119128 `{\n "version": "1.0",\n "tests": [\n {\n "selector": "suite feature A"\n },\n {\n "selector": "suite feature B"\n }\n ]\n}\n` ,
120129 "utf-8" ,
121130 ) ;
122- expect ( consoleModule . log ) . toHaveBeenNthCalledWith ( 1 , " agent testplan: /cwd/testplan.json" ) ;
131+ expect ( consoleModule . log ) . toHaveBeenNthCalledWith ( 1 , ` agent testplan: ${ outputPath } ` ) ;
123132 expect ( consoleModule . log ) . toHaveBeenNthCalledWith ( 2 , "agent selection source: /tmp/agent-output" ) ;
124133 expect ( consoleModule . log ) . toHaveBeenNthCalledWith ( 3 , "agent selection preset: failed" ) ;
125134 expect ( consoleModule . log ) . toHaveBeenNthCalledWith ( 4 , "agent selection tests: 2" ) ;
0 commit comments