@@ -453,6 +453,48 @@ test.describe("Functionality tests", () => {
453
453
await boldButton . click ( ) ;
454
454
expect ( await page . locator ( "strong" ) . count ( ) ) . toBe ( 0 ) ;
455
455
} ) ;
456
+
457
+ test ( "applies and removes bold formatting to the editor directly" , async ( {
458
+ mount,
459
+ page,
460
+ } ) => {
461
+ await mount ( < TextEditorDefaultComponent value = { unformattedValue } /> ) ;
462
+
463
+ const textbox = await page . locator ( "div[role='textbox']" ) ;
464
+
465
+ expect ( await page . locator ( "strong" ) . count ( ) ) . toBe ( 0 ) ;
466
+ expect ( await page . locator ( "span[data-lexical-text='true']" ) . count ( ) ) . toBe (
467
+ 1 ,
468
+ ) ;
469
+
470
+ await textbox . click ( ) ;
471
+
472
+ const boldButton = await page . locator (
473
+ "button[data-role='pw-rte-bold-button']" ,
474
+ ) ;
475
+
476
+ await boldButton . click ( ) ;
477
+ await textbox . click ( ) ;
478
+ await textbox . pressSequentially ( "This is some bold text" ) ;
479
+
480
+ expect ( await page . locator ( "strong" ) . count ( ) ) . toBe ( 1 ) ;
481
+ await page . locator ( "text=This is some bold text" ) . evaluate ( ( el ) => {
482
+ const style = window . getComputedStyle ( el ) ;
483
+ return Number ( style . fontWeight ) >= 700 ;
484
+ } ) ;
485
+
486
+ await boldButton . click ( ) ;
487
+ await textbox . click ( ) ;
488
+ await textbox . pressSequentially ( " and this is not" ) ;
489
+
490
+ expect ( await page . locator ( "span[data-lexical-text='true']" ) . count ( ) ) . toBe (
491
+ 2 ,
492
+ ) ;
493
+ await page . locator ( "text=and this is not" ) . evaluate ( ( el ) => {
494
+ const style = window . getComputedStyle ( el ) ;
495
+ return Number ( style . fontWeight ) < 700 ;
496
+ } ) ;
497
+ } ) ;
456
498
} ) ;
457
499
458
500
test . describe ( "Italic" , ( ) => {
@@ -473,6 +515,48 @@ test.describe("Functionality tests", () => {
473
515
await italicButton . click ( ) ;
474
516
expect ( await page . locator ( "em" ) . count ( ) ) . toBe ( 0 ) ;
475
517
} ) ;
518
+
519
+ test ( "applies and removes italic formatting to the editor directly" , async ( {
520
+ mount,
521
+ page,
522
+ } ) => {
523
+ await mount ( < TextEditorDefaultComponent value = { unformattedValue } /> ) ;
524
+
525
+ const textbox = await page . locator ( "div[role='textbox']" ) ;
526
+
527
+ expect ( await page . locator ( "em" ) . count ( ) ) . toBe ( 0 ) ;
528
+ expect ( await page . locator ( "span[data-lexical-text='true']" ) . count ( ) ) . toBe (
529
+ 1 ,
530
+ ) ;
531
+
532
+ await textbox . click ( ) ;
533
+
534
+ const italicButton = await page . locator (
535
+ "button[data-role='pw-rte-italic-button']" ,
536
+ ) ;
537
+
538
+ await italicButton . click ( ) ;
539
+ await textbox . click ( ) ;
540
+ await textbox . pressSequentially ( "This is some italic text" ) ;
541
+
542
+ expect ( await page . locator ( "em" ) . count ( ) ) . toBe ( 1 ) ;
543
+ await page . locator ( "text=This is some italic text" ) . evaluate ( ( el ) => {
544
+ const style = window . getComputedStyle ( el ) ;
545
+ return style . fontStyle === "italic" ;
546
+ } ) ;
547
+
548
+ await italicButton . click ( ) ;
549
+ await textbox . click ( ) ;
550
+ await textbox . pressSequentially ( " and this is not" ) ;
551
+
552
+ expect ( await page . locator ( "span[data-lexical-text='true']" ) . count ( ) ) . toBe (
553
+ 2 ,
554
+ ) ;
555
+ await page . locator ( "text=and this is not" ) . evaluate ( ( el ) => {
556
+ const style = window . getComputedStyle ( el ) ;
557
+ return style . fontStyle === "italic" ;
558
+ } ) ;
559
+ } ) ;
476
560
} ) ;
477
561
478
562
test . describe ( "Ordered List" , ( ) => {
0 commit comments