doc-detective 1.0.7 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/sample/results.json +64 -73
- package/src/config.json +1 -0
- package/src/lib/tests.js +4 -0
- package/src/lib/utils.js +36 -1
- package/sample/results.gif +0 -0
- package/sample/results.png +0 -0
package/package.json
CHANGED
package/sample/results.json
CHANGED
|
@@ -2,65 +2,20 @@
|
|
|
2
2
|
"tests": [
|
|
3
3
|
{
|
|
4
4
|
"id": "process-search-kittens",
|
|
5
|
-
"file": "/config/workspace/doc-detective/sample/doc-content.md",
|
|
6
5
|
"actions": [
|
|
7
|
-
{
|
|
8
|
-
"action": "startRecording",
|
|
9
|
-
"overwrite": false,
|
|
10
|
-
"filename": "results.gif",
|
|
11
|
-
"fps": 15,
|
|
12
|
-
"line": 9,
|
|
13
|
-
"result": {
|
|
14
|
-
"status": "PASS",
|
|
15
|
-
"description": "Started recording: /config/workspace/doc-detective/sample/temp_results.mp4",
|
|
16
|
-
"video": "/config/workspace/doc-detective/sample/temp_results.mp4"
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
6
|
{
|
|
20
7
|
"action": "goTo",
|
|
21
8
|
"uri": "www.google.com",
|
|
22
|
-
"line": 10,
|
|
23
9
|
"result": {
|
|
24
10
|
"status": "PASS",
|
|
25
11
|
"description": "Opened URI."
|
|
26
12
|
}
|
|
27
13
|
},
|
|
28
|
-
{
|
|
29
|
-
"action": "moveMouse",
|
|
30
|
-
"css": "#gbqfbb",
|
|
31
|
-
"alignH": "center",
|
|
32
|
-
"alignV": "center",
|
|
33
|
-
"line": 14,
|
|
34
|
-
"result": {
|
|
35
|
-
"status": "PASS",
|
|
36
|
-
"description": "Moved mouse to element."
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
"action": "wait",
|
|
41
|
-
"duration": "5000",
|
|
42
|
-
"line": 15,
|
|
43
|
-
"result": {
|
|
44
|
-
"status": "PASS",
|
|
45
|
-
"description": "Wait complete."
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
"action": "moveMouse",
|
|
50
|
-
"css": "[title=Search]",
|
|
51
|
-
"alignV": "center",
|
|
52
|
-
"line": 16,
|
|
53
|
-
"result": {
|
|
54
|
-
"status": "PASS",
|
|
55
|
-
"description": "Moved mouse to element."
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
14
|
{
|
|
59
15
|
"action": "type",
|
|
60
16
|
"css": "[title=Search]",
|
|
61
17
|
"keys": "kittens",
|
|
62
18
|
"trailingSpecialKey": "Enter",
|
|
63
|
-
"line": 17,
|
|
64
19
|
"result": {
|
|
65
20
|
"status": "PASS",
|
|
66
21
|
"description": "Typed keys."
|
|
@@ -69,35 +24,16 @@
|
|
|
69
24
|
{
|
|
70
25
|
"action": "wait",
|
|
71
26
|
"duration": "5000",
|
|
72
|
-
"line": 18,
|
|
73
27
|
"result": {
|
|
74
28
|
"status": "PASS",
|
|
75
29
|
"description": "Wait complete."
|
|
76
30
|
}
|
|
77
31
|
},
|
|
78
|
-
{
|
|
79
|
-
"action": "scroll",
|
|
80
|
-
"y": 300,
|
|
81
|
-
"line": 19,
|
|
82
|
-
"result": {
|
|
83
|
-
"status": "PASS",
|
|
84
|
-
"description": "Scroll complete."
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
"action": "stopRecording",
|
|
89
|
-
"line": 20,
|
|
90
|
-
"result": {
|
|
91
|
-
"status": "PASS",
|
|
92
|
-
"description": "Stopped recording: /config/workspace/doc-detective/sample/results.gif"
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
32
|
{
|
|
96
33
|
"action": "screenshot",
|
|
97
34
|
"filename": "results.png",
|
|
98
35
|
"matchPrevious": false,
|
|
99
36
|
"matchThreshold": 0.1,
|
|
100
|
-
"line": 21,
|
|
101
37
|
"result": {
|
|
102
38
|
"status": "PASS",
|
|
103
39
|
"description": "Captured screenshot.",
|
|
@@ -109,12 +45,10 @@
|
|
|
109
45
|
},
|
|
110
46
|
{
|
|
111
47
|
"id": "text-match-lucky",
|
|
112
|
-
"file": "/config/workspace/doc-detective/sample/doc-content.md",
|
|
113
48
|
"actions": [
|
|
114
49
|
{
|
|
115
50
|
"action": "goTo",
|
|
116
51
|
"uri": "www.google.com",
|
|
117
|
-
"line": 33,
|
|
118
52
|
"result": {
|
|
119
53
|
"status": "PASS",
|
|
120
54
|
"description": "Opened URI."
|
|
@@ -124,7 +58,16 @@
|
|
|
124
58
|
"action": "matchText",
|
|
125
59
|
"css": "#gbqfbb",
|
|
126
60
|
"text": "I'm Feeling Lucky",
|
|
127
|
-
"
|
|
61
|
+
"result": {
|
|
62
|
+
"status": "PASS",
|
|
63
|
+
"description": "Element text matched expected text."
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"action": "matchText",
|
|
68
|
+
"css": "#gbqfbb",
|
|
69
|
+
"text": "$TEXT",
|
|
70
|
+
"env": "./sample/variables.env",
|
|
128
71
|
"result": {
|
|
129
72
|
"status": "PASS",
|
|
130
73
|
"description": "Element text matched expected text."
|
|
@@ -135,12 +78,11 @@
|
|
|
135
78
|
},
|
|
136
79
|
{
|
|
137
80
|
"id": "process-lucky-shorthair",
|
|
138
|
-
"file": "/config/workspace/doc-detective/sample/doc-content.md",
|
|
139
81
|
"actions": [
|
|
140
82
|
{
|
|
141
83
|
"action": "goTo",
|
|
142
|
-
"uri": "
|
|
143
|
-
"
|
|
84
|
+
"uri": "$URL",
|
|
85
|
+
"env": "./sample/variables.env",
|
|
144
86
|
"result": {
|
|
145
87
|
"status": "PASS",
|
|
146
88
|
"description": "Opened URI."
|
|
@@ -149,8 +91,7 @@
|
|
|
149
91
|
{
|
|
150
92
|
"action": "type",
|
|
151
93
|
"css": "[title=Search]",
|
|
152
|
-
"keys": "
|
|
153
|
-
"line": 42,
|
|
94
|
+
"keys": "$SHORTHAIR_CAT_SEARCH",
|
|
154
95
|
"result": {
|
|
155
96
|
"status": "PASS",
|
|
156
97
|
"description": "Typed keys."
|
|
@@ -159,7 +100,6 @@
|
|
|
159
100
|
{
|
|
160
101
|
"action": "click",
|
|
161
102
|
"css": "#gbqfbb",
|
|
162
|
-
"line": 46,
|
|
163
103
|
"result": {
|
|
164
104
|
"status": "PASS",
|
|
165
105
|
"description": "Clicked element."
|
|
@@ -167,6 +107,57 @@
|
|
|
167
107
|
}
|
|
168
108
|
],
|
|
169
109
|
"status": "PASS"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"id": "non-ui-tests",
|
|
113
|
+
"actions": [
|
|
114
|
+
{
|
|
115
|
+
"action": "runShell",
|
|
116
|
+
"command": "echo $USERNAME",
|
|
117
|
+
"env": "./sample/variables.env",
|
|
118
|
+
"result": {
|
|
119
|
+
"status": "PASS",
|
|
120
|
+
"description": "Executed command.",
|
|
121
|
+
"stdout": "foo",
|
|
122
|
+
"stderr": "",
|
|
123
|
+
"exitCode": 0
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"action": "checkLink",
|
|
128
|
+
"uri": "https://www.google.com",
|
|
129
|
+
"statusCodes": [
|
|
130
|
+
200
|
|
131
|
+
],
|
|
132
|
+
"result": {
|
|
133
|
+
"status": "PASS",
|
|
134
|
+
"description": "Returned 200"
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"action": "checkLink",
|
|
139
|
+
"uri": "$URL",
|
|
140
|
+
"statusCodes": [
|
|
141
|
+
200
|
|
142
|
+
],
|
|
143
|
+
"result": {
|
|
144
|
+
"status": "PASS",
|
|
145
|
+
"description": "Returned 200"
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"action": "httpRequest",
|
|
150
|
+
"uri": "$URL",
|
|
151
|
+
"statusCodes": [
|
|
152
|
+
200
|
|
153
|
+
],
|
|
154
|
+
"result": {
|
|
155
|
+
"status": "PASS",
|
|
156
|
+
"description": "Returned 200."
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
],
|
|
160
|
+
"status": "PASS"
|
|
170
161
|
}
|
|
171
162
|
]
|
|
172
163
|
}
|
package/src/config.json
CHANGED
package/src/lib/tests.js
CHANGED
|
@@ -92,6 +92,10 @@ async function runTests(config, tests) {
|
|
|
92
92
|
config.debugRecording = {};
|
|
93
93
|
// Instantiate page
|
|
94
94
|
const page = await browser.newPage();
|
|
95
|
+
await page._client.send("Page.setDownloadBehavior", {
|
|
96
|
+
behavior: "allow",
|
|
97
|
+
downloadPath: config.downloadDirectory,
|
|
98
|
+
});
|
|
95
99
|
if (
|
|
96
100
|
test.saveFailedTestRecordings ||
|
|
97
101
|
(config.saveFailedTestRecordings &&
|
package/src/lib/utils.js
CHANGED
|
@@ -82,6 +82,19 @@ function setArgs(args) {
|
|
|
82
82
|
description: "Path to the media output directory.",
|
|
83
83
|
type: "string",
|
|
84
84
|
})
|
|
85
|
+
.option("downloadDir", {
|
|
86
|
+
description: "Path to the download directory.",
|
|
87
|
+
type: "string",
|
|
88
|
+
})
|
|
89
|
+
.option("saveFailedTestRecordings", {
|
|
90
|
+
description:
|
|
91
|
+
"Boolean. Whether to save recordings of failed tests. Defaults to true.",
|
|
92
|
+
type: "string",
|
|
93
|
+
})
|
|
94
|
+
.option("failedTestDir", {
|
|
95
|
+
description: "Path to the failed test directory.",
|
|
96
|
+
type: "string",
|
|
97
|
+
})
|
|
85
98
|
.option("browserHeadless", {
|
|
86
99
|
description:
|
|
87
100
|
"Boolean. Whether to run the browser in headless mode. Defaults to true.",
|
|
@@ -300,6 +313,26 @@ function setMediaDirectory(config, argv) {
|
|
|
300
313
|
return config;
|
|
301
314
|
}
|
|
302
315
|
|
|
316
|
+
function setDownloadDirectory(config, argv) {
|
|
317
|
+
config.downloadDirectory =
|
|
318
|
+
argv.downloadDir ||
|
|
319
|
+
process.env.DOC_MEDIA_DIRECTORY_PATH ||
|
|
320
|
+
config.downloadDirectory ||
|
|
321
|
+
defaultConfig.downloadDirectory;
|
|
322
|
+
config.downloadDirectory = path.resolve(config.downloadDirectory);
|
|
323
|
+
if (fs.existsSync(config.downloadDirectory)) {
|
|
324
|
+
log(config, "debug", `Download directory set: ${config.downloadDirectory}`);
|
|
325
|
+
} else {
|
|
326
|
+
config.downloadDirectory = path.resolve(defaultConfig.downloadDirectory);
|
|
327
|
+
log(
|
|
328
|
+
config,
|
|
329
|
+
"warning",
|
|
330
|
+
`Invalid download directory. Reverted to default: ${config.downloadDirectory}`
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
return config;
|
|
334
|
+
}
|
|
335
|
+
|
|
303
336
|
function setFailedTestRecording(config, argv) {
|
|
304
337
|
config.saveFailedTestRecordings =
|
|
305
338
|
argv.saveFailedTestRecordings ||
|
|
@@ -339,7 +372,7 @@ function setFailedTestRecording(config, argv) {
|
|
|
339
372
|
|
|
340
373
|
function setFailedTestDirectory(config, argv) {
|
|
341
374
|
config.failedTestDirectory =
|
|
342
|
-
argv.
|
|
375
|
+
argv.failedTestDir ||
|
|
343
376
|
process.env.DOC_FAILED_TEST_DIRECTORY_PATH ||
|
|
344
377
|
config.failedTestDirectory ||
|
|
345
378
|
defaultConfig.failedTestDirectory;
|
|
@@ -652,6 +685,8 @@ function setConfig(config, argv) {
|
|
|
652
685
|
|
|
653
686
|
config = setMediaDirectory(config, argv);
|
|
654
687
|
|
|
688
|
+
config = setDownloadDirectory(config, argv);
|
|
689
|
+
|
|
655
690
|
config = setFailedTestRecording(config, argv);
|
|
656
691
|
|
|
657
692
|
config = setFailedTestDirectory(config, argv);
|
package/sample/results.gif
DELETED
|
Binary file
|
package/sample/results.png
DELETED
|
Binary file
|