doc-detective 1.3.1 → 2.9.0-dev.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.
Files changed (44) hide show
  1. package/.github/FUNDING.yml +14 -0
  2. package/.github/dependabot.yml +11 -0
  3. package/.github/workflows/docker-image.yml +19 -0
  4. package/.github/workflows/electron-publish.yml +17 -0
  5. package/.github/workflows/npm-test.yaml +50 -0
  6. package/LICENSE +20 -20
  7. package/README.md +109 -42
  8. package/dev/dev.spec.json +62 -0
  9. package/dev/index.js +6 -0
  10. package/icon.png +0 -0
  11. package/index.js +1 -129
  12. package/package.json +43 -44
  13. package/samples/config.json +89 -0
  14. package/samples/doc-content-inline-tests.md +28 -0
  15. package/samples/doc-content.md +9 -0
  16. package/samples/reference.png +0 -0
  17. package/samples/screenshot.png +0 -0
  18. package/samples/tests.spec.json +70 -0
  19. package/samples/variables.env +5 -0
  20. package/src/index.js +44 -0
  21. package/src/utils.js +157 -1084
  22. package/test/artifacts/config.json +46 -0
  23. package/test/artifacts/doc-content.md +18 -0
  24. package/test/artifacts/test.spec.json +71 -0
  25. package/test/runCoverage.test.js +18 -0
  26. package/test/runTests.test.js +22 -0
  27. package/test/test-config.json +10 -0
  28. package/test/test-results.json +125 -0
  29. package/test/utils.test.js +204 -0
  30. package/.github/workflows/npm-publish.yml +0 -33
  31. package/config.json +0 -215
  32. package/src/analysis.js +0 -278
  33. package/src/analytics.js +0 -499
  34. package/src/coverage.js +0 -54
  35. package/src/install-mouse-helper.js +0 -72
  36. package/src/sanitize.js +0 -23
  37. package/src/suggest.js +0 -751
  38. package/src/tests/goTo.js +0 -39
  39. package/src/tests/httpRequest.js +0 -373
  40. package/src/tests/moveMouse.js +0 -91
  41. package/src/tests/record.js +0 -251
  42. package/src/tests/screenshot.js +0 -145
  43. package/src/tests/scroll.js +0 -32
  44. package/src/tests.js +0 -604
