Skip to content

Commit 34e5340

Browse files
committed
test: add e2e test for preserving marks when editing a link (#2573)
1 parent 9da3e59 commit 34e5340

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { expect } from "@playwright/test";
2+
import { test } from "../../setup/setupScript.js";
3+
import { BASE_URL, LINK_BUTTON_SELECTOR } from "../../utils/const.js";
4+
import { focusOnEditor } from "../../utils/editor.js";
5+
6+
test.beforeEach(async ({ page }) => {
7+
await page.goto(BASE_URL);
8+
});
9+
10+
test.describe("Check Link Toolbar functionality", () => {
11+
test("Should preserve existing marks when editing a link", async ({
12+
page,
13+
}) => {
14+
await focusOnEditor(page);
15+
16+
// Type bold text
17+
await page.keyboard.type("hello");
18+
await page.keyboard.press("Shift+Home");
19+
20+
// Make it bold via formatting toolbar
21+
await page.waitForSelector(`[data-test="bold"]`);
22+
await page.click(`[data-test="bold"]`);
23+
24+
// Add link
25+
await page.keyboard.press("Shift+Home");
26+
await page.waitForSelector(LINK_BUTTON_SELECTOR);
27+
await page.click(LINK_BUTTON_SELECTOR);
28+
await page.keyboard.type("https://example.com");
29+
await page.keyboard.press("Enter");
30+
31+
// Move cursor back onto the linked text to trigger link toolbar
32+
await page.keyboard.press("ArrowLeft");
33+
await page.waitForTimeout(500);
34+
35+
// Click Edit link button
36+
const editButton = page.getByText("Edit link");
37+
await editButton.waitFor({ state: "visible" });
38+
await editButton.click();
39+
40+
await page.keyboard.press("Control+A");
41+
await page.keyboard.type("https://example2.com");
42+
await page.keyboard.press("Enter");
43+
44+
await page.waitForTimeout(300);
45+
46+
// Verify bold mark is still present on the text
47+
const boldText = page.locator("strong a, a strong");
48+
await expect(boldText).toBeVisible();
49+
});
50+
});

0 commit comments

Comments
 (0)