wisp-schema 1.0.4 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d4abc3b624c92af7aadcbf233621d7dd14bd9f7c6be7a52be60aeb99ee84ba7
4
- data.tar.gz: 3b2e61a24d7f9d5325d1147a59c95d8ab74de977d041a6b9699ffbcc1aa97640
3
+ metadata.gz: c39370e77a573a96df3057aeeac77d2a6ac7cf3c6b9ad4bebfdf543492a9d215
4
+ data.tar.gz: 29bab08d4ff6412aa9d1eff0c2af13d3367c250ef21e8b5d08ccea008770af3b
5
5
  SHA512:
6
- metadata.gz: 3e476aa00de99f780fcffd78bea1c1a40cb2ad48ce69c93ae76bacaaadc32d24a3bc515c9112e78f53a781faa03edef9def86e2f347beb31fa1bd87af3bf23bb
7
- data.tar.gz: c271a6d930237e77469b66eedd46fbb2f1e7fa32e3b8a7b9fc6ddcb72703248ac4bcdd18ea1a47e7e9426cac6ca56bd5cc7ea47792d11099db4d8d8b79d32d0f
6
+ metadata.gz: e91fab4052ffcc15083c7c214583b39537cc666a22ab1a4af9809b576769f8d0e439d3b60187afefa5eb2a2f8f2e4737466c84fa5462d66347d67ab199f20d82
7
+ data.tar.gz: eb08a417159349fe4ed8f9f5fe7c4dd34438149e29efa7f8f7d0d4615b496674721fd52f3a0363925ad449abb2f0f721f8960fdb3157f3ede3438252a6d1e6e4
data/canary-wisp.json CHANGED
@@ -83,6 +83,7 @@
83
83
  },
84
84
  "click": {
85
85
  "type": "object",
86
+ "action_type": "action",
86
87
  "title": "Click",
87
88
  "description": "Clicks on the UI element",
88
89
  "properties": {
@@ -90,9 +91,11 @@
90
91
  "enum": ["click"]
91
92
  },
92
93
  "embedded_test_id": {"title": "Embedded Test ID", "type": "integer"},
94
+ "id": {"title": "Action ID", "type": "integer"},
93
95
  "target": {
94
96
  "title": "Target",
95
- "$ref": "#/definitions/noun"
97
+ "$ref": "#/definitions/noun",
98
+ "type": "ui_element_reference"
96
99
  },
97
100
  "button": {"title": "Mouse Button", "type": "string", "enum": ["left", "middle", "right"]},
98
101
  "hold": {"title": "And Hold", "type": "boolean"},
@@ -103,6 +106,7 @@
103
106
  },
104
107
  "double_click": {
105
108
  "type": "object",
109
+ "action_type": "action",
106
110
  "title": "Double Click",
107
111
  "description": "Double-clicks on the UI element",
108
112
  "properties": {
@@ -110,9 +114,11 @@
110
114
  "enum": ["double_click"]
111
115
  },
112
116
  "embedded_test_id": {"title": "Embedded Test ID", "type": "integer"},
117
+ "id": {"title": "Action ID", "type": "integer"},
113
118
  "target": {
114
119
  "title": "Target",
115
- "$ref": "#/definitions/noun"
120
+ "$ref": "#/definitions/noun",
121
+ "type": "ui_element_reference"
116
122
  }
117
123
  },
118
124
  "additionalProperties": false,
@@ -120,6 +126,7 @@
120
126
  },
121
127
  "fill": {
122
128
  "type": "object",
129
+ "action_type": "action",
123
130
  "title": "Fill",
124
131
  "description": "Fills the text field with specified content",
125
132
  "properties": {
@@ -127,9 +134,11 @@
127
134
  "enum": ["fill"]
128
135
  },
129
136
  "embedded_test_id": {"title": "Embedded Test ID", "type": "integer"},
137
+ "id": {"title": "Action ID", "type": "integer"},
130
138
  "target": {
131
139
  "title": "Target",
132
- "$ref": "#/definitions/noun"
140
+ "$ref": "#/definitions/noun",
141
+ "type": "ui_element_reference"
133
142
  },
134
143
  "text": {"title": "Text", "type": "string"}
135
144
  },