@@ -0,0 +1,89 @@
1
+ {
2
+ "envVariables": "./samples/variables.env",
3
+ "input": ".",
4
+ "output": ".",
5
+ "recursive": true,
6
+ "logLevel": "debug",
7
+ "runTests": {
8
+ "input": "./samples/doc-content.md",
9
+ "output": ".",
10
+ "setup": "",
11
+ "cleanup": "",
12
+ "recursive": true,
13
+ "mediaDirectory": ".",
14
+ "downloadDirectory": ".",
15
+ "contexts": [
16
+ {
17
+ "app": {
18
+ "name": "firefox",
19
+ "options": {
20
+ "width": 1200,
21
+ "height": 800,
22
+ "headless": false
23
+ }
24
+ },
25
+ "platforms": ["linux", "mac", "windows"]
26
+ }
27
+ ]
28
+ },
29
+ "runCoverage": {
30
+ "recursive": true,
31
+ "input": ".",
32
+ "output": ".",
33
+ "markup": []
34
+ },
35
+ "suggestTests": {
36
+ "recursive": true,
37
+ "input": ".",
38
+ "output": ".",
39
+ "markup": []
40
+ },
41
+ "fileTypes": [
42
+ {
43
+ "name": "Markdown",
44
+ "extensions": [".md"],
45
+ "testStartStatementOpen": "[comment]: # (test start",
46
+ "testStartStatementClose": ")",
47
+ "testIgnoreStatement": "[comment]: # (test ignore)",
48
+ "testEndStatement": "[comment]: # (test end)",
49
+ "stepStatementOpen": "[comment]: # (step",
50
+ "stepStatementClose": ")",
51
+ "markup": [
52
+ {
53
+ "name": "Hyperlink",
54
+ "regex": ["(?<=(?<!!)\\[[\\w\\s]+\\]\\().*?(?=\\))"],
55
+ "actions": ["checkLink"]
56
+ },
57
+ {
58
+ "name": "Navigation link",
59
+ "regex": ["(?<=([Oo]pen|[Cc]lick) (?<!!)\\[[\\w\\s]+\\]\\().*?(?=\\))"],
60
+ "actions": ["goTo"]
61
+ },
62
+ {
63
+ "name": "Onscreen text",
64
+ "regex": ["(?<=\\*\\*)[\\w\\s]+?(?=\\*\\*)"],
65
+ "actions": ["find"]
66
+ },
67
+ {
68
+ "name": "Image",
69
+ "regex": ["(?<=\\!\\[.*?\\]\\().*?(?=\\))"],
70
+ "actions": [
71
+ {
72
+ "name": "saveScreenshot",
73
+ "params": {
74
+ "directory": "samples",
75
+ "maxVariation": 5,
76
+ "overwrite": "byVariation"
77
+ }
78
+ }
79
+ ]
80
+ }
81
+ ]
82
+ }
83
+ ],
84
+ "integrations": {},
85
+ "telemetry": {
86
+ "send": false,
87
+ "userId": "Doc Detective"
88
+ }
89
+ }
@@ -0,0 +1,28 @@
1
+ # Doc Detective documentation overview
2
+
3
+ [comment]: # (test start {"id":"search-kittens", "detectSteps":false})
4
+
5
+ [Doc Detective documentation](http://doc-detective.com) is split into a few key sections:
6
+
7
+ [comment]: # (step {"action":"checkLink", "url":"https://doc-detective.com"})
8
+
9
+ - The landing page discusses what Doc Detective is, what it does, and who might find it useful.
10
+ - [Get started](https://doc-detective.com/get-started.html) covers how to quickly get up and running with Doc Detective.
11
+
12
+ [comment]: # (step {"action":"checkLink", "url":"https://doc-detective.com/get-started.html"})
13
+
14
+ - 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**.
15
+
16
+ [comment]: # (step {"action":"checkLink", "url":"https://doc-detective.com/reference/"})
17
+ [comment]: # (step {"action":"checkLink", "url":"https://doc-detective.com/reference/schemas/config.html"})
18
+ [comment]: # (step {"action":"checkLink", "url":"https://doc-detective.com/reference/schemas/specification.html"})
19
+ [comment]: # (step {"action":"checkLink", "url":"https://doc-detective.com/reference/schemas/test.html"})
20
+ [comment]: # (step {"action":"goTo", "url":"https://doc-detective.com/reference/schemas/typeKeys.html"})
21
+ [comment]: # (step {"action":"find", "selector":"h2#description", "matchText":"Description"})
22
+ [comment]: # (step {"action":"find", "selector":"h2#fields", "matchText":"Fields"})
23
+ [comment]: # (step {"action":"find", "selector":"h2#examples", "matchText":"Examples"})
24
+
25
+ ![](reference.png)
26
+ [comment]: # (step {"action":"saveScreenshot", "path":"reference.png", "directory":"samples", "maxVariation":5, "overwrite":"byVariation"})
27
+
28
+ [comment]: # (test end)
@@ -0,0 +1,9 @@
1
+ # Doc Detective documentation overview
2
+
3
+ [Doc Detective documentation](https://doc-detective.com) is split into a few key sections:
4
+
5
+ - The landing page discusses what Doc Detective is, what it does, and who might find it useful.
6
+ - [Get started](https://doc-detective.com/get-started.html) covers how to quickly get up and running with Doc Detective.
7
+ - 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
+
9
+ ![](reference.png)
Binary file
Binary file
@@ -0,0 +1,70 @@
1
+ {
2
+ "id": "Do all the things! - Spec",
3
+ "contexts": [
4
+ {
5
+ "app": {
6
+ "name": "firefox"
7
+ },
8
+ "platforms": ["windows", "mac", "linux"]
9
+ }
10
+ ],
11
+ "tests": [
12
+ {
13
+ "id": "Do all the things! - Test",
14
+ "description": "This test includes nearly every property across all actions.",
15
+ "steps": [
16
+ {
17
+ "action": "setVariables",
18
+ "path": ".env"
19
+ },
20
+ {
21
+ "action": "runShell",
22
+ "command": "echo",
23
+ "args": ["$USER"]
24
+ },
25
+ {
26
+ "action": "checkLink",
27
+ "url": "https://www.duckduckgo.com"
28
+ },
29
+ {
30
+ "action": "httpRequest",
31
+ "url": "https://reqres.in/api/users",
32
+ "method": "post",
33
+ "requestData": {
34
+ "name": "morpheus",
35
+ "job": "leader"
36
+ },
37
+ "responseData": {
38
+ "name": "morpheus",
39
+ "job": "leader"
40
+ },
41
+ "statusCodes": [200, 201]
42
+ },
43
+ {
44
+ "action": "goTo",
45
+ "url": "https://www.google.com"
46
+ },
47
+ {
48
+ "action": "find",
49
+ "selector": "[title=Search]",
50
+ "timeout": 10000,
51
+ "moveTo": true,
52
+ "click": true,
53
+ "typeKeys": {
54
+ "keys": ["shorthair cat", "$ENTER$"]
55
+ }
56
+ },
57
+ {
58
+ "action": "wait"
59
+ },
60
+ {
61
+ "action": "saveScreenshot",
62
+ "path": "screenshot.png",
63
+ "directory": "samples",
64
+ "maxVariation": 5,
65
+ "overwrite": "byVariation"
66
+ }
67
+ ]
68
+ }
69
+ ]
70
+ }
@@ -0,0 +1,5 @@
1
+ USERNAME=foo
2
+ PASSWORD=bar
3
+ SHORTHAIR_CAT_SEARCH=american shorthair cats
4
+ URL=www.google.com
5
+ TEXT=I'm Feeling Lucky
package/src/index.js ADDED
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { runTests, runCoverage } = require("doc-detective-core");
4
+ const { setArgs, setConfig, outputResults } = require("./utils");
5
+ const { argv } = require("node:process");
6
+ const path = require("path");
7
+
8
+ main(argv);
9
+
10
+ // Run tests
11
+ async function main(argv) {
12
+ // Find index of `doc-detective` or `run` in argv
13
+ console.log(argv);
14
+ let index = argv.indexOf("doc-detective");
15
+ if (index === -1) {
16
+ index = argv.findIndex((arg) => arg.endsWith("index.js"));
17
+ }
18
+ // `command` is the next argument after `doc-detective` or `src/index.js`
19
+ const command = argv[index + 1];
20
+ // Set args and config
21
+ argv = setArgs(argv);
22
+ const config = setConfig({}, argv);
23
+ // Run command
24
+ let results = {};
25
+ let outputDir;
26
+ let outputReportType;
27
+ if (command === "runCoverage") {
28
+ outputDir = config.runCoverage.output || config.output;
29
+ outputReportType = "coverageResults";
30
+ results = await runCoverage(config);
31
+ } else if (command === "runTests") {
32
+ outputDir = config.runTests.output || config.output;
33
+ outputReportType = "testResults";
34
+ results = await runTests(config);
35
+ } else {
36
+ throw new Error(`Command ${command} not found`);
37
+ }
38
+ // Output results
39
+ const outputPath = path.resolve(
40
+ outputDir,
41
+ `${outputReportType}-${Date.now()}.json`
42
+ );
43
+ await outputResults(config, outputPath, results);
44
+ }