@@ -2,39 +2,41 @@ import { afterAll, beforeAll, describe, expect, test } from "vite-plus/test";
22import { mkdtemp , rm , writeFile } from "node:fs/promises" ;
33import { tmpdir } from "node:os" ;
44import { join } from "node:path" ;
5- import { cliPackageRoot , parseStdoutJson , runCli } from "./helpers.ts" ;
6-
7- const DEMO_WORKFLOWS = [
8- "chat-basic.json" ,
9- "chained-text.json" ,
10- "chained-text.yaml" ,
11- "image-generate.json" ,
12- "image-gen/image-gen-workflow.json" ,
13- "image-to-video.json" ,
14- "image2video/lego/lego-build-sequence.json" ,
15- "image2video/nine-grid-storyboard.json" ,
16- "image2video/virtual-tryon/virtual-tryon-workflow.json" ,
17- "logic-nodes.json" ,
18- "commerce/amazon-listing/amazon-listing-workflow.json" ,
19- "commerce/audio-meeting-summary/workflow.json" ,
20- "commerce/cool-background/cool-background-workflow.json" ,
21- "commerce/dress-on-model/dress-on-model-workflow.json" ,
22- "commerce/flatlay/flatlay-workflow.json" ,
23- "commerce/poster-i18n/poster-i18n-workflow.json" ,
24- "commerce/scatter-flatlay/scatter-flatlay-workflow.json" ,
25- "commerce/six-view-product/six-view-workflow.json" ,
26- "commerce/valentine-marketing/valentine-marketing-workflow.json" ,
27- ] ;
5+ import { parseStdoutJson , runCli } from "./helpers.ts" ;
286
297describe ( "e2e: pipeline" , ( ) => {
308 let tempDir : string ;
9+ let chatBasicPath : string ;
3110 let invalidPipelinePath : string ;
3211
33- const sceneRoot = join ( cliPackageRoot , "scene" ) ;
34- const scenePipelinePath = join ( sceneRoot , "chat-basic.json" ) ;
35-
3612 beforeAll ( async ( ) => {
3713 tempDir = await mkdtemp ( join ( tmpdir ( ) , "bailian-cli-pipeline-" ) ) ;
14+ chatBasicPath = join ( tempDir , "chat-basic.json" ) ;
15+ await writeFile (
16+ chatBasicPath ,
17+ JSON . stringify ( {
18+ version : "workflow/v1" ,
19+ inputs : {
20+ type : "object" ,
21+ properties : {
22+ message : { type : "string" , default : "Hello from the demo pipeline." } ,
23+ } ,
24+ additionalProperties : false ,
25+ } ,
26+ steps : [
27+ {
28+ id : "chat" ,
29+ type : "text/chat" ,
30+ input : {
31+ message : { $input : "/message" } ,
32+ system : "You are a concise assistant for pipeline demos." ,
33+ temperature : 0.2 ,
34+ } ,
35+ } ,
36+ ] ,
37+ } ) ,
38+ ) ;
39+
3840 invalidPipelinePath = join ( tempDir , "invalid-dependency-pipeline.json" ) ;
3941 await writeFile (
4042 invalidPipelinePath ,
@@ -83,11 +85,11 @@ describe("e2e: pipeline", () => {
8385 expect ( stderr ) . toMatch ( / p i p e l i n e v a l i d a t e | w o r k f l o w \. j s o n | o u t p u t j s o n / i) ;
8486 } ) ;
8587
86- test ( "pipeline validate --output json 校验 scene workflow" , async ( ) => {
88+ test ( "pipeline validate --output json 校验合法 workflow" , async ( ) => {
8789 const { stdout, stderr, exitCode } = await runCli ( [
8890 "pipeline" ,
8991 "validate" ,
90- scenePipelinePath ,
92+ chatBasicPath ,
9193 "--output" ,
9294 "json" ,
9395 ] ) ;
@@ -98,28 +100,13 @@ describe("e2e: pipeline", () => {
98100 } ) ;
99101
100102 test ( "pipeline validate 使用 config 输出格式" , async ( ) => {
101- const { stdout, stderr, exitCode } = await runCli ( [ "pipeline" , "validate" , scenePipelinePath ] , {
103+ const { stdout, stderr, exitCode } = await runCli ( [ "pipeline" , "validate" , chatBasicPath ] , {
102104 DASHSCOPE_OUTPUT : "text" ,
103105 } ) ;
104106 expect ( exitCode , stderr ) . toBe ( 0 ) ;
105107 expect ( stdout ) . toBe ( "Pipeline definition is valid.\n" ) ;
106108 } ) ;
107109
108- test ( "pipeline validate --output json 校验迁移后的全部 scene workflows" , async ( ) => {
109- for ( const workflow of DEMO_WORKFLOWS ) {
110- const { stdout, stderr, exitCode } = await runCli ( [
111- "pipeline" ,
112- "validate" ,
113- join ( sceneRoot , workflow ) ,
114- "--output" ,
115- "json" ,
116- ] ) ;
117- expect ( exitCode , `${ workflow } \n${ stderr } ` ) . toBe ( 0 ) ;
118- const data = parseStdoutJson < { valid ?: boolean ; issues ?: string [ ] } > ( stdout ) ;
119- expect ( data , workflow ) . toEqual ( { valid : true , issues : [ ] } ) ;
120- }
121- } ) ;
122-
123110 test ( "pipeline validate 拒绝非法依赖 workflow" , async ( ) => {
124111 const { stdout, stderr, exitCode } = await runCli ( [
125112 "pipeline" ,
@@ -145,7 +132,7 @@ describe("e2e: pipeline", () => {
145132 const { stdout, stderr, exitCode } = await runCli ( [
146133 "pipeline" ,
147134 "run" ,
148- scenePipelinePath ,
135+ chatBasicPath ,
149136 "--input" ,
150137 '{"message":"hello"}' ,
151138 "--dry-run" ,
@@ -179,7 +166,7 @@ describe("e2e: pipeline", () => {
179166 [
180167 "pipeline" ,
181168 "run" ,
182- scenePipelinePath ,
169+ chatBasicPath ,
183170 "--input" ,
184171 '{"message":"hello"}' ,
185172 "--dry-run" ,
@@ -196,7 +183,7 @@ describe("e2e: pipeline", () => {
196183 const { stderr, exitCode } = await runCli ( [
197184 "pipeline" ,
198185 "run" ,
199- scenePipelinePath ,
186+ chatBasicPath ,
200187 "--input" ,
201188 '{"message":"hello"}' ,
202189 "--dry-run" ,
@@ -212,7 +199,7 @@ describe("e2e: pipeline", () => {
212199 const { stdout, stderr, exitCode } = await runCli ( [
213200 "pipeline" ,
214201 "run" ,
215- scenePipelinePath ,
202+ chatBasicPath ,
216203 "--input" ,
217204 '{"message":"hello"}' ,
218205 "--dry-run" ,
@@ -240,7 +227,7 @@ describe("e2e: pipeline", () => {
240227 const { stdout, stderr, exitCode } = await runCli ( [
241228 "pipeline" ,
242229 "run" ,
243- scenePipelinePath ,
230+ chatBasicPath ,
244231 "--dry-run" ,
245232 "--events" ,
246233 "bogus" ,
0 commit comments