@clevertask/react-sortable-tree 0.0.8 → 0.0.9
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.
package/README.md
CHANGED
|
@@ -369,6 +369,11 @@ await expectItemNotToBeChildOf(expect, taskA, taskC);
|
|
|
369
369
|
### expectItemBefore
|
|
370
370
|
|
|
371
371
|
This helper tells you if an item is before the "x" item. You don't need a function for after because it's a matter of targeting the items in their proper places.
|
|
372
|
+
⚠️ You must add a `data-tree-item-label` to your HTML element that contains the tree label
|
|
373
|
+
|
|
374
|
+
```tsx
|
|
375
|
+
<p data-tree-item-label>{props.treeItem.label}</p>
|
|
376
|
+
```
|
|
372
377
|
|
|
373
378
|
```ts
|
|
374
379
|
await expectItemBefore(page, expect, 'C', 'A');
|
package/dist/e2e/index.js
CHANGED
|
@@ -1,51 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
function u(t, e, o) {
|
|
2
|
+
return t.getByRole("treeitem", {
|
|
3
|
+
name: e,
|
|
4
|
+
exact: (o == null ? void 0 : o.exact) ?? !0
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
async function g({ page: t, expect: e, from: o, to: s }) {
|
|
8
|
+
const i = t.getByLabel(`Drag ${o.name}`, { exact: !0 }), n = u(t, s.name).locator("[data-tree-draggable]");
|
|
9
|
+
await e(i).toBeVisible(), await e(n).toBeVisible();
|
|
10
|
+
const a = await i.boundingBox(), r = await n.boundingBox();
|
|
11
|
+
if (!a || !r)
|
|
6
12
|
throw new Error("Could not determine bounding boxes for drag operation");
|
|
7
|
-
const
|
|
8
|
-
let
|
|
9
|
-
const
|
|
10
|
-
switch (
|
|
11
|
-
case "before":
|
|
12
|
-
d =
|
|
13
|
+
const w = a.x + a.width / 2, m = a.y + a.height / 2;
|
|
14
|
+
let f = r.x + 8, d = r.y;
|
|
15
|
+
const h = 4, l = a.y > r.y;
|
|
16
|
+
switch (s.position) {
|
|
17
|
+
case "before": {
|
|
18
|
+
d = r.y + h, l && (d += a.height);
|
|
13
19
|
break;
|
|
14
|
-
|
|
15
|
-
|
|
20
|
+
}
|
|
21
|
+
case "after": {
|
|
22
|
+
d = r.y + r.height - h, l && (d += a.height);
|
|
16
23
|
break;
|
|
24
|
+
}
|
|
17
25
|
case "inside": {
|
|
18
|
-
const
|
|
19
|
-
if (!
|
|
26
|
+
const c = await n.boundingBox();
|
|
27
|
+
if (!c)
|
|
20
28
|
throw new Error("Could not determine draggable item bounds");
|
|
21
|
-
|
|
29
|
+
f = c.x + c.width * 0.25, l ? d = c.y + c.height * 2 : d = c.y + c.height * 0.75;
|
|
22
30
|
break;
|
|
23
31
|
}
|
|
24
32
|
}
|
|
25
|
-
await t.mouse.move(
|
|
33
|
+
await t.mouse.move(w, m), await t.mouse.down(), await t.mouse.move(w + 1, m + 1), await t.mouse.move(f, d, { steps: 10 }), await t.evaluate(() => new Promise(requestAnimationFrame)), await t.waitForTimeout(120), await t.mouse.up(), await t.waitForTimeout(120), await e(i).toHaveCount(1);
|
|
26
34
|
}
|
|
27
|
-
async function
|
|
35
|
+
async function b(t) {
|
|
28
36
|
const e = await t.getAttribute("data-tree-item-id");
|
|
29
37
|
if (!e)
|
|
30
38
|
throw new Error("Tree item does not have data-tree-item-id");
|
|
31
39
|
return e;
|
|
32
40
|
}
|
|
33
|
-
async function
|
|
34
|
-
const
|
|
35
|
-
|
|
41
|
+
async function y(t, e, o, s) {
|
|
42
|
+
const i = await t.locator('[role="treeitem"] [data-tree-item-label]').evaluateAll((r) => r.map((w) => {
|
|
43
|
+
var m;
|
|
44
|
+
return (m = w.textContent) == null ? void 0 : m.trim();
|
|
45
|
+
})), n = i.indexOf(o), a = i.indexOf(s);
|
|
46
|
+
e(n).toBeLessThan(a);
|
|
36
47
|
}
|
|
37
|
-
async function
|
|
38
|
-
const a = await
|
|
39
|
-
await
|
|
48
|
+
async function B(t, e, o, s) {
|
|
49
|
+
const i = u(t, o), n = u(t, s), a = await b(n);
|
|
50
|
+
await e(i).toHaveAttribute("data-tree-item-parent-id", a);
|
|
40
51
|
}
|
|
41
|
-
async function
|
|
42
|
-
const a = await
|
|
43
|
-
await
|
|
52
|
+
async function I(t, e, o, s) {
|
|
53
|
+
const i = u(t, o), n = u(t, s), a = await b(n);
|
|
54
|
+
await e(i).not.toHaveAttribute("data-tree-item-parent-id", a);
|
|
44
55
|
}
|
|
45
56
|
export {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
57
|
+
g as dragItem,
|
|
58
|
+
y as expectItemBefore,
|
|
59
|
+
I as expectItemNotToBeChildOf,
|
|
60
|
+
B as expectItemToBeChildOf,
|
|
61
|
+
u as getTreeItem,
|
|
62
|
+
b as getTreeItemId
|
|
51
63
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function expectItemBefore(page: Page, expect: Expect,
|
|
1
|
+
import { Page, Expect } from '@playwright/test';
|
|
2
|
+
export declare function expectItemBefore(page: Page, expect: Expect, beforeLabel: string, afterLabel: string): Promise<void>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function expectItemToBeChildOf(expect: Expect, child:
|
|
3
|
-
export declare function expectItemNotToBeChildOf(expect: Expect, child:
|
|
1
|
+
import { Page, Expect } from '@playwright/test';
|
|
2
|
+
export declare function expectItemToBeChildOf(page: Page, expect: Expect, child: string, parent: string): Promise<void>;
|
|
3
|
+
export declare function expectItemNotToBeChildOf(page: Page, expect: Expect, child: string, parent: string): Promise<void>;
|