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