Skip to content

Commit 59327ad

Browse files
committed
Updated references and added runCode
1 parent a270699 commit 59327ad

File tree

11 files changed

+622
-276
lines changed

11 files changed

+622
-276
lines changed

.scripts/buildSchemaReferences.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ async function main() {
1818
"goTo_v2",
1919
"httpRequest_v2",
2020
"runShell_v2",
21+
"runCode_v2",
2122
"saveScreenshot_v2",
2223
"setVariables_v2",
2324
"startRecording_v2",

docs/references/schemas/config.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,28 @@ Field | Type | Description | Default
1010
defaultCommand | string | Optional. Default command to run when no command is specified.<br/><br/>Accepted values: `runTests`, `runCoverage` |
1111
input | One of<br/>-&nbsp;string<br/>-&nbsp;array of strings | Optional. Path(s) to test specifications and documentation source files. May be paths to specific files or to directories to scan for files. | `.`
1212
output | string | Optional. Path of the of the file or directory in which to store the output of Doc Detective commands. If a file path is specified, the output is written to that file. If a file of that name already exists, Doc Detective creates appends an integer to the result file name. If a directory path is specified, the output file name is dependent on the command being run. | `.`
13-
recursive | boolean | Optional. If `true` searches `input`, `setup`, and `cleanup` paths recursively for test specifications and source files. | `true`
13+
recursive | boolean | Optional. If `true` searches `input`, `setup`, and `cleanup` paths recursively for test specificaions and source files. | `true`
1414
relativePathBase | string | Optional. Whether paths should be interpreted as relative to the current working directory (`cwd`) or to the file in which they're specified (`file`).<br/><br/>Accepted values: `cwd`, `file` | `cwd`
1515
envVariables | string | Optional. Path to a `.env` file to load before performing a Doc Detective operation. |
1616
runTests | object | Optional. Options for running tests. When running tests, values set here override general configuration options. |
1717
runTests.input | One of<br/>-&nbsp;string<br/>-&nbsp;array of strings | Optional. Path(s) to test specifications and documentation source files. May be paths to specific files or to directories to scan for files. |
1818
runTests.output | string | Optional. Path of the of the file or directory in which to store the output of Doc Detective commands. If a file path is specified, the output is written to that file. If a file of that name already exists, Doc Detective creates appends an integer to the result file name. If a directory path is specified, the output file name is dependent on the command being run. | `.`
1919
runTests.setup | One of<br/>-&nbsp;string<br/>-&nbsp;array of strings | Optional. Path(s) to test specifications to perform before those specified by `input`. Useful for setting up testing environments. |
2020
runTests.cleanup | One of<br/>-&nbsp;string<br/>-&nbsp;array of strings | Optional. Path(s) to test specifications to perform after those specified by `input`. Useful for cleaning up testing environments. |
21-
runTests.recursive | boolean | Optional. If `true` searches `input`, `setup`, and `cleanup` paths recursively for test specifications and source files. |
21+
runTests.recursive | boolean | Optional. If `true` searches `input`, `setup`, and `cleanup` paths recursively for test specificaions and source files. |
2222
runTests.detectSteps | boolean | Optional. Whether or not to detect steps in input files based on markup regex. | `false`
2323
runTests.mediaDirectory | string | Optional. DEPRECATED. | `.`
2424
runTests.downloadDirectory | string | Optional. Path of the directory in which to store downloaded files. | `.`
2525
runTests.contexts | array of object([context](/docs/references/schemas/context)) | Optional. Application/platform sets to run tests in. If no contexts are specified but a context is required by one or more tests, Doc Detective attempts to identify a supported context in the current environment and run tests against it. | ``[{"app":{"name":"firefox","options":{"width":1200,"height":800,"headless":true}},"platforms":["linux","mac","windows"]}]``
26-
runCoverage | object | Optional. Options for performing test coverage analysis on documentation source files. When performing coverage analysis, values set here override general configuration options. |
26+
runCoverage | object | Optional. Options for performing test coverage analysis on documentation source files. When performing coveration analysis, values set here override general configuration options. |
2727
runCoverage.input | One of<br/>-&nbsp;string<br/>-&nbsp;array of strings | Optional. Path(s) to test specifications and documentation source files. May be paths to specific files or to directories to scan for files. |
2828
runCoverage.output | string | Optional. Path of the of the file or directory in which to store the output of Doc Detective commands. If a file path is specified, the output is written to that file. If a file of that name already exists, Doc Detective creates appends an integer to the result file name. If a directory path is specified, the output file name is dependent on the command being run. | `.`
29-
runCoverage.recursive | boolean | Optional. If `true` searches `input`, `setup`, and `cleanup` paths recursively for test specifications and source files. |
29+
runCoverage.recursive | boolean | Optional. If `true` searches `input`, `setup`, and `cleanup` paths recursively for test specificaions and source files. |
3030
runCoverage.markup | array of strings | Optional. Markup types to include when performing this operation. If no markup types are specified, the operation includes all markup types as defined in `fileTypes`. | ``["onscreenText","emphasis","image","hyperlink","codeInline","codeBlock","interaction"]``
31-
suggestTests | object | Optional. Options for suggesting tests based on documentation source files. When suggesting tests, values set here override general configuration options. |
31+
suggestTests | object | Optional. Options for suggesting tests based on documentation source files. When suggesting tests, values set here override general condiguration options. |
3232
suggestTests.input | One of<br/>-&nbsp;string<br/>-&nbsp;array of strings | Optional. Path(s) to test specifications and documentation source files. May be paths to specific files or to directories to scan for files. |
3333
suggestTests.output | string | Optional. Path of the of the file or directory in which to store the output of Doc Detective commands. If a file path is specified, the output is written to that file. If a file of that name already exists, Doc Detective creates appends an integer to the result file name. If a directory path is specified, the output file name is dependent on the command being run. | `.`
34-
suggestTests.recursive | boolean | Optional. If `true` searches `input`, `setup`, and `cleanup` paths recursively for test specifications and source files. |
34+
suggestTests.recursive | boolean | Optional. If `true` searches `input`, `setup`, and `cleanup` paths recursively for test specificaions and source files. |
3535
suggestTests.markup | array of strings | Optional. Markup types to include when performing this operation. If no markup types are specified, the operation includes all markup types as defined in `fileTypes`. | ``["onscreenText","emphasis","image","hyperlink","codeInline","codeBlock","interaction"]``
3636
fileTypes | array of objects | Optional. Information on supported file types and how to parse the markup within them. | []
3737
fileTypes.name | string | Optional. Name of the file type. |
@@ -49,6 +49,7 @@ fileTypes.markup.actions | array of <br/>- strings<br/>- objects<br/>-&nbsp;obje
4949
fileTypes.markup.actions.name | string | Required. Name of the action.<br/><br/>Accepted values: `checkLink`, `find`, `goTo`, `httpRequest`, `runShell`, `saveScreenshot`, `setVariables`, `startRecording`, `stopRecording`, `typeKeys`, `wait` |
5050
fileTypes.markup.actions.params | object | Optional. Parameters for the action. |
5151
integrations | object | Optional. Options for connecting to external services. |
52+
integrations.openApi | array of undefineds | Optional. undefined |
5253
telemetry | object | Optional. Options around sending telemetry for Doc Detective usage. | ``{"send":true}``
5354
telemetry.send | boolean | Required. If `true`, sends Doc Detective telemetry. | `true`
5455
telemetry.userId | string | Optional. Identifier for the organization, group, or individual running Doc Detective. |
@@ -99,6 +100,21 @@ logLevel | string | Optional. Amount of detail to output when performing an ope
99100
}
100101
```
101102

103+
```json
104+
{
105+
"integrations": {
106+
"openApi": [
107+
{
108+
"name": "Acme",
109+
"descriptionPath": "https://www.acme.com/openapi.json",
110+
"server": "https://api.acme.com",
111+
"mockResponse": true
112+
}
113+
]
114+
}
115+
}
116+
```
117+
102118
```json
103119
{
104120
"envVariables": "",

docs/references/schemas/context.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ app.path | string | Optional. Absolute path or command for the application. If
1515
app.options | object | Optional. Options to pass to the app. Only works when `name` is `firefox` or `chrome`. |
1616
app.options.width | integer | Optional. Width of the window in pixels. |
1717
app.options.height | integer | Optional. Height of the window in pixels. |
18+
app.options.viewport_height | integer | Optional. Height of the viewport in pixels. Overrides `height`. |
19+
app.options.viewport_width | integer | Optional. Width of the viewport in pixels. Overrides `width`. |
1820
app.options.headless | boolean | Optional. If `true`, runs the browser in headless mode. Not supported by Safari. |
1921
app.options.driverPath | string | Optional. Path to the browser driver. If not specified, defaults to internally managed dependencies. |
2022
platforms | array of strings | Required. Supported platforms for the application. |
@@ -32,6 +34,21 @@ platforms | array of strings | Required. Supported platforms for the applicatio
3234
}
3335
```
3436

37+
```json
38+
{
39+
"app": {
40+
"name": "chrome",
41+
"options": {
42+
"viewport_width": 800,
43+
"viewport_height": 600
44+
}
45+
},
46+
"platforms": [
47+
"linux"
48+
]
49+
}
50+
```
51+
3552
```json
3653
{
3754
"app": {

docs/references/schemas/find.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ selector | string | Required. Selector that uniquely identifies the element. |
1414
timeout | integer | Optional. Max duration in milliseconds to wait for the element to exist. | `5000`
1515
matchText | string | Optional. Text that the element should contain. If the element doesn't contain the text, the step fails. Accepts both strings an regular expressions. To use a regular expression, the expression should start and end with a `/`. For example, `/search/`. |
1616
moveTo | [object Object] | Optional. Move to the element. If the element isn't visible, it's scrolled into view. Only runs the if the test is being recorded. | `false`
17-
click | boolean | Optional. Click the element. | `false`
17+
click | One of<br/>-&nbsp;boolean<br/>-&nbsp;object | Optional. Click the element. |
1818
typeKeys | One of<br/>-&nbsp;string<br/>-&nbsp;object | Optional. Type keys after finding the element. Either a string or an object with a `keys` field as defined in [`typeKeys`](typeKeys). To type in the element, make the element active with the `click` parameter. |
1919
setVariables | array of objects | Optional. Extract environment variables from the element's text. | ``[]``
2020
setVariables.name | string | Required. Name of the environment variable to set. |
@@ -41,6 +41,16 @@ setVariables.regex | string | Required. Regex to extract the environment variab
4141
}
4242
```
4343

44+
```json
45+
{
46+
"action": "find",
47+
"selector": "[title=Search]",
48+
"click": {
49+
"button": "right"
50+
}
51+
}
52+
```
53+
4454
```json
4555
{
4656
"action": "find",

docs/references/schemas/httpRequest.md

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ Field | Type | Description | Default
99
:-- | :-- | :-- | :--
1010
id | string | Optional. ID of the step. | Generated UUID
1111
description | string | Optional. Description of the step. |
12-
action | string | Required. Action to perform. |
13-
url | string | Required. URL for the HTTP request. |
12+
action | string | Required. Aciton to perform. |
13+
url | string | Optional. URL for the HTTP request. |
14+
openApi | undefined | Optional. undefined |
1415
statusCodes | array of integers | Optional. Accepted status codes. If the specified URL returns a code other than what is specified here, the action fails. | ``[200]``
1516
method | string | Optional. Method of the HTTP request<br/><br/>Accepted values: `get`, `put`, `post`, `patch`, `delete` | `get`
1617
timeout | integer | Optional. Timeout for the HTTP request, in milliseconds. | `60000`
@@ -121,3 +122,67 @@ envsFromResponseData.jqFilter | string | Required. jq filter to apply to the re
121122
"overwrite": "byVariation"
122123
}
123124
```
125+
126+
```json
127+
{
128+
"action": "httpRequest",
129+
"openApi": {
130+
"name": "Reqres",
131+
"operationId": "getUserById"
132+
},
133+
"requestParams": {
134+
"id": 123
135+
}
136+
}
137+
```
138+
139+
```json
140+
{
141+
"action": "httpRequest",
142+
"openApi": {
143+
"descriptionPath": "https://api.example.com/openapi.json",
144+
"operationId": "getUserById"
145+
},
146+
"requestParams": {
147+
"id": 123
148+
}
149+
}
150+
```
151+
152+
```json
153+
{
154+
"action": "httpRequest",
155+
"openApi": {
156+
"descriptionPath": "https://api.example.com/openapi.json",
157+
"operationId": "createUser",
158+
"useExample": "both"
159+
}
160+
}
161+
```
162+
163+
```json
164+
{
165+
"action": "httpRequest",
166+
"openApi": {
167+
"descriptionPath": "https://api.example.com/openapi.json",
168+
"operationId": "updateUser",
169+
"useExample": "request",
170+
"exampleKey": "acme"
171+
}
172+
}
173+
```
174+
175+
```json
176+
{
177+
"action": "httpRequest",
178+
"openApi": {
179+
"descriptionPath": "https://api.example.com/openapi.json",
180+
"operationId": "updateUser",
181+
"useExample": "request",
182+
"exampleKey": "acme",
183+
"requestHeaders": {
184+
"Authorization": "Bearer $TOKEN"
185+
}
186+
}
187+
}
188+
```

docs/references/schemas/runCode.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
2+
# runCode
3+
4+
Assemble and run code.
5+
6+
## Fields
7+
8+
Field | Type | Description | Default
9+
:-- | :-- | :-- | :--
10+
id | string | Optional. ID of the step. | Generated UUID
11+
description | string | Optional. Description of the step. |
12+
action | string | Required. The action to perform. |
13+
language | string | Required. Language of the code to run. If not specified, the code is run in the shell.<br/><br/>Accepted values: `python`, `bash`, `javascript` |
14+
code | string | Required. Code to run. |
15+
args | array of strings | Optional. Arguments for the command. | ``[]``
16+
workingDirectory | string | Optional. Working directory for the command. | `.`
17+
exitCodes | array of integers | Optional. Expected exit codes of the command. If the command's actual exit code isn't in this list, the step fails. | ``[0]``
18+
output | string | Optional. Content expected in the command's output. If the expected content can't be found in the command's output (either stdout or stderr), the step fails. Supports strings and regular expressions. To use a regular expression, the string must start and end with a forward slash, like in `/^hello-world.*/`. |
19+
savePath | string | Optional. File path to save the command's output, relative to `saveDirectory`. |
20+
saveDirectory | string | Optional. Directory to save the command's output. If the directory doesn't exist, creates the directory. If not specified, the directory is your media directory. |
21+
maxVariation | integer | Optional. Allowed variation in percentage of text different between the current output and previously saved output. If the difference between the current output and the previous output is greater than `maxVariation`, the step fails. If output doesn't exist at `savePath`, this value is ignored. | `0`
22+
overwrite | string | Optional. If `true`, overwrites the existing output at `savePath` if it exists.
23+
If `byVariation`, overwrites the existing output at `savePath` if the difference between the new output and the existing output is greater than `maxVariation`.<br/><br/>Accepted values: `true`, `false`, `byVariation` | `false`
24+
timeout | integer | Optional. Max time in milliseconds the command is allowed to run. If the command runs longer than this, the step fails. | `60000`
25+
setVariables | array of objects | Optional. Extract environment variables from the command's output. | ``[]``
26+
setVariables.name | string | Required. Name of the environment variable to set. |
27+
setVariables.regex | string | Required. Regex to extract the environment variable from the command's output. |
28+
outputs | object | Optional. Outputs from step processes and user-defined expressions. Use the `outputs` object to reference outputs in subsequent steps. If a user-defined output matches the key for a step-defined output, the user-defined output takes precedence. |
29+
outputs.stdout | string | Optional. Standard output of the command. |
30+
outputs.stderr | string | Optional. Standard error of the command. |
31+
outputs.exitCode | integer | Optional. Exit code of the command. |
32+
33+
## Examples
34+
35+
```json
36+
{
37+
"action": "runCode",
38+
"language": "javascript",
39+
"code": "console.log('Hello, ${process.env.USER}!');"
40+
}
41+
```
42+
43+
```json
44+
{
45+
"action": "runCode",
46+
"language": "bash",
47+
"code": "docker run hello-world",
48+
"timeout": 20000,
49+
"exitCodes": [
50+
0
51+
],
52+
"output": "Hello from Docker!"
53+
}
54+
```
55+
56+
```json
57+
{
58+
"action": "runCode",
59+
"language": "javascript",
60+
"code": "return false",
61+
"exitCodes": [
62+
1
63+
]
64+
}
65+
```
66+
67+
```json
68+
{
69+
"action": "runCode",
70+
"language": "python",
71+
"code": "print('Hello from Python')",
72+
"workingDirectory": ".",
73+
"exitCodes": [
74+
0
75+
],
76+
"output": "Hello from Python!",
77+
"savePath": "python-output.txt",
78+
"saveDirectory": "output",
79+
"maxVariation": 10,
80+
"overwrite": "byVariation"
81+
}
82+
```

docs/references/schemas/saveScreenshot.md

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@ description | string | Optional. Description of the step. |
1212
action | string | Required. The action to perform. |
1313
path | string | Optional. File path of the PNG file, relative to `directory`. If not specified, the file name is the ID of the step. |
1414
directory | string | Optional. Directory of the PNG file. If the directory doesn't exist, creates the directory. |
15-
maxVariation | number | Optional. Allowed variation in percentage of pixels between the new screenshot and the existing screenshot at `path`. If the difference between the new screenshot and the existing screenshot is greater than `maxVariation`, the step fails. If a screenshot doesn't exist at `path`, the system ignores this value. | `5`
15+
maxVariation | number | Optional. Allowed variation in percentage of pixels between the new screenshot and the exisitng screenshot at `path`. If the difference between the new screenshot and the existing screenshot is greater than `maxVariation`, the step fails. If a screenshot doesn't exist at `path`, this value is ignored. | `5`
1616
overwrite | string | Optional. If `true`, overwrites the existing screenshot at `path` if it exists.
1717
If `byVariation`, overwrites the existing screenshot at `path` if the difference between the new screenshot and the existing screenshot is greater than `maxVariation`.<br/><br/>Accepted values: `true`, `false`, `byVariation` | `false`
18+
crop | object | Optional. Crops the screenshot. |
19+
crop.selector | string | Required. Selector of the element to crop the image to. |
20+
crop.padding | One of<br/>-&nbsp;number<br/>-&nbsp;object | Optional. undefined |
1821

1922
## Examples
2023

@@ -48,3 +51,43 @@ If `byVariation`, overwrites the existing screenshot at `path` if the difference
4851
"overwrite": "byVariation"
4952
}
5053
```
54+
55+
```json
56+
{
57+
"action": "saveScreenshot",
58+
"path": "results.png",
59+
"directory": "static/images",
60+
"crop": {
61+
"selector": "#element"
62+
}
63+
}
64+
```
65+
66+
```json
67+
{
68+
"action": "saveScreenshot",
69+
"path": "results.png",
70+
"directory": "static/images",
71+
"crop": {
72+
"selector": "#element",
73+
"padding": 10
74+
}
75+
}
76+
```
77+
78+
```json
79+
{
80+
"action": "saveScreenshot",
81+
"path": "results.png",
82+
"directory": "static/images",
83+
"crop": {
84+
"selector": "#element",
85+
"padding": {
86+
"top": 10,
87+
"right": 20,
88+
"bottom": 30,
89+
"left": 40
90+
}
91+
}
92+
}
93+
```

0 commit comments

Comments
 (0)