Skip to content

Commit 759942e

Browse files
committed
- Update links in documentation to remove file extensions for consistency
- Add new tests documentation page with detailed structure and examples - Refactor JsonYamlTabs component to use Docusaurus components for better integration
1 parent 260eabb commit 759942e

File tree

4 files changed

+79
-81
lines changed

4 files changed

+79
-81
lines changed

docs/get-started/concepts.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ A [test specification](/docs/references/schemas/specification) is a group of tes
1212

1313
## Test
1414

15-
A [test](/docs/get-started/tests/index.md) is a sequence of steps to perform. Conceptually parallel to a procedure.
15+
A [test](/docs/get-started/tests/index) is a sequence of steps to perform. Conceptually parallel to a procedure.
1616

1717
## Step
1818

@@ -24,23 +24,23 @@ An action is the task performed in a step. Doc Detective supports a variety of a
2424

2525
| Name | Description |
2626
| :---------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------- |
27-
| [checkLink](/docs/get-started/actions/checkLink.md) | Check if a URL returns an acceptable status code from a GET request. |
28-
| [find](/docs/get-started/actions/find.md) | Locate and interact with an element on the page. |
29-
| [click](/docs/get-started/actions/click.md) | Click an element. |
30-
| [goTo](/docs/get-started/actions/goTo.md) | Navigate to a specified URL. |
31-
| [httpRequest](/docs/get-started/actions/httpRequest.md) | Perform a generic HTTP request, for example to an API. |
32-
| [runShell](/docs/get-started/actions/runShell.md) | Perform a native shell command. |
33-
| [screenshot](/docs/get-started/actions/screenshot.md) | Take a screenshot in PNG format. |
34-
| [loadVariables](/docs/get-started/actions/loadVariables.md) | Load environment variables from a `.env` file. |
35-
| [record](/docs/get-started/actions/record.md) | Capture a video of test run. |
36-
| [stopRecord](/docs/get-started/actions/stopRecord.md) | Stop capturing a video of test run. |
37-
| [type](/docs/get-started/actions/type.md) | Type keys. To type special keys, begin and end the string with `$` and use the special key’s enum. For example, to type the Escape key, enter `$ESCAPE$`. |
38-
| [wait](/docs/get-started/actions/wait.md) | Pause before performing the next action. |
27+
| [checkLink](/docs/get-started/actions/checkLink) | Check if a URL returns an acceptable status code from a GET request. |
28+
| [find](/docs/get-started/actions/find) | Locate and interact with an element on the page. |
29+
| [click](/docs/get-started/actions/click) | Click an element. |
30+
| [goTo](/docs/get-started/actions/goTo) | Navigate to a specified URL. |
31+
| [httpRequest](/docs/get-started/actions/httpRequest) | Perform a generic HTTP request, for example to an API. |
32+
| [runShell](/docs/get-started/actions/runShell) | Perform a native shell command. |
33+
| [screenshot](/docs/get-started/actions/screenshot) | Take a screenshot in PNG format. |
34+
| [loadVariables](/docs/get-started/actions/loadVariables) | Load environment variables from a `.env` file. |
35+
| [record](/docs/get-started/actions/record) | Capture a video of test run. |
36+
| [stopRecord](/docs/get-started/actions/stopRecord) | Stop capturing a video of test run. |
37+
| [type](/docs/get-started/actions/type) | Type keys. To type special keys, begin and end the string with `$` and use the special key’s enum. For example, to type the Escape key, enter `$ESCAPE$`. |
38+
| [wait](/docs/get-started/actions/wait) | Pause before performing the next action. |
3939

4040
## Context
4141

42-
A [context](/docs/references/schemas/context.md) consists of an application and platforms that support the tests.
42+
A [context](/docs/references/schemas/context) consists of an application and platforms that support the tests.
4343

4444
## Next steps
4545

46-
- [Create your first test](/docs/get-started/create-your-first-test.md)
46+
- [Create your first test](/docs/get-started/create-your-first-test)

docs/get-started/create-your-first-test.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ In this tutorial, you will create a basic test that navigates to a webpage, vali
88

99
## What is a test?
1010

