-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathast.ts
More file actions
285 lines (238 loc) · 5.73 KB
/
ast.ts
File metadata and controls
285 lines (238 loc) · 5.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
export interface Identifier {
type: 'Identifier'
name: string
}
export interface StringLiteral {
type: 'StringLiteral'
value: string
}
export interface NullLiteral {
type: 'NullLiteral'
}
export interface NewPageExpression {
type: 'NewPageExpression'
}
export interface ClosePageExpression {
type: 'ClosePageExpression'
target: Expression
}
export interface NewCssLocatorExpression {
type: 'NewCssLocatorExpression'
selector: Expression
page: Expression
}
export interface NewTestIdLocatorExpression {
type: 'NewTestIdLocatorExpression'
testId: Expression
page: Expression
}
export interface NewAltTextLocatorExpression {
type: 'NewAltTextLocatorExpression'
text: Expression
page: Expression
options: Expression | null
}
export interface NewLabelLocatorExpression {
type: 'NewLabelLocatorExpression'
text: Expression
page: Expression
options: Expression | null
}
export interface NewPlaceholderLocatorExpression {
type: 'NewPlaceholderLocatorExpression'
text: Expression
page: Expression
options: Expression | null
}
export interface NewTitleLocatorExpression {
type: 'NewTitleLocatorExpression'
text: Expression
page: Expression
options: Expression | null
}
export interface TextLocatorOptionsExpression {
type: 'TextLocatorOptionsExpression'
exact?: boolean
}
export interface RoleLocatorOptionsExpression {
type: 'RoleLocatorOptionsExpression'
name?: {
value: string
exact?: boolean
}
}
export interface NewRoleLocatorExpression {
type: 'NewRoleLocatorExpression'
role: Expression
page: Expression
options: Expression | null
}
export interface GotoExpression {
type: 'GotoExpression'
target: Expression
url: Expression
}
export interface ReloadExpression {
type: 'ReloadExpression'
target: Expression
}
export interface ClickOptionsExpression {
type: 'ClickOptionsExpression'
button: 'left' | 'middle' | 'right'
modifiers: Array<'Control' | 'Shift' | 'Alt' | 'Meta'>
}
export interface FillTextExpression {
type: 'FillTextExpression'
target: Expression
value: Expression
}
export interface ClickExpression {
type: 'ClickExpression'
locator: Expression
options: Expression | null
}
export interface ClearExpression {
type: 'ClearExpression'
locator: Expression
}
export interface CheckExpression {
type: 'CheckExpression'
locator: Expression
checked: boolean
}
export interface SelectOptionValueExpression {
type: 'SelectOptionValueExpression'
value?: string
label?: string
index?: number
}
export interface SelectOptionsExpression {
type: 'SelectOptionsExpression'
locator: Expression
selected: Expression[]
multiple: boolean
}
export interface WaitForOptionsExpression {
type: 'WaitForOptionsExpression'
timeout?: number
state?: 'attached' | 'detached' | 'visible' | 'hidden'
}
export interface WaitForExpression {
type: 'WaitForExpression'
target: Expression
options: Expression | null
}
export interface WaitForNavigationExpression {
type: 'WaitForNavigationExpression'
target: Expression
}
export interface PromiseAllExpression {
type: 'PromiseAllExpression'
expressions: Expression[]
}
export interface TextContainsAssertion {
type: 'TextContainsAssertion'
text: Expression
}
export interface IsVisibleAssertion {
type: 'IsVisibleAssertion'
}
export interface IsHiddenAssertion {
type: 'IsHiddenAssertion'
}
export interface IsAttributeEqualToAssertion {
type: 'IsAttributeEqualToAssertion'
attribute: Expression
value: Expression
}
export interface IsCheckedAssertion {
type: 'IsCheckedAssertion'
}
export interface IsNotCheckedAssertion {
type: 'IsNotCheckedAssertion'
}
export interface IsIndeterminateAssertion {
type: 'IsIndeterminateAssertion'
}
export interface HasValueAssertion {
type: 'HasValueAssertion'
expected: [Expression, ...Expression[]]
}
export type Assertion =
| TextContainsAssertion
| IsVisibleAssertion
| IsHiddenAssertion
| IsAttributeEqualToAssertion
| IsCheckedAssertion
| IsNotCheckedAssertion
| IsIndeterminateAssertion
| HasValueAssertion
export interface ExpectExpression {
type: 'ExpectExpression'
actual: Expression
expected: Assertion
}
export type Expression =
| Identifier
| StringLiteral
| NullLiteral
| NewPageExpression
| ClosePageExpression
| NewRoleLocatorExpression
| RoleLocatorOptionsExpression
| TextLocatorOptionsExpression
| NewLabelLocatorExpression
| NewPlaceholderLocatorExpression
| NewTitleLocatorExpression
| NewAltTextLocatorExpression
| NewCssLocatorExpression
| NewTestIdLocatorExpression
| GotoExpression
| ReloadExpression
| ClearExpression
| ClickExpression
| ClickOptionsExpression
| FillTextExpression
| CheckExpression
| SelectOptionValueExpression
| SelectOptionsExpression
| ExpectExpression
| WaitForExpression
| WaitForOptionsExpression
| WaitForNavigationExpression
| PromiseAllExpression
export interface VariableDeclaration {
type: 'VariableDeclaration'
kind: 'const' | 'let'
name: string
value: Expression
}
export interface Allocation {
type: 'Allocation'
declarations: VariableDeclaration[]
statements: Statement[]
disposers: Statement[]
}
export type Declaration = VariableDeclaration | Allocation
export interface ExpressionStatement {
type: 'ExpressionStatement'
expression: Expression
}
export interface AssignmentStatement {
type: 'AssignmentStatement'
target: Identifier
value: Expression
}
export type Statement = Declaration | ExpressionStatement | AssignmentStatement
export type Node = Expression | Statement
export interface Scenario {
type: 'Scenario'
body: Statement[]
}
export type DefaultScenario = Scenario & {
name?: string
}
export interface Test {
defaultScenario?: DefaultScenario
scenarios: Record<string, Scenario>
}