@@ -23,6 +23,7 @@ const insightFindTask = (shouldThrow?: boolean) => {
23
23
param : {
24
24
prompt : 'test' ,
25
25
} ,
26
+ locate : null ,
26
27
async executor ( param , taskContext ) {
27
28
if ( shouldThrow ) {
28
29
const { task } = taskContext ;
@@ -46,70 +47,58 @@ const insightFindTask = (shouldThrow?: boolean) => {
46
47
return insightFindTask ;
47
48
} ;
48
49
49
- vi . setConfig ( {
50
- testTimeout : 40 * 1000 ,
51
- } ) ;
52
-
53
50
describe ( 'executor' , ( ) => {
54
- it (
55
- 'insight - basic run' ,
56
- async ( ) => {
57
- const insightTask1 = insightFindTask ( ) ;
58
- const flushResultData = 'abcdef' ;
59
- const taskParam = {
60
- action : 'tap' ,
61
- anything : 'acceptable' ,
62
- } ;
63
- const tapperFn = vi . fn ( ) ;
64
- const actionTask : ExecutionTaskActionApply = {
65
- type : 'Action' ,
66
- param : taskParam ,
67
- executor : tapperFn ,
68
- } ;
69
- const actionTask2 : ExecutionTaskActionApply = {
70
- type : 'Action' ,
71
- param : taskParam ,
72
- executor : async ( ) => {
73
- return {
74
- output : flushResultData ,
75
- } as any ;
76
- } ,
77
- } ;
51
+ it ( 'insight - basic run' , async ( ) => {
52
+ const insightTask1 = insightFindTask ( ) ;
53
+ const flushResultData = 'abcdef' ;
54
+ const taskParam = {
55
+ action : 'tap' ,
56
+ anything : 'acceptable' ,
57
+ } ;
58
+ const tapperFn = vi . fn ( ) ;
59
+ const actionTask : ExecutionTaskActionApply = {
60
+ type : 'Action' ,
61
+ param : taskParam ,
62
+ locate : null ,
63
+ executor : tapperFn ,
64
+ } ;
65
+ const actionTask2 : ExecutionTaskActionApply = {
66
+ type : 'Action' ,
67
+ param : taskParam ,
68
+ locate : null ,
69
+ executor : async ( ) => {
70
+ return {
71
+ output : flushResultData ,
72
+ } as any ;
73
+ } ,
74
+ } ;
78
75
79
- const inputTasks = [ insightTask1 , actionTask , actionTask2 ] ;
80
-
81
- const executor = new Executor (
82
- 'test' ,
83
- 'hello, this is a test' ,
84
- inputTasks ,
85
- ) ;
86
- const flushResult = await executor . flush ( ) ;
87
- const tasks = executor . tasks as ExecutionTaskInsightLocate [ ] ;
88
- const { element } = tasks [ 0 ] . output || { } ;
89
- expect ( element ) . toBeTruthy ( ) ;
90
-
91
- expect ( tasks . length ) . toBe ( inputTasks . length ) ;
92
- expect ( tasks [ 0 ] . status ) . toBe ( 'finished' ) ;
93
- expect ( tasks [ 0 ] . output ) . toMatchSnapshot ( ) ;
94
- expect ( tasks [ 0 ] . log ?. dump ) . toBeTruthy ( ) ;
95
- expect ( tasks [ 0 ] . timing ?. end ) . toBeTruthy ( ) ;
96
- expect ( tasks [ 0 ] . cache ) . toBeTruthy ( ) ;
97
- expect ( tasks [ 0 ] . cache ?. hit ) . toEqual ( false ) ;
98
-
99
- expect ( tapperFn ) . toBeCalledTimes ( 1 ) ;
100
- expect ( tapperFn . mock . calls [ 0 ] [ 0 ] ) . toBe ( taskParam ) ;
101
- expect ( tapperFn . mock . calls [ 0 ] [ 1 ] . element ) . toBe ( element ) ;
102
- expect ( tapperFn . mock . calls [ 0 ] [ 1 ] . task ) . toBeTruthy ( ) ;
103
-
104
- const dump = executor . dump ( ) ;
105
- expect ( dump . logTime ) . toBeTruthy ( ) ;
106
-
107
- expect ( flushResult ) . toBe ( flushResultData ) ;
108
- } ,
109
- {
110
- timeout : 999 * 1000 ,
111
- } ,
112
- ) ;
76
+ const inputTasks = [ insightTask1 , actionTask , actionTask2 ] ;
77
+
78
+ const executor = new Executor ( 'test' , 'hello, this is a test' , inputTasks ) ;
79
+ const flushResult = await executor . flush ( ) ;
80
+ const tasks = executor . tasks as ExecutionTaskInsightLocate [ ] ;
81
+ expect ( executor . isInErrorState ( ) ) . toBeFalsy ( ) ;
82
+ const { element } = tasks [ 0 ] . output || { } ;
83
+ expect ( element ) . toBeTruthy ( ) ;
84
+
85
+ expect ( tasks . length ) . toBe ( inputTasks . length ) ;
86
+ expect ( tasks [ 0 ] . status ) . toBe ( 'finished' ) ;
87
+ expect ( tasks [ 0 ] . output ) . toMatchSnapshot ( ) ;
88
+ expect ( tasks [ 0 ] . log ?. dump ) . toBeTruthy ( ) ;
89
+ expect ( tasks [ 0 ] . timing ?. end ) . toBeTruthy ( ) ;
90
+ expect ( tasks [ 0 ] . cache ) . toBeTruthy ( ) ;
91
+ expect ( tasks [ 0 ] . cache ?. hit ) . toEqual ( false ) ;
92
+
93
+ expect ( tapperFn ) . toBeCalledTimes ( 1 ) ;
94
+ expect ( tapperFn . mock . calls [ 0 ] [ 0 ] ) . toBe ( taskParam ) ;
95
+ expect ( tapperFn . mock . calls [ 0 ] [ 1 ] . task ) . toBeTruthy ( ) ;
96
+
97
+ const dump = executor . dump ( ) ;
98
+ expect ( dump . logTime ) . toBeTruthy ( ) ;
99
+
100
+ expect ( flushResult ) . toBe ( flushResultData ) ;
101
+ } ) ;
113
102
114
103
it ( 'insight - init and append' , async ( ) => {
115
104
const initExecutor = new Executor ( 'test' ) ;
@@ -123,6 +112,7 @@ describe('executor', () => {
123
112
action : 'tap' ,
124
113
element : 'previous' ,
125
114
} ,
115
+ locate : null ,
126
116
executor : async ( ) => {
127
117
// delay 500
128
118
await new Promise ( ( resolve ) => setTimeout ( resolve , 500 ) ) ;
0 commit comments