@@ -138,6 +147,7 @@
138
147
  },
139
148
  "type": {
140
149
  "type": "object",
150
+ "action_type": "action",
141
151
  "title": "Type",
142
152
  "description": "Types in specified text",
143
153
  "properties": {
@@ -145,6 +155,7 @@
145
155
  "enum": ["type"]
146
156
  },
147
157
  "embedded_test_id": {"title": "Embedded Test ID", "type": "integer"},
158
+ "id": {"title": "Action ID", "type": "integer"},
148
159
  "text": {"title": "Text", "type": "string"}
149
160
  },
150
161
  "additionalProperties": false,
@@ -152,6 +163,7 @@
152
163
  },
153
164
  "send_key": {
154
165
  "type": "object",
166
+ "action_type": "action",
155
167
  "title": "Press Key",
156
168
  "description": "Press specified key or key combination.",
157
169
  "properties": {
@@ -159,6 +171,7 @@
159
171
  "enum": ["send_key"]
160
172
  },
161
173
  "embedded_test_id": {"title": "Embedded Test ID", "type": "integer"},
174
+ "id": {"title": "Action ID", "type": "integer"},
162
175
  "key": {"title": "Key", "type": "string"},
163
176
  "modifier": {"title": "Modifier", "type": "string"}
164
177
  },
@@ -167,6 +180,7 @@
167
180
  },
168
181
  "hover": {
169
182
  "type": "object",
183
+ "action_type": "action",
170
184
  "title": "Hover",
171
185
  "description": "Hovers over specified element",
172
186
  "properties": {
@@ -174,9 +188,11 @@
174
188
  "enum": ["hover"]
175
189
  },
176
190
  "embedded_test_id": {"title": "Embedded Test ID", "type": "integer"},
191
+ "id": {"title": "Action ID", "type": "integer"},
177
192
  "target": {
178
193
  "title": "Target",
179
- "$ref": "#/definitions/noun"
194
+ "$ref": "#/definitions/noun",
195
+ "type": "ui_element_reference"
180
196
  }
181
197
  },
182
198
  "additionalProperties": false,
@@ -184,6 +200,7 @@
184
200
  },
185
201
  "select": {
186
202
  "type": "object",
203
+ "action_type": "action",
187
204
  "title": "Select",
188
205
  "description": "Selects specified item from the dropdown",
189
206
  "properties": {
@@ -191,9 +208,11 @@
191
208
  "enum": ["select"]
192
209
  },
193
210
  "embedded_test_id": {"title": "Embedded Test ID", "type": "integer"},
211
+ "id": {"title": "Action ID", "type": "integer"},
194
212
  "target": {
195
213
  "title": "Target",
196
- "$ref": "#/definitions/noun"
214
+ "$ref": "#/definitions/noun",
215
+ "type": "ui_element_reference"
197
216
  },
198
217
  "option": {
199
218
  "title": "Option",
@@ -205,19 +224,22 @@
205
224
  },
206
225
  "refresh": {
207
226
  "type": "object",
227
+ "action_type": "action",
208
228
  "title": "Refresh",
209
229
  "description": "Refreshes the webpage",
210
230
  "properties": {
211
231
  "action": {
212
232
  "enum": ["refresh"]
213
233
  },
214
- "embedded_test_id": {"title": "Embedded Test ID", "type": "integer"}
234
+ "embedded_test_id": {"title": "Embedded Test ID", "type": "integer"},
235
+ "id": {"title": "Action ID", "type": "integer"}
215
236
  },
216
237
  "additionalProperties": false,
217
238
  "required": ["action"]
218
239
  },
219
240
  "navigate": {
220
241
  "type": "object",
242
+ "action_type": "action",
221
243
  "title": "Navigate",
222
244
  "description": "Navigates to specified URL",
223
245
  "properties": {
@@ -225,6 +247,7 @@
225
247
  "enum": ["navigate"]
226
248
  },
227
249
  "embedded_test_id": {"title": "Embedded Test ID", "type": "integer"},
250
+ "id": {"title": "Action ID", "type": "integer"},
228
251
  "url": {"title": "URL", "type": "string"},
229
252
  "tab": {"title": "Tab", "type": "string", "enum": ["current", "new", "incognito"]}
230
253
  },
@@ -233,19 +256,22 @@
233
256
  },
