@@ -13,10 +13,10 @@ const groupAndCaseForTest = (testInfo: TestInfo) => {
13
13
14
14
if ( titlePath . length > 1 ) {
15
15
caseName = titlePath . pop ( ) ! ;
16
- groupName = titlePath . join ( ' > ' ) ;
16
+ groupName = ` ${ titlePath . join ( ' > ' ) } : ${ testInfo . line } ` ;
17
17
} else if ( titlePath . length === 1 ) {
18
18
caseName = titlePath [ 0 ] ;
19
- groupName = caseName ;
19
+ groupName = ` ${ caseName } : ${ testInfo . line } ` ;
20
20
} else {
21
21
caseName = 'unnamed' ;
22
22
groupName = 'unnamed' ;
@@ -32,63 +32,62 @@ export const PlaywrightAiFixture = () => {
32
32
if ( ! idForPage ) {
33
33
idForPage = randomUUID ( ) ;
34
34
( page as any ) [ midSceneAgentKeyId ] = idForPage ;
35
- pageAgentMap [ idForPage ] = new PageAgent ( page , testId ) ;
35
+ pageAgentMap [ idForPage ] = new PageAgent ( page , ` ${ testId } - ${ idForPage } ` ) ;
36
36
}
37
37
return pageAgentMap [ idForPage ] ;
38
38
} ;
39
39
40
40
return {
41
41
ai : async ( { page } : any , use : any , testInfo : TestInfo ) => {
42
+ const agent = agentForPage ( page , testInfo . testId ) ;
42
43
await use ( async ( taskPrompt : string , opts ?: { type ?: 'action' | 'query' } ) => {
43
44
const { groupName, caseName } = groupAndCaseForTest ( testInfo ) ;
44
- const agent = agentForPage ( page , testInfo . testId ) ;
45
45
const actionType = opts ?. type || 'action' ;
46
46
const result = await agent . ai ( taskPrompt , actionType , caseName , groupName ) ;
47
- if ( agent . dumpFile ) {
48
- testInfo . annotations . push ( {
49
- type : 'PLAYWRIGHT_AI_ACTION' ,
50
- description : JSON . stringify ( {
51
- testId : testInfo . testId ,
52
- dumpPath : agent . dumpFile ,
53
- } ) ,
54
- } ) ;
55
- }
56
47
return result ;
57
48
} ) ;
49
+ if ( agent . dumpFile ) {
50
+ testInfo . annotations . push ( {
51
+ type : 'MIDSCENE_AI_ACTION' ,
52
+ description : JSON . stringify ( {
53
+ testId : testInfo . testId ,
54
+ dumpPath : agent . dumpFile ,
55
+ } ) ,
56
+ } ) ;
57
+ }
58
58
} ,
59
59
aiAction : async ( { page } : any , use : any , testInfo : TestInfo ) => {
60
+ const agent = agentForPage ( page , testInfo . testId ) ;
60
61
await use ( async ( taskPrompt : string ) => {
61
- const agent = agentForPage ( page , testInfo . testId ) ;
62
-
63
62
const { groupName, caseName } = groupAndCaseForTest ( testInfo ) ;
64
63
await agent . aiAction ( taskPrompt , caseName , groupName ) ;
65
- if ( agent . dumpFile ) {
66
- testInfo . annotations . push ( {
67
- type : 'PLAYWRIGHT_AI_ACTION' ,
68
- description : JSON . stringify ( {
69
- testId : testInfo . testId ,
70
- dumpPath : agent . dumpFile ,
71
- } ) ,
72
- } ) ;
73
- }
74
64
} ) ;
65
+ if ( agent . dumpFile ) {
66
+ testInfo . annotations . push ( {
67
+ type : 'MIDSCENE_AI_ACTION' ,
68
+ description : JSON . stringify ( {
69
+ testId : testInfo . testId ,
70
+ dumpPath : agent . dumpFile ,
71
+ } ) ,
72
+ } ) ;
73
+ }
75
74
} ,
76
75
aiQuery : async ( { page } : any , use : any , testInfo : TestInfo ) => {
76
+ const agent = agentForPage ( page , testInfo . testId ) ;
77
77
await use ( async function ( demand : any ) {
78
- const agent = agentForPage ( page , testInfo . testId ) ;
79
78
const { groupName, caseName } = groupAndCaseForTest ( testInfo ) ;
80
79
const result = await agent . aiQuery ( demand , caseName , groupName ) ;
81
- if ( agent . dumpFile ) {
82
- testInfo . annotations . push ( {
83
- type : 'PLAYWRIGHT_AI_ACTION' ,
84
- description : JSON . stringify ( {
85
- testId : testInfo . testId ,
86
- dumpPath : agent . dumpFile ,
87
- } ) ,
88
- } ) ;
89
- }
90
80
return result ;
91
81
} ) ;
82
+ if ( agent . dumpFile ) {
83
+ testInfo . annotations . push ( {
84
+ type : 'MIDSCENE_AI_ACTION' ,
85
+ description : JSON . stringify ( {
86
+ testId : testInfo . testId ,
87
+ dumpPath : agent . dumpFile ,
88
+ } ) ,
89
+ } ) ;
90
+ }
92
91
} ,
93
92
} ;
94
93
} ;
0 commit comments