@uxf/e2e-playwright 11.129.0 → 11.130.0

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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const test_1 = require("@playwright/test");
4
+ /**
5
+ * The section dialog goes through `openModal`, which needs a provider in the layout to render into.
6
+ * Without one it silently does nothing, which is how this went unnoticed.
7
+ */
8
+ (0, test_1.test)("content builder opens the add section dialog", async ({ page }) => {
9
+ await page.goto("/examples/cms/content-builder/Default");
10
+ await page.getByText("Přidat sekci", { exact: true }).click();
11
+ await (0, test_1.expect)(page.getByRole("heading", { name: "Přidat sekci" })).toBeVisible();
12
+ await (0, test_1.expect)(page.getByText("Strukturovaný text", { exact: true })).toBeVisible();
13
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const test_1 = require("@playwright/test");
4
+ const STORY = "/examples/cms/wysiwyg-input/Default";
5
+ const EDITABLE = ".uxf-wysiwyg__editable";
6
+ const FIELD = ".uxf-text-input";
7
+ /**
8
+ * The editor as a field inside a form, which is how backoffice uses it and the one shape the wysiwyg
9
+ * playground cannot cover: focus handover, tabbing past the editor, and submitting through it.
10
+ */
11
+ async function openStory(page) {
12
+ await page.goto(STORY);
13
+ await (0, test_1.expect)(page.locator(EDITABLE)).toBeVisible();
14
+ }
15
+ function saveButton(page) {
16
+ return page.getByText("Uložit", { exact: true });
17
+ }
18
+ /** Where focus actually is, named by the class the design system puts on it. */
19
+ function activeElementClass(page) {
20
+ return page.evaluate(() => {
21
+ const el = document.activeElement;
22
+ return el ? el.className : "";
23
+ });
24
+ }
25
+ test_1.test.describe("wysiwyg input focus", () => {
26
+ (0, test_1.test)("clicking into the editor marks the surrounding field focused", async ({ page }) => {
27
+ await openStory(page);
28
+ const field = page.locator(FIELD).filter({ has: page.locator(EDITABLE) });
29
+ await (0, test_1.expect)(field).not.toHaveClass(/is-focused/);
30
+ await page.locator(EDITABLE).click();
31
+ await (0, test_1.expect)(field).toHaveClass(/is-focused/);
32
+ });
33
+ (0, test_1.test)("tabs from the field above into the editor and out into the field below", async ({ page }) => {
34
+ await openStory(page);
35
+ await page.locator('input[name="title"]').focus();
36
+ await page.keyboard.press("Tab");
37
+ (0, test_1.expect)(await activeElementClass(page)).toContain("uxf-wysiwyg__editable");
38
+ await page.keyboard.press("Tab");
39
+ (0, test_1.expect)(await activeElementClass(page)).toContain("uxf-input__element");
40
+ await (0, test_1.expect)(page.locator('input[name="perex"]')).toBeFocused();
41
+ });
42
+ });
43
+ test_1.test.describe("wysiwyg input dialogs", () => {
44
+ // openModal needs a provider in the layout to render into, or it silently does nothing. The cms
45
+ // example had none, so every dialog in these stories was a dead click.
46
+ (0, test_1.test)("opens the image dialog from the toolbar", async ({ page }) => {
47
+ await openStory(page);
48
+ await page.locator(".uxf-wysiwyg__toolbar-button-image").first().click();
49
+ await (0, test_1.expect)(page.locator("#insert-image-form")).toBeVisible();
50
+ });
51
+ });
52
+ test_1.test.describe("wysiwyg input submit", () => {
53
+ (0, test_1.test)("carries what was typed into the submitted value", async ({ page }) => {
54
+ await openStory(page);
55
+ await page.locator(EDITABLE).click();
56
+ await page.keyboard.type("obsah článku");
57
+ await saveButton(page).click();
58
+ const submitted = page.getByTestId("submitted-value");
59
+ await (0, test_1.expect)(submitted).toBeVisible();
60
+ await (0, test_1.expect)(submitted).toContainText("obsah článku");
61
+ });
62
+ (0, test_1.test)("blocks submitting while the editor is empty", async ({ page }) => {
63
+ await openStory(page);
64
+ await saveButton(page).click();
65
+ await (0, test_1.expect)(page.getByText("Obsah je povinný")).toBeVisible();
66
+ await (0, test_1.expect)(page.getByTestId("submitted-value")).toHaveCount(0);
67
+ });
68
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/e2e-playwright",
3
- "version": "11.129.0",
3
+ "version": "11.130.0",
4
4
  "description": "UXF Playwright helpers",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -13,7 +13,7 @@ const test_1 = require("@playwright/test");
13
13
  */
14
14
  exports.default = (0, test_1.defineConfig)({
15
15
  testDir: ".",
16
- testMatch: ["ui/**/*.e2e.ts", "data-grid/**/*.e2e.ts"],
16
+ testMatch: ["ui/**/*.e2e.ts", "cms/**/*.e2e.ts", "data-grid/**/*.e2e.ts", "wysiwyg/**/*.e2e.ts"],
17
17
  /* Run tests in files in parallel */
18
18
  fullyParallel: true,
19
19
  /* Fail the build on CI if you accidentally left test.only in the source code. */
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,221 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const test_1 = require("@playwright/test");
4
+ const PLAYGROUND = "/examples/wysiwyg/playground";
5
+ const EDITABLE = ".uxf-wysiwyg__editable";
6
+ /** What jsdom cannot see: which element a toolbar button produces, and whether the popovers work. */
7
+ async function openPlayground(page) {
8
+ await page.goto(PLAYGROUND);
9
+ await (0, test_1.expect)(page.locator(EDITABLE)).toBeVisible();
10
+ }
11
+ /** Replaces the document with a single paragraph holding `text`, and leaves it selected. */
12
+ async function typeFresh(page, text) {
13
+ await page.locator(EDITABLE).click();
14
+ await page.keyboard.press("ControlOrMeta+a");
15
+ await page.keyboard.type(text);
16
+ await page.keyboard.press("ControlOrMeta+a");
17
+ }
18
+ function toolbarButton(page, modifier) {
19
+ return page.locator(`.uxf-wysiwyg__toolbar-button-${modifier}`).first();
20
+ }
21
+ /** Toolbar order of the marks group. */
22
+ const MARKS = [
23
+ ["bold", "uxf-wysiwyg__element-bold"],
24
+ ["italic", "uxf-wysiwyg__element-italic"],
25
+ ["underline", "uxf-wysiwyg__element-underline"],
26
+ ["code", "uxf-wysiwyg__element-code"],
27
+ ["highlight", "uxf-wysiwyg__element-highlight"],
28
+ ];
29
+ test_1.test.describe("wysiwyg marks", () => {
30
+ MARKS.forEach(([name, elementClass], index) => {
31
+ (0, test_1.test)(`${name} wraps and unwraps the selection`, async ({ page }) => {
32
+ await openPlayground(page);
33
+ await typeFresh(page, "označený text");
34
+ const marks = page.locator(".uxf-wysiwyg__toolbar-button-group-marks .uxf-wysiwyg__toolbar-button-mark");
35
+ await (0, test_1.expect)(marks).toHaveCount(MARKS.length);
36
+ await marks.nth(index).click();
37
+ await (0, test_1.expect)(page.locator(`${EDITABLE} .${elementClass}`)).toHaveCount(1);
38
+ await marks.nth(index).click();
39
+ await (0, test_1.expect)(page.locator(`${EDITABLE} .${elementClass}`)).toHaveCount(0);
40
+ });
41
+ });
42
+ });
43
+ test_1.test.describe("wysiwyg blocks", () => {
44
+ [1, 2, 3, 4, 5, 6].forEach((level) => {
45
+ (0, test_1.test)(`h${level} applies to the current block`, async ({ page }) => {
46
+ await openPlayground(page);
47
+ await typeFresh(page, "Nadpis");
48
+ const headings = page.locator(".uxf-wysiwyg__toolbar-button-group-headings .uxf-wysiwyg__toolbar-button-element");
49
+ await (0, test_1.expect)(headings).toHaveCount(6);
50
+ await headings.nth(level - 1).click();
51
+ await (0, test_1.expect)(page.locator(`${EDITABLE} .uxf-wysiwyg__element-heading-h${level}`)).toHaveCount(1);
52
+ });
53
+ });
54
+ (0, test_1.test)("blockquote toggles, splits on Enter and is left on the second Enter", async ({ page }) => {
55
+ await openPlayground(page);
56
+ await typeFresh(page, "citace");
57
+ await page.locator(".uxf-wysiwyg__toolbar-button-group-blocks .uxf-wysiwyg__toolbar-button-element").click();
58
+ await (0, test_1.expect)(page.locator(`${EDITABLE} .uxf-wysiwyg__element-blockquote`)).toHaveCount(1);
59
+ // Enter splits the quote, and a second Enter on the empty line leaves it. Click the quote
60
+ // itself rather than the editable: a click anywhere else lands the caret in another block.
61
+ await page.locator(`${EDITABLE} .uxf-wysiwyg__element-blockquote`).click();
62
+ await page.keyboard.press("End");
63
+ await page.keyboard.press("Enter");
64
+ await (0, test_1.expect)(page.locator(`${EDITABLE} .uxf-wysiwyg__element-blockquote`)).toHaveCount(2);
65
+ await page.keyboard.press("Enter");
66
+ await (0, test_1.expect)(page.locator(`${EDITABLE} .uxf-wysiwyg__element-blockquote`)).toHaveCount(1);
67
+ });
68
+ (0, test_1.test)("shift+enter still soft-breaks inside a quote", async ({ page }) => {
69
+ await openPlayground(page);
70
+ await typeFresh(page, "citace");
71
+ await page.locator(".uxf-wysiwyg__toolbar-button-group-blocks .uxf-wysiwyg__toolbar-button-element").click();
72
+ await page.locator(EDITABLE).click();
73
+ await page.keyboard.press("End");
74
+ await page.keyboard.press("Shift+Enter");
75
+ await (0, test_1.expect)(page.locator(`${EDITABLE} .uxf-wysiwyg__element-blockquote`)).toHaveCount(1);
76
+ });
77
+ (0, test_1.test)("bulleted and numbered lists produce ul and ol", async ({ page }) => {
78
+ await openPlayground(page);
79
+ await typeFresh(page, "položka");
80
+ const lists = page.locator(".uxf-wysiwyg__toolbar-button-group-lists .uxf-wysiwyg__toolbar-button-list");
81
+ await (0, test_1.expect)(lists).toHaveCount(2);
82
+ await lists.nth(0).click();
83
+ await (0, test_1.expect)(page.locator(`${EDITABLE} .uxf-wysiwyg__element-list-unordered`)).toHaveCount(1);
84
+ await (0, test_1.expect)(page.locator(`${EDITABLE} .uxf-wysiwyg__element-list-item`)).toHaveCount(1);
85
+ await lists.nth(1).click();
86
+ await (0, test_1.expect)(page.locator(`${EDITABLE} .uxf-wysiwyg__element-list-ordered`)).toHaveCount(1);
87
+ });
88
+ });
89
+ test_1.test.describe("wysiwyg floating link", () => {
90
+ (0, test_1.test)("inserts a link through the floating form", async ({ page }) => {
91
+ await openPlayground(page);
92
+ await typeFresh(page, "odkaz");
93
+ await toolbarButton(page, "link").click();
94
+ const form = page.locator(".uxf-wysiwyg__floating-link-insert__form");
95
+ await (0, test_1.expect)(form).toBeVisible();
96
+ await form.locator('input[name="url-address"]').fill("https://uxf.cz");
97
+ await form.locator(".uxf-wysiwyg__floating-link-insert__form-submit-button").click();
98
+ await (0, test_1.expect)(page.locator(`${EDITABLE} .uxf-wysiwyg__element-link`)).toHaveCount(1);
99
+ // Plate 53 sanitises the url, normalising an origin-only href to a trailing slash. The stored
100
+ // node keeps the url as typed.
101
+ await (0, test_1.expect)(page.locator(`${EDITABLE} .uxf-wysiwyg__element-link`)).toHaveAttribute("href", /^https:\/\/uxf\.cz\/?$/);
102
+ });
103
+ (0, test_1.test)("rejects an invalid url", async ({ page }) => {
104
+ await openPlayground(page);
105
+ await typeFresh(page, "odkaz");
106
+ await toolbarButton(page, "link").click();
107
+ const form = page.locator(".uxf-wysiwyg__floating-link-insert__form");
108
+ await form.locator('input[name="url-address"]').fill("nevalidní");
109
+ await form.locator(".uxf-wysiwyg__floating-link-insert__form-submit-button").click();
110
+ await (0, test_1.expect)(page.locator(`${EDITABLE} .uxf-wysiwyg__element-link`)).toHaveCount(0);
111
+ await (0, test_1.expect)(form).toBeVisible();
112
+ });
113
+ });
114
+ test_1.test.describe("wysiwyg modals", () => {
115
+ (0, test_1.test)("the button modal inserts a button element", async ({ page }) => {
116
+ await openPlayground(page);
117
+ await page.locator(EDITABLE).click();
118
+ await toolbarButton(page, "button").click();
119
+ const form = page.locator("#insert-button-form");
120
+ await (0, test_1.expect)(form).toBeVisible();
121
+ await form.locator('input[name="button-text"]').fill("Klikni");
122
+ await form.locator('input[name="url-address"]').fill("https://uxf.cz");
123
+ await form.locator(".uxf-wysiwyg__modal-button-submit").click();
124
+ await (0, test_1.expect)(page.locator(`${EDITABLE} .uxf-wysiwyg__element-button`)).toHaveCount(1);
125
+ await (0, test_1.expect)(form).toHaveCount(0);
126
+ });
127
+ (0, test_1.test)("the video modal previews and inserts an embed", async ({ page }) => {
128
+ await openPlayground(page);
129
+ await page.locator(EDITABLE).click();
130
+ await toolbarButton(page, "video").click();
131
+ const form = page.locator("#insert-video-form");
132
+ await (0, test_1.expect)(form).toBeVisible();
133
+ await form.locator('input[name="url-address"]').fill("https://www.youtube.com/watch?v=dQw4w9WgXcQ");
134
+ await (0, test_1.expect)(page.locator(".uxf-wysiwyg__insert-modal-video__iframe")).toBeVisible();
135
+ await form.locator(".uxf-wysiwyg__modal-button-submit").click();
136
+ await (0, test_1.expect)(page.locator(`${EDITABLE} .uxf-wysiwyg__element-video`)).toHaveCount(1);
137
+ });
138
+ (0, test_1.test)("the image modal opens and cancels without inserting", async ({ page }) => {
139
+ await openPlayground(page);
140
+ await page.locator(EDITABLE).click();
141
+ await toolbarButton(page, "image").click();
142
+ const form = page.locator("#insert-image-form");
143
+ await (0, test_1.expect)(form).toBeVisible();
144
+ await form.locator(".uxf-wysiwyg__modal-button-cancel").click();
145
+ await (0, test_1.expect)(form).toHaveCount(0);
146
+ });
147
+ });
148
+ test_1.test.describe("wysiwyg floating link placement", () => {
149
+ /**
150
+ * Plate 53 dropped the placement and middleware its link popover used to carry, so without ours it
151
+ * never flips above the selection, sits flush against it and centres instead of aligning to the
152
+ * start. All three are invisible to jsdom.
153
+ */
154
+ (0, test_1.test)("sits offset below the selection rather than flush against it", async ({ page }) => {
155
+ await openPlayground(page);
156
+ await typeFresh(page, "odkaz");
157
+ // The popover is placed against the DOM selection rect, so that is what to measure against.
158
+ const selection = await page.evaluate(() => {
159
+ const rect = window.getSelection().getRangeAt(0).getBoundingClientRect();
160
+ return { left: rect.left, bottom: rect.bottom };
161
+ });
162
+ await toolbarButton(page, "link").click();
163
+ const form = page.locator(".uxf-wysiwyg__floating-link-insert__form");
164
+ await (0, test_1.expect)(form).toBeVisible();
165
+ // The positioned element is the wrapper floating-ui places, not the form nested inside it.
166
+ const popover = await page.evaluate(() => {
167
+ const el = document.querySelector(".uxf-wysiwyg__floating-link-insert").parentElement;
168
+ const rect = el.getBoundingClientRect();
169
+ return { left: rect.left, top: rect.top };
170
+ });
171
+ (0, test_1.expect)(popover.top - selection.bottom).toBeGreaterThan(6);
172
+ (0, test_1.expect)(popover.top - selection.bottom).toBeLessThan(18);
173
+ });
174
+ (0, test_1.test)("flips above the selection when there is no room below", async ({ page }) => {
175
+ await page.setViewportSize({ height: 400, width: 1000 });
176
+ await openPlayground(page);
177
+ // Fill the document so the caret ends up near the bottom of a short viewport.
178
+ await page.locator(EDITABLE).click();
179
+ await page.keyboard.press("ControlOrMeta+a");
180
+ await page.keyboard.type(`${Array.from({ length: 12 }, (_, i) => `řádek ${i}`).join("\n")}\nodkaz`);
181
+ await page.keyboard.press("Shift+Home");
182
+ const caret = await page.locator(`${EDITABLE} [data-slate-node="element"]`).last().boundingBox();
183
+ await toolbarButton(page, "link").click();
184
+ const form = page.locator(".uxf-wysiwyg__floating-link-insert__form");
185
+ await (0, test_1.expect)(form).toBeVisible();
186
+ const popover = await form.boundingBox();
187
+ (0, test_1.expect)(popover.y + popover.height).toBeLessThanOrEqual(caret.y + 1);
188
+ });
189
+ });
190
+ test_1.test.describe("wysiwyg appearance", () => {
191
+ // slate-react set outline: none itself until 0.126; without our own rule the native ring returns.
192
+ (0, test_1.test)("shows no native focus ring on the editable", async ({ page }) => {
193
+ await openPlayground(page);
194
+ await page.locator(EDITABLE).click();
195
+ const outline = await page.locator(EDITABLE).evaluate((el) => window.getComputedStyle(el).outlineStyle);
196
+ (0, test_1.expect)(outline).toBe("none");
197
+ });
198
+ (0, test_1.test)("paints the highlight mark with its configured colour", async ({ page }) => {
199
+ await openPlayground(page);
200
+ await typeFresh(page, "zvýrazněno");
201
+ await page.locator(".uxf-wysiwyg__toolbar-button-group-marks .uxf-wysiwyg__toolbar-button-mark").nth(4).click();
202
+ const background = await page
203
+ .locator(`${EDITABLE} .uxf-wysiwyg__element-highlight`)
204
+ .evaluate((el) => window.getComputedStyle(el).backgroundColor);
205
+ (0, test_1.expect)(background).toBe("rgb(253, 224, 71)");
206
+ });
207
+ });
208
+ test_1.test.describe("wysiwyg history", () => {
209
+ (0, test_1.test)("undo and redo walk the edit back and forward", async ({ page }) => {
210
+ await openPlayground(page);
211
+ await typeFresh(page, "původní");
212
+ await page.keyboard.press("End");
213
+ await page.keyboard.type(" a přidané");
214
+ await (0, test_1.expect)(page.locator(EDITABLE)).toContainText("a přidané");
215
+ const group = page.locator(".uxf-wysiwyg__toolbar-button-group-undo-redo");
216
+ await group.locator(".uxf-wysiwyg__toolbar-button-undo").click();
217
+ await (0, test_1.expect)(page.locator(EDITABLE)).not.toContainText("a přidané");
218
+ await group.locator(".uxf-wysiwyg__toolbar-button-redo").click();
219
+ await (0, test_1.expect)(page.locator(EDITABLE)).toContainText("a přidané");
220
+ });
221
+ });