234
257
  "close_tab": {
235
258
  "type": "object",
259
+ "action_type": "action",
236
260
  "title": "Close Tab",
237
261
  "description": "Closes current browser tab",
238
262
  "properties": {
239
263
  "action": {
240
264
  "enum": ["close_tab"]
241
265
  },
242
- "embedded_test_id": {"title": "Embedded Test ID", "type": "integer"}
266
+ "embedded_test_id": {"title": "Embedded Test ID", "type": "integer"},
267
+ "id": {"title": "Action ID", "type": "integer"}
243
268
  },
244
269
  "additionalProperties": false,
245
270
  "required": ["action"]
246
271
  },
247
272
  "scroll": {
248
273
  "type": "object",
274
+ "action_type": "action",
249
275
  "title": "Scroll",
250
276
  "description": "Scrolls the page into specified direction until target is reached",
251
277
  "properties": {
@@ -253,10 +279,12 @@
253
279
  "enum": ["scroll"]
254
280
  },
255
281
  "embedded_test_id": {"title": "Embedded Test ID", "type": "integer"},
282
+ "id": {"title": "Action ID", "type": "integer"},
256
283
  "direction": {"title": "Direction", "type": "string", "enum": ["up", "down", "left", "right"]},
257
284
  "target": {
258
285
  "title": "Target",
259
- "$ref": "#/definitions/noun"
286
+ "$ref": "#/definitions/noun",
287
+ "type": "ui_element_reference"
260
288
  }
261
289
  },
262
290
  "additionalProperties": false,
@@ -264,6 +292,7 @@
264
292
  },
265
293
  "wait": {
266
294
  "type": "object",
295
+ "action_type": "action",
267
296
  "title": "Wait",
268
297
  "description": "Waits for a number of seconds",
269
298
  "properties": {
@@ -271,6 +300,7 @@
271
300
  "enum": ["wait"]
272
301
  },
273
302
  "embedded_test_id": {"title": "Embedded Test ID", "type": "integer"},
303
+ "id": {"title": "Action ID", "type": "integer"},
274
304
  "seconds": {"title": "seconds", "type": "integer"}
275
305
  },
276
306
  "additionalProperties": false,
@@ -278,6 +308,7 @@
278
308
  },
279
309
  "drag_and_drop": {
280
310
  "type": "object",
311
+ "action_type": "action",
281
312
  "title": "Drag and drop",
282
313
  "description": "Drag and drop",
283
314
  "properties": {
@@ -285,13 +316,15 @@
285
316
  "enum": ["drag_and_drop"]
286
317
  },
287
318
  "embedded_test_id": {"title": "Embedded Test ID", "type": "integer"},
319
+ "id": {"title": "Action ID", "type": "integer"},
288
320
  "object": {
289
321
  "title": "Object",
290
322
  "$ref": "#/definitions/noun"
291
323
  },
292
324
  "target": {
293
325
  "title": "Target",
294
- "$ref": "#/definitions/noun"
326
+ "$ref": "#/definitions/noun",
327
+ "type": "ui_element_reference"
295
328
  }
296
329
  },
297
330
  "additionalProperties": false,
@@ -299,6 +332,7 @@
299
332
  },
