@uxf/e2e-playwright 11.130.0 → 11.130.1
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/package.json +1 -1
- package/wysiwyg/hotkeys.e2e.d.ts +1 -0
- package/wysiwyg/hotkeys.e2e.js +66 -0
- package/wysiwyg/wysiwyg.e2e.js +7 -0
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const test_1 = require("@playwright/test");
|
|
4
|
+
const EDITABLE = ".uxf-wysiwyg__editable";
|
|
5
|
+
/**
|
|
6
|
+
* Keyboard shortcuts, which nothing else covers: the toolbar tests click buttons, and a shortcut can be
|
|
7
|
+
* declared and still do nothing. Two ways it failed after the Plate 53 migration, both silent:
|
|
8
|
+
*
|
|
9
|
+
* - a `shortcuts.toggle` carrying only `keys` resolves through the plugin's own toggle transform, which
|
|
10
|
+
* Plate's own marks get from `toPlatePlugin` and a hand-written plugin does not have;
|
|
11
|
+
* - `keys` has to name the key the way the matcher sees it. `mod+shift+.` never fires, because the
|
|
12
|
+
* physical period key with shift held reports `event.key` as `>`. The spelling is `period`.
|
|
13
|
+
*/
|
|
14
|
+
/** Replaces the document with `text` and leaves it selected. */
|
|
15
|
+
async function selectFresh(page, text) {
|
|
16
|
+
await page.locator(EDITABLE).click();
|
|
17
|
+
await page.keyboard.press("ControlOrMeta+a");
|
|
18
|
+
await page.keyboard.type(text);
|
|
19
|
+
await page.keyboard.press("ControlOrMeta+a");
|
|
20
|
+
}
|
|
21
|
+
const MARKS = [
|
|
22
|
+
["bold", "ControlOrMeta+b", "uxf-wysiwyg__element-bold"],
|
|
23
|
+
["italic", "ControlOrMeta+i", "uxf-wysiwyg__element-italic"],
|
|
24
|
+
["underline", "ControlOrMeta+u", "uxf-wysiwyg__element-underline"],
|
|
25
|
+
["code", "ControlOrMeta+e", "uxf-wysiwyg__element-code"],
|
|
26
|
+
["highlight", "ControlOrMeta+Shift+h", "uxf-wysiwyg__element-highlight"],
|
|
27
|
+
];
|
|
28
|
+
test_1.test.describe("wysiwyg hotkeys", () => {
|
|
29
|
+
MARKS.forEach(([name, keys, className]) => {
|
|
30
|
+
(0, test_1.test)(`${keys} toggles ${name}`, async ({ page }) => {
|
|
31
|
+
await page.goto("/examples/wysiwyg/playground");
|
|
32
|
+
await selectFresh(page, "text");
|
|
33
|
+
await page.keyboard.press(keys);
|
|
34
|
+
await (0, test_1.expect)(page.locator(`${EDITABLE} .${className}`)).toHaveCount(1);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
(0, test_1.test)("ControlOrMeta+Shift+Period toggles a blockquote", async ({ page }) => {
|
|
38
|
+
await page.goto("/examples/wysiwyg/playground");
|
|
39
|
+
await selectFresh(page, "citace");
|
|
40
|
+
await page.keyboard.press("ControlOrMeta+Shift+Period");
|
|
41
|
+
await (0, test_1.expect)(page.locator(`${EDITABLE} .uxf-wysiwyg__element-blockquote`)).toHaveCount(1);
|
|
42
|
+
});
|
|
43
|
+
(0, test_1.test)("ControlOrMeta+Enter leaves the current block", async ({ page }) => {
|
|
44
|
+
await page.goto("/examples/wysiwyg/playground");
|
|
45
|
+
await selectFresh(page, "prvni");
|
|
46
|
+
await page.keyboard.press("ArrowRight");
|
|
47
|
+
await page.keyboard.press("ControlOrMeta+Enter");
|
|
48
|
+
await (0, test_1.expect)(page.locator(`${EDITABLE} [data-slate-node="element"]`)).not.toHaveCount(1);
|
|
49
|
+
});
|
|
50
|
+
(0, test_1.test)("ControlOrMeta+K opens the link popover", async ({ page }) => {
|
|
51
|
+
await page.goto("/examples/wysiwyg/playground");
|
|
52
|
+
await selectFresh(page, "odkaz");
|
|
53
|
+
await page.keyboard.press("ControlOrMeta+k");
|
|
54
|
+
await (0, test_1.expect)(page.locator(".uxf-wysiwyg__floating-link-insert__form")).toBeVisible();
|
|
55
|
+
});
|
|
56
|
+
(0, test_1.test)("ControlOrMeta+Z and ControlOrMeta+Shift+Z walk history", async ({ page }) => {
|
|
57
|
+
await page.goto("/examples/wysiwyg/playground");
|
|
58
|
+
await selectFresh(page, "puvodni");
|
|
59
|
+
await page.keyboard.press("End");
|
|
60
|
+
await page.keyboard.type(" pridane");
|
|
61
|
+
await page.keyboard.press("ControlOrMeta+z");
|
|
62
|
+
await (0, test_1.expect)(page.locator(EDITABLE)).not.toContainText("pridane");
|
|
63
|
+
await page.keyboard.press("ControlOrMeta+Shift+z");
|
|
64
|
+
await (0, test_1.expect)(page.locator(EDITABLE)).toContainText("pridane");
|
|
65
|
+
});
|
|
66
|
+
});
|
package/wysiwyg/wysiwyg.e2e.js
CHANGED
|
@@ -7,12 +7,19 @@ const EDITABLE = ".uxf-wysiwyg__editable";
|
|
|
7
7
|
async function openPlayground(page) {
|
|
8
8
|
await page.goto(PLAYGROUND);
|
|
9
9
|
await (0, test_1.expect)(page.locator(EDITABLE)).toBeVisible();
|
|
10
|
+
// The editable is in the DOM before the toolbar is, and the toolbar needs the editor from
|
|
11
|
+
// context - so waiting for a toolbar button is what says the editor is actually interactive.
|
|
12
|
+
// Without it, keystrokes sent under parallel load can land before Plate is listening.
|
|
13
|
+
await (0, test_1.expect)(page.locator(".uxf-wysiwyg__toolbar-button").first()).toBeVisible();
|
|
10
14
|
}
|
|
11
15
|
/** Replaces the document with a single paragraph holding `text`, and leaves it selected. */
|
|
12
16
|
async function typeFresh(page, text) {
|
|
13
17
|
await page.locator(EDITABLE).click();
|
|
14
18
|
await page.keyboard.press("ControlOrMeta+a");
|
|
15
19
|
await page.keyboard.type(text);
|
|
20
|
+
// Confirm the text landed before the test acts on it; a dropped keystroke otherwise surfaces
|
|
21
|
+
// as a confusing failure several steps later.
|
|
22
|
+
await (0, test_1.expect)(page.locator(EDITABLE)).toContainText(text);
|
|
16
23
|
await page.keyboard.press("ControlOrMeta+a");
|
|
17
24
|
}
|
|
18
25
|
function toolbarButton(page, modifier) {
|