@@ -14,40 +14,68 @@ import type Log from '../instruments/instrument-model'
14
14
import Session , { SessionProps } from '../sessions/sessions-model'
15
15
16
16
export default class Attempt {
17
- @ observable agents : Agent [ ] = [ ]
18
- @ observable sessions : Record < string , Session > = { }
19
- @ observable commands : Command [ ] = [ ]
20
- @ observable err ?: Err = undefined
21
- @ observable hooks : Hook [ ] = [ ]
17
+ agents : Agent [ ] = [ ]
18
+ sessions : Record < string , Session > = { }
19
+ commands : Command [ ] = [ ]
20
+ err ?: Err = undefined
21
+ hooks : Hook [ ] = [ ]
22
22
// TODO: make this an enum with states: 'QUEUED, ACTIVE, INACTIVE'
23
- @ observable isActive : boolean | null = null
24
- @ observable routes : Route [ ] = [ ]
25
- @ observable _state ?: TestState | null = null
26
- @ observable _testOuterStatus ?: TestState = undefined
27
- @ observable _invocationCount : number = 0
28
- @ observable invocationDetails ?: FileDetails
23
+ isActive : boolean | null = null
24
+ routes : Route [ ] = [ ]
25
+ _state ?: TestState | null = null
26
+ _testOuterStatus ?: TestState = undefined
27
+ _invocationCount : number = 0
28
+ invocationDetails ?: FileDetails
29
29
// eslint-disable-next-line @typescript-eslint/no-unused-vars
30
- @ observable hookCount : { [ name in HookName ] : number } = {
30
+ hookCount : { [ name in HookName ] : number } = {
31
31
'before all' : 0 ,
32
32
'before each' : 0 ,
33
33
'after all' : 0 ,
34
34
'after each' : 0 ,
35
35
'test body' : 0 ,
36
36
'studio commands' : 0 ,
37
37
}
38
- @ observable _isOpen : boolean | null = null
38
+ _isOpen : boolean | null = null
39
39
40
- @ observable isOpenWhenLast : boolean | null = null
40
+ isOpenWhenLast : boolean | null = null
41
41
_callbackAfterUpdate : Function | null = null
42
42
testId : string
43
43
44
- @ observable id : number
44
+ id : number
45
45
test : Test
46
46
47
47
_logs : { [ key : string ] : Log } = { }
48
48
49
49
constructor ( props : TestProps , test : Test ) {
50
- makeObservable ( this )
50
+ makeObservable ( this , {
51
+ agents : observable ,
52
+ sessions : observable ,
53
+ commands : observable ,
54
+ err : observable ,
55
+ hooks : observable ,
56
+ isActive : observable ,
57
+ routes : observable ,
58
+ _state : observable ,
59
+ _testOuterStatus : observable ,
60
+ _invocationCount : observable ,
61
+ invocationDetails : observable ,
62
+ hookCount : observable ,
63
+ _isOpen : observable ,
64
+ isOpenWhenLast : observable ,
65
+ id : observable ,
66
+ hasCommands : computed ,
67
+ isLongRunning : computed ,
68
+ _hasLongRunningCommand : computed ,
69
+ state : computed ,
70
+ error : computed ,
71
+ isLast : computed ,
72
+ isOpen : computed ,
73
+ start : action ,
74
+ update : action ,
75
+ setIsOpen : action ,
76
+ finish : action ,
77
+ } )
78
+
51
79
this . testId = props . id
52
80
this . id = props . currentRetry || 0
53
81
this . test = test
@@ -66,25 +94,25 @@ export default class Attempt {
66
94
_ . each ( props . routes , this . addLog )
67
95
}
68
96
69
- @ computed get hasCommands ( ) {
97
+ get hasCommands ( ) {
70
98
return ! ! this . commands . length
71
99
}
72
100
73
- @ computed get isLongRunning ( ) {
101
+ get isLongRunning ( ) {
74
102
return this . isActive && this . _hasLongRunningCommand
75
103
}
76
104
77
- @ computed get _hasLongRunningCommand ( ) {
105
+ get _hasLongRunningCommand ( ) {
78
106
return _ . some ( this . commands , ( command ) => {
79
107
return command . isLongRunning
80
108
} )
81
109
}
82
110
83
- @ computed get state ( ) {
111
+ get state ( ) {
84
112
return this . _state || ( this . isActive ? 'active' : 'processing' )
85
113
}
86
114
87
- @ computed get error ( ) {
115
+ get error ( ) {
88
116
const command = this . err ?. isCommandErr ? this . commandMatchingErr ( ) : undefined
89
117
90
118
return {
@@ -94,11 +122,11 @@ export default class Attempt {
94
122
}
95
123
}
96
124
97
- @ computed get isLast ( ) {
125
+ get isLast ( ) {
98
126
return this . id === this . test . lastAttempt . id
99
127
}
100
128
101
- @ computed get isOpen ( ) {
129
+ get isOpen ( ) {
102
130
if ( this . _isOpen !== null ) {
103
131
return this . _isOpen
104
132
}
@@ -166,11 +194,11 @@ export default class Attempt {
166
194
. last ( )
167
195
}
168
196
169
- @ action start ( ) {
197
+ start ( ) {
170
198
this . isActive = true
171
199
}
172
200
173
- @ action update ( props : UpdatableTestProps ) {
201
+ update ( props : UpdatableTestProps ) {
174
202
if ( props . state ) {
175
203
this . _state = props . state
176
204
}
@@ -200,11 +228,11 @@ export default class Attempt {
200
228
}
201
229
}
202
230
203
- @ action setIsOpen ( isOpen : boolean ) {
231
+ setIsOpen ( isOpen : boolean ) {
204
232
this . _isOpen = isOpen
205
233
}
206
234
207
- @ action finish ( props : UpdatableTestProps , isInteractive : boolean ) {
235
+ finish ( props : UpdatableTestProps , isInteractive : boolean ) {
208
236
this . update ( props )
209
237
this . isActive = false
210
238
0 commit comments