300
333
  "embedded_test": {
301
334
  "type": "object",
335
+ "action_type": "embedded_test",
302
336
  "title": "Embedded Test",
303
337
  "description": "Embeds a Test",
304
338
  "properties": {
@@ -315,6 +349,7 @@
315
349
  },
316
350
  "tester_instruction": {
317
351
  "type": "object",
352
+ "action_type": "action",
318
353
  "title": "Tester Instruction",
319
354
  "description": "An action for a human to complete",
320
355
  "properties": {
@@ -322,6 +357,7 @@
322
357
  "enum": ["tester_instruction"]
323
358
  },
324
359
  "embedded_test_id": {"title": "Embedded Test ID", "type": "integer"},
360
+ "id": {"title": "Action ID", "type": "integer"},
325
361
  "instruction": {"title": "Instruction", "type": "string"}
326
362
  },
327
363
  "additionalProperties": false,
@@ -329,13 +365,15 @@
329
365
  },
330
366
  "observe": {
331
367
  "type": "object",
368
+ "action_type": "assertion",
332
369
  "title": "Observe",
333
370
  "description": "Checks if element of the UI is visible or not",
334
371
  "properties": {
335
- "assertion": {
372
+ "action": {
336
373
  "enum": ["observe"]
337
374
  },
338
375
  "embedded_test_id": {"title": "Embedded Test ID", "type": "integer"},
376
+ "id": {"title": "Action ID", "type": "integer"},
339
377
  "object": {
340
378
  "title": "Object",
341
379
  "$ref": "#/definitions/noun"
@@ -347,35 +385,39 @@
347
385
  }
348
386
  },
349
387
  "additionalProperties": false,
350
- "required": ["assertion", "object", "visibility"]
388
+ "required": ["action", "object", "visibility"]
351
389
  },
352
390
  "loaded": {
353
391
  "type": "object",
392
+ "action_type": "assertion",
354
393
  "title": "Loaded",
355
394
  "description": "Checks if specified page has loaded",
356
395
  "properties": {
357
- "assertion": {
396
+ "action": {
358
397
  "enum": ["loaded"]
359
398
  },
360
399
  "embedded_test_id": {"title": "Embedded Test ID", "type": "integer"},
400
+ "id": {"title": "Action ID", "type": "integer"},
361
401
  "page": {"title": "Page", "type": "string"}
362
402
  },
363
403
  "additionalProperties": false,
364
- "required": ["assertion", "page"]
404
+ "required": ["action", "page"]
365
405
  },
366
406
  "tester_confirmation": {
367
407
  "type": "object",
408
+ "action_type": "assertion",
368
409
  "title": "Tester Confirmation",
369
410
  "description": "Ask a question to confirm a behavior",
370
411
  "properties": {
371
- "assertion": {
412
+ "action": {
372
413
  "enum": ["tester_confirmation"]
373
414
  },
374
415
  "embedded_test_id": {"title": "Embedded Test ID", "type": "integer"},
416
+ "id": {"title": "Action ID", "type": "integer"},
375
417
  "confirmation": {"title": "confirmation", "type": "string"}
376
418
  },
377
419
  "additionalProperties": false,
378
- "required": ["assertion", "confirmation"]
420
+ "required": ["action", "confirmation"]
379
421
  }
380
422
  },
381
423
  "type": "object",
data/lib/version.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Wisp
4
- VERSION = '1.0.4'
5
- STABLE_VERSION = '0.18.1'
4
+ VERSION = '1.2.1'
5
+ STABLE_VERSION = '1.2.1'
6
+ CANARY_VERSION = '2.0.0'
6
7
  end
data/lib/wisp-schema.rb CHANGED
@@ -4,18 +4,44 @@ require 'semantic'
4
4
  require_relative 'version'
5
5
 
6
6
  module Wisp
7
+ class NotSupportedAction < StandardError
8
+ end
9
+
7
10
  SCHEMA_PATH = File.expand_path('../wisp.json', __dir__)
8
11
  NOUNS_PATH = File.expand_path('../nouns.json', __dir__)
9
12
 
10
13
  CANARY_SCHEMA_PATH = File.expand_path('../canary-wisp.json', __dir__)
11
14
  CANARY_NOUNS_PATH = File.expand_path('../canary-nouns.json', __dir__)
12
15
 
16
+ ACTIONS = [
17
+ "click",
18
+ "close_tab",
19
+ "double_click",
20
+ "drag_and_drop",
21
+ "fill",
22
+ "hover",
23
+ "loaded",
24
+ "navigate",
25
+ "observe",
26
+ "refresh",
27
+ "scroll",
28
+ "select",
29
+ "send_key",
30
+ "tester_confirmation",
31
+ "tester_instruction",
32
+ "type",
33
+ "wait",
34
+ ].freeze
35
+
13
36
  SEMANTIC_STABLE_VERSION = Semantic::Version.new(STABLE_VERSION)
14
37
 
15
- def wisp_schemer(raw_version)
16
- version = Semantic::Version.new(raw_version)
38
+ def is_canary?(raw_version)
39
+ Semantic::Version.new(raw_version) > SEMANTIC_STABLE_VERSION
40
+ end
41
+ module_function :is_canary?
17
42
 
18
- if version > SEMANTIC_STABLE_VERSION
43
+ def wisp_schemer(raw_version)
44
+ if is_canary?(raw_version)
19
45
  JSONSchemer.schema(Pathname.new(Wisp::CANARY_SCHEMA_PATH))
20
46
  else
21
47
  JSONSchemer.schema(Pathname.new(Wisp::SCHEMA_PATH))
@@ -24,13 +50,22 @@ module Wisp
24
50
  module_function :wisp_schemer
25
51
 
26
52
  def nouns_schemer(raw_version)
27
- version = Semantic::Version.new(raw_version)
28
-
29
- if version > SEMANTIC_STABLE_VERSION
53
+ if is_canary?(raw_version)
30
54
  JSONSchemer.schema(Pathname.new(Wisp::CANARY_NOUNS_PATH))
31
55
  else
32
56
  JSONSchemer.schema(Pathname.new(Wisp::NOUNS_PATH))
33
57
  end
34
58
  end
35
59
  module_function :nouns_schemer
60
+
61
+ def action_schemer(raw_version, action)
62
+ raise NotSupportedAction unless ACTIONS.include?(action)
63
+
64
+ if is_canary?(raw_version)
65
+ JSONSchemer.schema(Pathname.new(File.expand_path("../canary/actions/#{action}.json", __dir__)))
66
+ else
67
+ JSONSchemer.schema(Pathname.new(File.expand_path("../stable/actions/#{action}.json", __dir__)))
68
+ end
69
+ end
70
+ module_function :action_schemer
36
71
  end
@@ -0,0 +1,26 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "type": "object",
4
+ "action_type": "action",
5
+ "title": "Click",
6
+ "description": "Clicks on the UI element",
7
+ "properties": {
8
+ "action": {
9
+ "enum": ["click"]
10
+ },
11
+ "id": {"title": "Action ID", "type": "integer"},
12
+ "target": {
13
+ "title": "Target",
14
+ "$ref": "ui_element_reference.json"
15
+ },
16
+ "button": {"title": "Mouse Button", "type": "string", "enum": ["left", "middle", "right"]},
17
+ "hold": {"title": "And Hold", "type": "boolean"},
18
+ "hold_seconds": {"title": "Hold seconds", "type": "integer"},
19
+ "version": {
20
+ "type": "string",
21
+ "title": "Version"
22
+ }
23
+ },
24
+ "additionalProperties": false,
25
+ "required": ["action", "target", "button", "hold", "version"]
26
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "type": "object",
4
+ "action_type": "action",
5
+ "title": "Close Tab",
6
+ "description": "Closes current browser tab",
7
+ "properties": {
8
+ "action": {
9
+ "enum": ["close_tab"]
10
+ },
11
+ "id": {"title": "Action ID", "type": "integer"},
12
+ "version": {
13
+ "type": "string",
14
+ "title": "Version"
15
+ }
16
+ },
17
+ "additionalProperties": false,
18
+ "required": ["action", "version"]
19
+ }