11-
A [test](/docs/get-started/tests/index.md) in Doc Detective is a series of steps, where each step performs a single [action](/docs/category/actions). An action can be navigating to a URL, finding an element, or taking a screenshot, for example.
11+
A [test](/docs/get-started/tests/index) in Doc Detective is a series of steps, where each step performs a single [action](/docs/category/actions). An action can be navigating to a URL, finding an element, or taking a screenshot, for example.
1212

1313
## What does this test do?
1414

@@ -18,7 +18,7 @@ This test navigates to `https://example.com`, checks for the presence of the `<h
1818

1919
Before you begin, ensure you have the following:
2020

21-
- [Doc Detective installed](/docs/get-started/installation.md).
21+
- [Doc Detective installed](/docs/get-started/installation).
2222
- A text editor.
2323

2424
## Steps
@@ -68,10 +68,10 @@ To create your first test, follow these steps:
6868

6969
This test uses the following actions:
7070

71-
- [`goTo`](/docs/get-started/actions/goTo.md): Navigates to the specified URL, https://example.com, to start the test flow.
72-
- [`find`](/docs/get-started/actions/find.md): Locates elements on the page using CSS selectors such as HTML tags like `h1` or `a`, and validates their presence and text content.
73-
- [`click`](/docs/get-started/actions/click.md): Clicks on the specified element, in this case, the `More information...` link.
74-
- [`screenshot`](/docs/get-started/actions/screenshot.md): Captures a screenshot of the current page and saves it to the specified path.
71+
- [`goTo`](/docs/get-started/actions/goTo): Navigates to the specified URL, https://example.com, to start the test flow.
72+
- [`find`](/docs/get-started/actions/find): Locates elements on the page using CSS selectors such as HTML tags like `h1` or `a`, and validates their presence and text content.
73+
- [`click`](/docs/get-started/actions/click): Clicks on the specified element, in this case, the `More information...` link.
74+
- [`screenshot`](/docs/get-started/actions/screenshot): Captures a screenshot of the current page and saves it to the specified path.
7575

7676
4. Save the file.
7777

docs/get-started/tests/index.md renamed to docs/get-started/tests/index.mdx

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ sidebar_position: 4
33
description: Tests tell Doc Detective what actions to perform, how, and where.
44
---
55

6+
import JsonYamlTabs from "@site/src/components/JsonYamlTabs";
7+
68
# Tests
79

810
> Want help writing your test steps? Check out the [Action Builder prototype](/app).
@@ -36,29 +38,26 @@ You can define test specs in multiple ways:
3638
- [Inline JSON](#inline-json) allows you to define tests directly in your documentation source files.
3739
- [Detected tests](#detected-tests) are automatically generated by Doc Detective based on your documentation source files and your configuration.
3840

39-
### Standalone JSON
41+
### Standalone JSON or YAML
4042

41-
Test specs in standalone JSON files use the following basic structure:
43+
Test specs in standalone JSON or YAML files use the following basic structure:
4244

43-
```json
44-
{
45-
"specId": "spec-id",
46-
"description": "Spec Description",
47-
"tests": [
45+
{<JsonYamlTabs object={{
46+
specId: "spec-id",
47+
description: "Spec Description",
48+
tests: [
4849
{
49-
"testId": "test-id",
50-
"description": "Test Description",
51-
"steps": [
50+
testId: "test-id",
51+
description: "Test Description",
52+
steps: [
5253
{
53-
"stepId": "step-id",
54-
"description": "Step Description"
55-
// Additional step properties, such as find, goTo, httpRequest, etc.
54+
stepId: "step-id",
55+
description: "Step description. This object also needs additional step properties like `find`, `goTo`, or `httpRequest`."
5656
}
5757
]
5858
}
5959
]
60-
}
61-
```
60+
}}></JsonYamlTabs>}
6261

6362
> For comprehensive options, see [`specification`](/docs/references/schemas/specification).
6463
@@ -118,6 +117,7 @@ If you declare a step without declaring a test, Doc Detective automatically crea
118117
Doc Detective supports different comment patterns depending on your file type:
119118

120119
**Markdown files** (`.md`, `.markdown`, `.mdx`):
120+
121121
- JSX-style comments: `{/* test { "testId": "my-test" } */}`
122122
- HTML comments: `<!-- test { "testId": "my-test" } -->`
123123
- Markdown link comments: `[comment]: # (test { "testId": "my-test" })`
@@ -126,12 +126,14 @@ Doc Detective supports different comment patterns depending on your file type:
126126
- Ignore blocks: `{/* test ignore start */}` and `{/* test ignore end */}`
127127

128128
**HTML files** (`.html`, `.htm`):
129+
129130
- Test comments: `<!-- test { "testId": "my-test" } -->`
130131
- Step comments: `<!-- step { "goTo": "https://example.com" } -->`
131132
- Test end: `<!-- test end -->`
132133
- Ignore blocks: `<!-- test ignore start -->` and `<!-- test ignore end -->`
133134

134135
**AsciiDoc files** (`.adoc`, `.asciidoc`, `.asc`):
136+
135137
- Line comments: `// (test { "testId": "my-test" })`
136138
- Step comments: `// (step { "goTo": "https://example.com" })`
137139
- Test end: `// (test end)`
@@ -165,30 +167,21 @@ To search for American Shorthair kittens,
165167
Here's the same example using **YAML syntax** in Markdown:
166168

167169
```markdown
168-
{/* test testId: kitten-search */}
170+
{/_ test testId: kitten-search _/}
169171

170172
To search for American Shorthair kittens,
171173

172174
1. Go to [Google](https://www.google.com).
173175

174-
{/* step goTo: https://www.google.com */}
176+
{/_ step goTo: https://www.google.com _/}
175177

176178
2. In the search bar, enter "American Shorthair kittens", then press Enter.
177179

178-
{/* step find:
179-
selector: "[title=Search]"
180-
click: true
181-
*/}
182-
{/* step type:
183-
- "American Shorthair kittens"
184-
- "$ENTER$"
185-
*/}
186-
{/* step wait: 5000 */}
180+
{/_ step find: selector: "[title=Search]" click: true _/} {/_ step type: - "American Shorthair kittens" - "$ENTER$" _/} {/_ step wait: 5000 _/}
187181

188182
![Search results](search-results.png)
189183

190-
{/* step screenshot: search-results.png */}
191-
{/* test end */}
184+
{/_ step screenshot: search-results.png _/} {/_ test end _/}
192185
```
193186

194187
**HTML example**:
@@ -229,7 +222,7 @@ Detected tests are useful for keeping your tests in sync with your documentation
229222
230223
Doc Detective includes several default markup patterns for Markdown files. Here are all the built-in patterns:
231224

232-
```json
225+
````json
233226
{
234227
"fileTypes": [
235228
{
@@ -311,48 +304,54 @@ Doc Detective includes several default markup patterns for Markdown files. Here
311304
}
312305
]
313306
}
314-
```
307+
````
315308

316309
#### Default markup pattern descriptions
317310

318311
**checkHyperlink**: Detects standard Markdown links (excluding images) and checks that they return a valid HTTP status code.
312+
319313
- Pattern: `[link text](https://example.com)`
320314
- Action: Performs a GET request to verify the link is accessible
321315

322316
**clickOnscreenText**: Detects action verbs followed by bold text and clicks on that element.
317+
323318
- Pattern: `Click **Button Name**`, `Tap **Menu Item**`, `Select **Option**`
324319
- Action: Clicks on the specified element using its text content
325320

326321
**findOnscreenText**: Detects any bold text and verifies it exists on the page.
322+
327323
- Pattern: `**Any Bold Text**`
328324
- Action: Searches for the text on the current page
329325

330326
**goToUrl**: Detects navigation instructions with links and opens the URL.
327+
331328
- Pattern: `Go to [Page Name](https://example.com)`, `Navigate to [Site](https://example.com)`
332329
- Action: Opens the specified URL in the browser
333330

334331
**screenshotImage**: Detects images with a `.screenshot` class or attribute and takes a screenshot.
332+
335333
- Pattern: `![Alt text](image.png){.screenshot}`
336334
- Action: Saves a screenshot to the specified path
337335

338336
**typeText**: Detects typing instructions with quoted text and types the content.
337+
339338
- Pattern: `Type "Hello World"`, `Enter "username"`
340339
- Action: Types the specified text into the active element
341340

342341
**httpRequestFormat**: Detects HTTP request code blocks and executes the request.
342+
343343
- Pattern: HTTP request in code blocks with method, URL, headers, and body
344344
- Action: Executes the HTTP request with the specified parameters
345345

346346
**runCode**: Detects code blocks in supported languages and executes the code.
347+
347348
- Pattern: Code blocks with `bash`, `python`, `py`, `javascript`, or `js` language tags (excluding those marked with `testIgnore`)
348349
- Action: Executes the code in the specified language (marked as unsafe)
349350

350351
The `regex` property defines the regular expression patterns to match, and the `actions` property defines the actions to perform when the pattern is detected. With the default configuration, Doc Detective would take the following Markdown and generate tests automatically:
351352

352353
Markdown:
353354

354-
<!-- test-start {"detectSteps":false} -->
355-
356355
```markdown
357356
To get started,
358357

@@ -365,8 +364,6 @@ Check out our [documentation](https://docs.example.com) for more information.
365364
![Search results](search-results.png){ .screenshot }
366365
```
367366

368-
<!-- test-end -->
369-
370367
Detected tests:
371368

372369
```json
@@ -429,11 +426,13 @@ You can extend or override the default patterns by defining custom markup patter
429426
Doc Detective also includes default configurations for HTML and AsciiDoc files, though these only include inline statement patterns for test definitions and don't include markup patterns for detected tests:
430427

431428
**HTML files** (`.html`, `.htm`):
429+
432430
- Uses HTML comment syntax for inline test statements
433431
- Example: `<!-- test { "testId": "my-test" } -->`
434432

435433
**AsciiDoc files** (`.adoc`, `.asciidoc`, `.asc`):
436-
- Uses AsciiDoc comment syntax for inline test statements
434+
435+
- Uses AsciiDoc comment syntax for inline test statements
437436
- Example: `// (test { "testId": "my-test" })`
438437

439438
To add detected test functionality to HTML or AsciiDoc files, you would need to define custom markup patterns in your configuration similar to the Markdown examples above.
Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
1-
import React, { useState } from 'react';
2-
import { Tabs, Tab } from 'react-bootstrap';
3-
import yaml from 'yaml';
1+
import React, { useState } from "react";
2+
import yaml from "yaml";
3+
import Tabs from "@theme/Tabs";
4+
import TabItem from "@theme/TabItem";
5+
import CodeBlock from "@theme/CodeBlock";
46

5-
const JsonYamlTabs = ({ jsonInput }) => {
6-
const [yamlOutput, setYamlOutput] = useState('');
7-
8-
const handleTabSelect = (key) => {
9-
if (key === 'yaml') {
10-
const parsedJson = JSON.parse(jsonInput);
11-
const yamlString = yaml.stringify(parsedJson);
12-
setYamlOutput(yamlString);
13-
}
14-
};
15-
// Change to use Docusaurus code block
16-
return (
17-
<Tabs defaultActiveKey="json" onSelect={handleTabSelect}>
18-
<Tab eventKey="json" title="JSON">
19-
<pre>{jsonInput}</pre>
20-
</Tab>
21-
<Tab eventKey="yaml" title="YAML">
22-
<pre>{yamlOutput}</pre>
23-
</Tab>
24-
</Tabs>
25-
);
7+
const JsonYamlTabs = ({ object }) => {
8+
const jsonInput = JSON.stringify(object, null, 2);
9+
const yamlOutput = yaml.stringify(object, { lineWidth: -1 });
10+
// Change to use Docusaurus code block
11+
return (
12+
<Tabs defaultValue="json">
13+
<TabItem value="json" label="JSON">
14+
<CodeBlock language="json" showLineNumbers>
15+
{jsonInput}
16+
</CodeBlock>
17+
</TabItem>
18+
<TabItem value="yaml" label="YAML">
19+
<CodeBlock language="yaml" showLineNumbers>
20+
{yamlOutput}
21+
</CodeBlock>
22+
</TabItem>
23+
</Tabs>
24+
);
2625
};
2726

28-
export default JsonYamlTabs;
27+
export default JsonYamlTabs;

0 commit comments

Comments
 (0)