Skip to content

Commit 21d64fe

Browse files
authored
dragAndDrop action docs (#89)
* First pass at dragAndDrop docs * Update dragAndDrop docs * Add timeout description * Add to sidebar * Fixed broken links
1 parent ac996c2 commit 21d64fe

File tree

7 files changed

+147
-18
lines changed

7 files changed

+147
-18
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
---
2+
title: dragAndDrop
3+
layout: default
4+
nav_order: 3
5+
parent: Actions
6+
grand_parent: Tests
7+
description: Drag an element from a source location to a target location.
8+
---
9+
10+
# dragAndDrop
11+
12+
The `dragAndDrop` action allows you to drag an element and drop it at a target location. This is useful for testing drag-and-drop interfaces, reordering lists, moving items between containers, and other interactive UI elements.
13+
14+
The `dragAndDrop` action requires both a source and target element, which can be specified using element text, CSS/XPath selectors, or detailed objects with additional configuration options.
15+
16+
## Use Cases
17+
18+
The `dragAndDrop` action is particularly useful for testing:
19+
20+
- **Kanban boards**: Moving tasks between different status columns
21+
- **File uploads**: Dragging files from desktop to upload areas
22+
- **List reordering**: Changing the order of items in sortable lists
23+
- **Dashboard widgets**: Rearranging components on customizable dashboards
24+
- **Form builders**: Moving form elements between different sections
25+
- **Shopping carts**: Adding items by dragging them to the cart area
26+
27+
## Properties
28+
29+
The `dragAndDrop` action requires an object with the following properties:
30+
31+
- `source`: (Required) The element to drag from. Can be a string (element text or selector) or a detailed object.
32+
- `target`: (Required) The element to drop onto. Can be a string (element text or selector) or a detailed object.
33+
34+
### Source and Target Element Properties
35+
36+
When using detailed objects for `source` or `target`, you can specify:
37+
38+
- `elementText`: (Optional) Display text of the element. If combined with `selector`, the element must match both the text and the selector.
39+
- `selector`: (Optional) CSS or XPath selector of the element. If combined with `elementText`, the element must match both the text and the selector.
40+
- `timeout`: (Optional) Maximum duration in milliseconds to wait for this specific element to exist.
41+
42+
43+
> For comprehensive options, see the full [`dragAndDrop`](/docs/references/schemas/draganddrop) reference.
44+
45+
## Examples
46+
47+
Here are several ways you might use the `dragAndDrop` action:
48+
49+
### Drag and drop using selectors or element text
50+
51+
```json
52+
{
53+
"tests": [
54+
{
55+
"steps": [
56+
{
57+
"description": "Drag 'Item 1' and drop it onto 'Drop Zone'",
58+
"dragAndDrop": {
59+
"source": "#source-list .draggable-item:first-child",
60+
"target": "Drop Zone"
61+
}
62+
}
63+
]
64+
}
65+
]
66+
}
67+
```
68+
69+
### Drag and drop with detailed element objects
70+
71+
```json
72+
{
73+
"tests": [
74+
{
75+
"steps": [
76+
{
77+
"description": "Drag a specific task to a different column",
78+
"dragAndDrop": {
79+
"source": {
80+
"selector": ".task-card",
81+
"elementText": "Complete documentation"
82+
},
83+
"target": {
84+
"selector": ".column",
85+
"elementText": "In Progress"
86+
}
87+
}
88+
}
89+
]
90+
}
91+
]
92+
}
93+
```
94+
95+
## Related Actions
96+
97+
- [`click`](/docs/get-started/actions/click): Click elements to interact with them
98+
- [`find`](/docs/get-started/actions/find): Locate elements before performing other actions
99+
- [`wait`](/docs/get-started/actions/wait): Add delays for animations to complete

docs/get-started/tests/index.mdx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Tests tell Doc Detective what actions to perform, how, and where. Tests are made
1919

2020
- [**checkLink**](/docs/get-started/actions/checkLink): Check if a URL returns an acceptable status code from a GET request.
2121
- [**click**](/docs/get-started/actions/click): Click or tap an element.
22+
- [**dragAndDrop**](/docs/get-started/actions/dragAndDrop): Drag an element and drop it on a target.
2223
- [**find**](/docs/get-started/actions/find): Check if an element exists with the specified selector.
2324
- [**goTo**](/docs/get-started/actions/goTo): Navigate to a specified URL.
2425
- [**httpRequest**](/docs/get-started/actions/httpRequest): Perform a generic HTTP request, for example to an API.
@@ -36,8 +37,8 @@ Tests tell Doc Detective what actions to perform, how, and where. Tests are made
3637

3738
You can define test specs in multiple ways:
3839

39-
- [Standalone JSON files](#standalone-json) make it easy to see the entirety of the spec and keep it in a separate, machine-readable format.
40-
- [Inline JSON](#inline-json) allows you to define tests directly in your documentation source files.
40+
- [Standalone JSON files](#standalone-json-or-yaml) make it easy to see the entirety of the spec and keep it in a separate, machine-readable format.
41+
- [Inline JSON](#inline-json-or-yaml) allows you to define tests directly in your documentation source files.
4142
- [Detected tests](#detected-tests) are automatically generated by Doc Detective based on your documentation source files and your configuration.
4243

4344
### Standalone JSON or YAML
@@ -218,7 +219,7 @@ Doc Detective can automatically generate tests based on your documentation sourc
218219

219220
Detected tests are useful for keeping your tests in sync with your documentation. When you update your documentation, Doc Detective automatically updates the tests based on the new content. Detected tests are generated automatically. You can't edit detected tests directly, but you can update your config or documentation source files to change the tests.
220221

221-
> You can mix detected tests with [inline tests](#inline-json) to declare steps that might not be covered in your content, such starting or stopping a recording.
222+
> You can mix detected tests with [inline tests](#inline-json-or-yaml) to declare steps that might not be covered in your content, such starting or stopping a recording.
222223
223224
Doc Detective includes several default markup patterns for Markdown files. Here are all the built-in patterns:
224225

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
# dragAndDrop
3+
4+
5+
6+
## Referenced In
7+
8+
- [Markup definition](/docs/references/schemas/markup-definition)
9+
- [test](/docs/references/schemas/test)
10+
- [Resolved context](/docs/references/schemas/resolved-context)
11+
12+
## Fields
13+
14+
Field | Type | Description | Default
15+
:-- | :-- | :-- | :--
16+
dragAndDrop | object([dragAndDrop](/docs/references/schemas/draganddrop)) | Required. Drag and drop an element from source to target. |
17+
18+
## Examples
19+
20+
```json
21+
{
22+
"dragAndDrop": {}
23+
}
24+
```

package-lock.json

Lines changed: 14 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "doc-detective-docs",
3-
"version": "3.0.5",
3+
"version": "3.0.6",
44
"scripts": {
55
"docusaurus": "docusaurus",
66
"prestart": "npm run build-schemas",
@@ -21,7 +21,7 @@
2121
"doc-detective": "npx doc-detective@latest runTests"
2222
},
2323
"dependencies": {
24-
"@apidevtools/json-schema-ref-parser": "^14.1.1",
24+
"@apidevtools/json-schema-ref-parser": "^14.2.0",
2525
"@docusaurus/core": "^3.8.1",
2626
"@docusaurus/preset-classic": "^3.8.1",
2727
"@docusaurus/theme-mermaid": "^3.8.1",
@@ -31,7 +31,7 @@
3131
"@mui/icons-material": "^7.3.1",
3232
"@mui/material": "^7.3.1",
3333
"clsx": "^2.1.1",
34-
"doc-detective-common": "^3.2.0",
34+
"doc-detective-common": "^3.3.0",
3535
"dotenv": "^17.2.1",
3636
"https-browserify": "^1.0.0",
3737
"os-browserify": "^0.3.0",

sidebars.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const sidebars: SidebarsConfig = {
5252
items: [
5353
"get-started/actions/checkLink",
5454
"get-started/actions/click",
55+
"get-started/actions/dragAndDrop",
5556
"get-started/actions/find",
5657
"get-started/actions/goTo",
5758
"get-started/actions/httpRequest",

styles/config/vocabularies/Docs/accept.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ CLA
1010
CLEAR
1111
config
1212
CTRL
13+
dragAndDrop
14+
draggable
1315
defaultCommand
1416
detectSteps
1517
Dev

0 commit comments

Comments
 (0)