doc-detective 2.13.0-dev.0 → 2.13.0

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.
@@ -25,30 +25,30 @@
25
25
  "markup": [
26
26
  {
27
27
  "name": "Hyperlink",
28
- "regex": ["(?<=(?<!!)\\[[\\w\\s]+\\]\\().*?(?=\\))"],
28
+ "regex": ["(?<!!)\\[.+?\\]\\((.+?)\\)"],
29
29
  "actions": ["checkLink"]
30
30
  },
31
31
  {
32
32
  "name": "Navigation link",
33
- "regex": ["(?<=([Oo]pen|[Cc]lick) (?<!!)\\[[\\w\\s]+\\]\\().*?(?=\\))"],
33
+ "regex": [
34
+ "(?:[Cc]hose|[Oo]pen|[Cc]lick|[Nn]avigate to|[Gg]o to)(?<!!)\\[.+?\\]\\((.+?)\\)"
35
+ ],
34
36
  "actions": ["goTo"]
35
37
  },
36
38
  {
37
39
  "name": "Onscreen text",
38
- "regex": ["(?<=\\*\\*)[\\w\\s]+?(?=\\*\\*)"],
40
+ "regex": ["\\*\\*(.+?)\\*\\*"],
39
41
  "actions": ["find"]
40
42
  },
41
43
  {
42
44
  "name": "Image",
43
- "regex": ["(?<=\\!\\[.*?\\]\\().*?(?=\\))"],
45
+ "regex": ["!\\[.+?\\]\\((.+?)\\)"],
44
46
  "actions": [
45
47
  {
46
- "name": "saveScreenshot",
47
- "params": {
48
- "directory": "samples",
49
- "maxVariation": 5,
50
- "overwrite": "byVariation"
51
- }
48
+ "action": "saveScreenshot",
49
+ "directory": "samples",
50
+ "maxVariation": 5,
51
+ "overwrite": "byVariation"
52
52
  }
53
53
  ]
54
54
  }
@@ -0,0 +1,26 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 24.3.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <svg version="1.1" id="_x31_" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
4
+ width="1200px" height="1200px" viewBox="0 0 1200 1200" enable-background="new 0 0 1200 1200" xml:space="preserve">
5
+ <g>
6
+ <path fill="#4B9A47" d="M1128.306,1200H71.694C32.099,1200,0,1167.901,0,1128.306V71.694C0,32.099,32.099,0,71.694,0h1056.612
7
+ C1167.901,0,1200,32.099,1200,71.694v1056.612C1200,1167.901,1167.901,1200,1128.306,1200z"/>
8
+ <g>
9
+ <path fill="#FFFFFF" d="M251.414,202.411v792.621c0,30.013,24.331,54.344,54.344,54.344h612.917
10
+ c16.716,0,30.268-13.551,30.268-30.268V420.58L677.939,149.577l-376.472,2.454C273.771,152.211,251.414,174.714,251.414,202.411z"
11
+ />
12
+ <path d="M918.676,1078.376H305.758c-45.956,0-83.344-37.388-83.344-83.344V202.411c0-43.487,35.378-79.097,78.865-79.38
13
+ l388.594-2.533l288.069,288.07v610.541C977.942,1051.788,951.355,1078.376,918.676,1078.376z M666.006,178.655l-364.349,2.375
14
+ c-11.713,0.076-21.243,9.668-21.243,21.381v792.621c0,13.975,11.37,25.344,25.344,25.344h612.917c0.698,0,1.267-0.568,1.267-1.268
15
+ V432.592L666.006,178.655z"/>
16
+ </g>
17
+ <rect x="449.529" y="595.822" width="302.675" height="60.076"/>
18
+ <rect x="449.529" y="759.771" width="181.605" height="60.076"/>
19
+ <path d="M864.547,919.645l-33.693,0.599l-22.668-28.276c47.751-52.006,73.916-119.016,73.916-190.056
20
+ c0-75.146-29.264-145.795-82.4-198.932c-53.137-53.137-123.785-82.4-198.932-82.4s-145.795,29.264-198.932,82.4
21
+ c-53.137,53.136-82.4,123.785-82.4,198.932s29.264,145.795,82.4,198.932c53.136,53.137,123.785,82.4,198.932,82.4
22
+ c72.38,0,140.58-27.159,192.986-76.64l22.685,24.676l0.425,32.343c0,2.932,1.17,5.743,3.249,7.81l214.126,212.771l49.529-52.28
23
+ L872.417,922.828C870.324,920.757,867.49,919.611,864.547,919.645z M600.77,920.244c-120.389,0-218.332-97.943-218.332-218.332
24
+ S480.382,483.58,600.77,483.58s218.332,97.943,218.332,218.332S721.159,920.244,600.77,920.244z"/>
25
+ </g>
26
+ </svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "doc-detective",
3
- "version": "2.13.0-dev.0",
3
+ "version": "2.13.0",
4
4
  "description": "Treat doc content as testable assertions to validate doc accuracy and product UX.",
5
5
  "bin": {
6
6
  "doc-detective": "src/index.js"
@@ -31,8 +31,8 @@
31
31
  },
32
32
  "homepage": "https://github.com/doc-detective/doc-detective#readme",
33
33
  "dependencies": {
34
- "doc-detective-common": "^1.17.0-dev.1",
35
- "doc-detective-core": "^2.13.0-dev.0",
34
+ "doc-detective-common": "^1.17.0",
35
+ "doc-detective-core": "^2.13.0",
36
36
  "prompt-sync": "^4.2.0",
37
37
  "yargs": "^17.7.2"
38
38
  },
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "envVariables": "./variables.env",
3
+ "defaultCommand": "runTests",
3
4
  "input": ".",
4
5
  "output": ".",
5
6
  "recursive": true,
6
7
  "logLevel": "info",
7
8
  "runTests": {
8
9
  "detectSteps": true,
9
- "input": "./doc-content.md",
10
+ "input": "./doc-content-inline-tests.md",
10
11
  "output": ".",
11
12
  "setup": "",
12
13
  "cleanup": "",
@@ -16,14 +17,12 @@
16
17
  "contexts": [
17
18
  {
18
19
  "app": {
19
- "name": "firefox",
20
+ "name": "chrome",
20
21
  "options": {
21
- "width": 1200,
22
- "height": 800,
23
22
  "headless": false
24
23
  }
25
24
  },
26
- "platforms": ["linux", "mac", "windows"]
25
+ "platforms": ["windows", "mac", "linux"]
27
26
  }
28
27
  ]
29
28
  },
@@ -33,12 +32,6 @@
33
32
  "output": ".",
34
33
  "markup": []
35
34
  },
