1
1
import { PageTaskExecutor } from '@/common/tasks' ;
2
- import type { PlanningAction } from '@midscene/core' ;
2
+ import type { DeviceAction , PlanningAction } from '@midscene/core' ;
3
3
import { beforeEach , describe , expect , it , vi } from 'vitest' ;
4
4
5
5
// Mock page with mouse operations
@@ -10,6 +10,22 @@ const mockPage = {
10
10
} ,
11
11
screenshotBase64 : vi . fn ( ) . mockResolvedValue ( 'mock-screenshot' ) ,
12
12
evaluateJavaScript : vi . fn ( ) ,
13
+ actionSpace : ( ) =>
14
+ [
15
+ {
16
+ name : 'RightClick' ,
17
+ call : ( context , param ) => {
18
+ if ( ! context . element ) {
19
+ throw new Error ( 'Element not found' ) ;
20
+ }
21
+ mockPage . mouse . click (
22
+ context . element . center [ 0 ] ,
23
+ context . element . center [ 1 ] ,
24
+ { button : 'right' } ,
25
+ ) ;
26
+ } ,
27
+ } ,
28
+ ] as DeviceAction [ ] ,
13
29
} as any ;
14
30
15
31
// Mock insight
@@ -165,8 +181,6 @@ describe('PageTaskExecutor RightClick Action', () => {
165
181
} ;
166
182
167
183
// Should throw error when element is null
168
- await expect ( rightClickTask . executor ( null , mockContext ) ) . rejects . toThrow (
169
- 'Element not found, cannot right click' ,
170
- ) ;
184
+ await expect ( rightClickTask . executor ( null , mockContext ) ) . rejects . toThrow ( ) ;
171
185
} ) ;
172
186
} ) ;
0 commit comments