36
- "suggestTests": {
37
- "recursive": true,
38
- "input": ".",
39
- "output": ".",
40
- "markup": []
41
- },
42
35
  "fileTypes": [
43
36
  {
44
37
  "name": "Markdown",
@@ -52,30 +45,29 @@
52
45
  "markup": [
53
46
  {
54
47
  "name": "Hyperlink",
55
- "regex": ["(?<=(?<!!)\\[[\\w\\s]+\\]\\().*?(?=\\))"],
48
+ "regex": ["(?<!!)\\[.+?\\]\\((.+?)\\)"],
56
49
  "actions": ["checkLink"]
57
50
  },
58
51
  {
59
52
  "name": "Navigation link",
60
- "regex": ["(?<=([Oo]pen|[Cc]lick) (?<!!)\\[[\\w\\s]+\\]\\().*?(?=\\))"],
53
+ "regex": [
54
+ "(?:[Cc]hose|[Oo]pen|[Cc]lick|[Nn]avigate to|[Gg]o to)\\s+(?<!!)\\[.+?\\]\\((.+?)\\)"
55
+ ],
61
56
  "actions": ["goTo"]
62
57
  },
63
58
  {
64
59
  "name": "Onscreen text",
65
- "regex": ["(?<=\\*\\*)[\\w\\s]+?(?=\\*\\*)"],
60
+ "regex": ["\\*\\*(.+?)\\*\\*"],
66
61
  "actions": ["find"]
67
62
  },
68
63
  {
69
64
  "name": "Image",
70
- "regex": ["(?<=\\!\\[.*?\\]\\().*?(?=\\))"],
65
+ "regex": ["!\\[.+?\\]\\((.+?)\\)"],
71
66
  "actions": [
72
67
  {
73
- "name": "saveScreenshot",
74
- "params": {
75
- "directory": ".",
76
- "maxVariation": 5,
77
- "overwrite": "byVariation"
78
- }
68
+ "action": "saveScreenshot",
69
+ "maxVariation": 5,
70
+ "overwrite": "byVariation"
79
71
  }
80
72
  ]
81
73
  }
@@ -3,7 +3,9 @@
3
3
  [Doc Detective documentation](https://doc-detective.com) is split into a few key sections:
4
4
 
5
5
  - The landing page discusses what Doc Detective is, what it does, and who might find it useful.
6
+
6
7
  - [Get started](https://doc-detective.com/get-started.html) covers how to quickly get up and running with Doc Detective.
8
+
7
9
  - The [references](https://doc-detective.com/reference/) detail the various JSON objects that Doc Detective expects for [configs](https://doc-detective.com/reference/schemas/config.html), [test specifications](https://doc-detective.com/reference/schemas/specification.html), [tests](https://doc-detective.com/reference/schemas/test), actions, and more. Open [typeKeys](https://doc-detective.com/reference/schemas/typeKeys.html)--or any other schema--and you'll find three sections: **Description**, **Fields**, and **Examples**.
8
10
 
9
11
  ![Search results.](reference.png)
@@ -1,12 +1,12 @@
1
1
  # Doc Detective documentation overview
2
2
 
3
- [comment]: # (test start {"id":"search-kittens", "detectSteps":false})
3
+ [comment]: # (test start {"id":"doc-detective-docs", "detectSteps": false})
4
4
 
5
5
  [Doc Detective documentation](http://doc-detective.com) is split into a few key sections:
6
6
 
7
7
  [comment]: # (step {"action":"checkLink", "url":"https://doc-detective.com"})
8
8
 
9
- The landing page discusses what Doc Detective is, what it does, and who might find it useful.
9
+ - The landing page discusses what Doc Detective is, what it does, and who might find it useful.
10
10
 
11
11
  - [Get started](https://doc-detective.com/get-started.html) covers how to quickly get up and running with Doc Detective.
12
12
 
@@ -25,5 +25,5 @@ The landing page discusses what Doc Detective is, what it does, and who might fi
25
25
 
26
26
  ![Search results.](reference.png)
27
27
 
28
- [comment]: # (step {"action":"saveScreenshot", "path":"reference.png", "directory":"samples", "maxVariation":5, "overwrite":"byVariation"})
28
+ [comment]: # (step {"action":"saveScreenshot", "path":"reference.png", "maxVariation":5, "overwrite":"byVariation"})
29
29
  [comment]: # (test end)
@@ -0,0 +1,14 @@
1
+ {
2
+ "tests": [
3
+ {
4
+ "steps": [
5
+ {
6
+ "action": "runShell",
7
+ "description": "Run a Docker container and check the output.",
8
+ "command": "docker run hello-world",
9
+ "output": "Hello from Docker!"
10
+ }
11
+ ]
12
+ }
13
+ ]
14
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "tests": [
3
+ {
4
+ "steps": [
5
+ {
6
+ "action": "checkLink",
7
+ "url": "https://www.duckduckgo.com"
8
+ },
9
+ {
10
+ "action": "httpRequest",
11
+ "url": "https://reqres.in/api/users",
12
+ "method": "post",
13
+ "requestData": {
14
+ "name": "morpheus",
15
+ "job": "leader"
16
+ },
17
+ "responseData": {
18
+ "name": "morpheus",
19
+ "job": "leader"
20
+ },
21
+ "statusCodes": [200, 201]
22
+ }
23
+ ]
24
+ }
25
+ ]
26
+ }
@@ -0,0 +1,15 @@
1
+ To search for American Shorthair kittens,
2
+
3
+ 1. Go to [DuckDuckGo](https://www.duckduckgo.com).
4
+
5
+ [comment]: # (step { "action": "goTo", "url": "https://www.duckduckgo.com"})
6
+ [comment]: # (step { "action": "startRecording", "path": "search-results.gif"})
7
+
8
+ 2. In the search bar, enter "American Shorthair kittens", then press Enter.
9
+
10
+ [comment]: # (step { "action": "find", "selector": "#searchbox_input", "click": true })
11
+ [comment]: # (step { "action": "typeKeys", "keys": ["American Shorthair kittens", "$ENTER$"] })
12
+ [comment]: # (step { "action": "find", "selector": "[data-testid='web-vertical']" })
13
+ [comment]: # (step { "action": "stopRecording" })
14
+
15
+ ![](search-results.gif)
@@ -0,0 +1,28 @@
1
+ {
2
+ "tests": [
3
+ {
4
+ "steps": [
5
+ {
6
+ "action": "goTo",
7
+ "url": "https://www.duckduckgo.com"
8
+ },
9
+ {
10
+ "action": "find",
11
+ "selector": "#searchbox_input",
12
+ "click": true,
13
+ "typeKeys": {
14
+ "keys": ["American Shorthair kittens", "$ENTER$"]
15
+ }
16
+ },
17
+ {
18
+ "action": "find",
19
+ "selector": "[data-testid='web-vertical']"
20
+ },
21
+ {
22
+ "action": "saveScreenshot",
23
+ "path": "search-results.png"
24
+ }
25
+ ]
26
+ }
27
+ ]
28
+ }
package/src/utils.js CHANGED
@@ -115,10 +115,12 @@ function setConfig(config, args) {
115
115
 
116
116
  async function outputResults(config, path, results) {
117
117
  let data = JSON.stringify(results, null, 2);
118
- fs.writeFile(path, data, (err) => {
119
- if (err) throw err;
120
- });
121
- console.log(`See results at ${path}`);
118
+ try {
119
+ fs.writeFileSync(path, data);
120
+ console.log(`See results at ${path}`);
121
+ } catch (err) {
122
+ console.error(`Error writing results to ${path}: ${err}`);
123
+ }
122
124
  }
123
125
 
124
126
  // Perform a native command in the current working directory.
@@ -178,6 +178,8 @@ describe("Util tests", function () {
178
178
  const inputResultsPath = path.resolve("./test/test-results.json");
179
179
  const inputResultsJSON = require(inputResultsPath);
180
180
  const outputResultsPath = path.resolve("./test/output-test-results.json");
181
+ // Check that input file exists
182
+ expect(fs.existsSync(inputResultsPath)).to.equal(true);
181
183
  // Output results
182
184
  await outputResults(null, outputResultsPath, inputResultsJSON);
183
185
  // Check that output file exists