@@ -8,14 +8,26 @@ test('renders the configured plugin toolbar', async ({ page }) => {
88 ) . toBeVisible ( ) ;
99
1010 const toolbar = page . getByRole ( 'toolbar' , { name : 'Editor toolbar' } ) ;
11+ const paragraph = toolbar . getByRole ( 'button' , { name : 'P' } ) ;
12+ const heading1 = toolbar . getByRole ( 'button' , { name : 'H1' } ) ;
13+ const heading2 = toolbar . getByRole ( 'button' , { name : 'H2' } ) ;
14+ const heading3 = toolbar . getByRole ( 'button' , { name : 'H3' } ) ;
1115 const underline = toolbar . getByRole ( 'button' , { name : 'U' } ) ;
16+ const bulletList = toolbar . getByRole ( 'button' , { name : 'Bullet list' } ) ;
17+ const orderedList = toolbar . getByRole ( 'button' , { name : 'Ordered list' } ) ;
18+ const liftListItem = toolbar . getByRole ( 'button' , { name : 'Lift list item' } ) ;
19+ const sinkListItem = toolbar . getByRole ( 'button' , { name : 'Sink list item' } ) ;
1220 const link = toolbar . getByRole ( 'button' , { name : 'Link' } ) ;
1321 const unlink = toolbar . getByRole ( 'button' , { name : 'Unlink' } ) ;
1422 const undo = toolbar . getByRole ( 'button' , { name : 'Undo' } ) ;
1523 const redo = toolbar . getByRole ( 'button' , { name : 'Redo' } ) ;
1624
1725 await expect ( page . locator ( 'rte-editor > button' ) ) . toHaveCount ( 0 ) ;
18- await expect ( toolbar . getByRole ( 'button' ) ) . toHaveCount ( 8 ) ;
26+ await expect ( toolbar . getByRole ( 'button' ) ) . toHaveCount ( 16 ) ;
27+ await expect ( paragraph ) . toHaveAttribute ( 'title' , 'Paragraph' ) ;
28+ await expect ( heading1 ) . toHaveAttribute ( 'title' , 'Heading 1' ) ;
29+ await expect ( heading2 ) . toHaveAttribute ( 'title' , 'Heading 2' ) ;
30+ await expect ( heading3 ) . toHaveAttribute ( 'title' , 'Heading 3' ) ;
1931 await expect ( toolbar . getByRole ( 'button' , { name : 'B' } ) ) . toHaveAttribute (
2032 'title' ,
2133 'Bold' ,
@@ -30,21 +42,77 @@ test('renders the configured plugin toolbar', async ({ page }) => {
3042 'title' ,
3143 'Strikethrough' ,
3244 ) ;
45+ await expect ( bulletList ) . toHaveAttribute ( 'title' , 'Bullet list' ) ;
46+ await expect ( bulletList ) . toBeDisabled ( ) ;
47+ await expect ( orderedList ) . toHaveAttribute ( 'title' , 'Ordered list' ) ;
48+ await expect ( orderedList ) . toBeDisabled ( ) ;
49+ await expect ( liftListItem ) . toHaveAttribute ( 'title' , 'Lift list item' ) ;
50+ await expect ( liftListItem ) . toBeDisabled ( ) ;
51+ await expect ( sinkListItem ) . toHaveAttribute ( 'title' , 'Sink list item' ) ;
52+ await expect ( sinkListItem ) . toBeDisabled ( ) ;
3353 await expect ( link ) . toHaveAttribute ( 'title' , 'Link' ) ;
3454 await expect ( link ) . toBeEnabled ( ) ;
3555 await expect ( unlink ) . toHaveAttribute ( 'title' , 'Unlink' ) ;
3656 await expect ( unlink ) . toBeDisabled ( ) ;
3757 await expect ( undo ) . toBeDisabled ( ) ;
3858 await expect ( redo ) . toBeDisabled ( ) ;
3959
40- await expect ( toolbar . getByRole ( 'button' , { name : 'H1' } ) ) . toHaveCount ( 0 ) ;
41- await expect ( toolbar . getByRole ( 'button' , { name : 'UL' } ) ) . toHaveCount ( 0 ) ;
4260 await expect ( page . locator ( '.ProseMirror' ) ) . toContainText ( 'Angular RTE' ) ;
61+ await expect ( page . locator ( 'pre' ) ) . toContainText (
62+ '<h1><strong>Angular RTE</strong></h1>' ,
63+ ) ;
64+ await expect ( page . locator ( 'pre' ) ) . toContainText (
65+ '<ul><li><p>Compose plugins in TypeScript.</p></li><li><p>Keep toolbar markup in the consuming app.</p></li></ul>' ,
66+ ) ;
67+ await expect ( page . locator ( 'pre' ) ) . toContainText (
68+ '<ol><li><p>Pick capabilities for the current product surface.</p></li><li><p>Render controls with Angular templates and rteCommand.</p></li></ol>' ,
69+ ) ;
4370 await expect ( page . locator ( 'pre' ) ) . toContainText ( '<u>underline</u>' ) ;
4471 await expect ( page . locator ( 'pre' ) ) . toContainText (
4572 '<a href="https://angular.dev" target="_blank" rel="noopener noreferrer">links</a>' ,
4673 ) ;
4774
75+ await page
76+ . locator ( '.ProseMirror' )
77+ . getByText ( 'Build headless editing primitives' )
78+ . selectText ( ) ;
79+ await heading2 . click ( ) ;
80+ await expect ( heading2 ) . toHaveAttribute ( 'aria-pressed' , 'true' ) ;
81+ await expect ( page . locator ( 'pre' ) ) . toContainText (
82+ '<h2>Build headless editing primitives with a plugin stack that remains fully selected by the consumer.</h2>' ,
83+ ) ;
84+ await paragraph . click ( ) ;
85+ await expect ( page . locator ( 'pre' ) ) . toContainText (
86+ '<p>Build headless editing primitives with a plugin stack that remains fully selected by the consumer.</p>' ,
87+ ) ;
88+ await expect ( bulletList ) . toBeEnabled ( ) ;
89+ await expect ( orderedList ) . toBeEnabled ( ) ;
90+
91+ await bulletList . click ( ) ;
92+ await expect ( bulletList ) . toHaveAttribute ( 'aria-pressed' , 'true' ) ;
93+ await expect ( page . locator ( 'pre' ) ) . toContainText (
94+ '<ul><li><p>Build headless editing primitives with a plugin stack that remains fully selected by the consumer.</p></li></ul>' ,
95+ ) ;
96+ await page . locator ( '.ProseMirror' ) . press ( 'Tab' ) ;
97+ await expect ( page . locator ( '.ProseMirror' ) ) . toBeFocused ( ) ;
98+ await page . locator ( '.ProseMirror' ) . press ( 'Escape' ) ;
99+ await expect ( page . locator ( '.ProseMirror' ) ) . not . toBeFocused ( ) ;
100+ await page
101+ . locator ( '.ProseMirror' )
102+ . getByText ( 'Build headless editing primitives' )
103+ . selectText ( ) ;
104+
105+ await orderedList . click ( ) ;
106+ await expect ( orderedList ) . toHaveAttribute ( 'aria-pressed' , 'true' ) ;
107+ await expect ( page . locator ( 'pre' ) ) . toContainText (
108+ '<ol><li><p>Build headless editing primitives with a plugin stack that remains fully selected by the consumer.</p></li></ol>' ,
109+ ) ;
110+
111+ await orderedList . click ( ) ;
112+ await expect ( page . locator ( 'pre' ) ) . toContainText (
113+ '<p>Build headless editing primitives with a plugin stack that remains fully selected by the consumer.</p>' ,
114+ ) ;
115+
48116 await underline . click ( ) ;
49117 await expect ( underline ) . toHaveAttribute ( 'aria-pressed' , 'true' ) ;
50118
@@ -65,7 +133,7 @@ test('renders the configured plugin toolbar', async ({ page }) => {
65133 . getByRole ( 'button' , { name : 'Save' } )
66134 . click ( ) ;
67135 await expect ( page . locator ( 'pre' ) ) . toContainText (
68- '<strong><a href="/docs" target="_blank" rel="noopener noreferrer">Angular RTE</a></strong>' ,
136+ '<h1>< strong><a href="/docs" target="_blank" rel="noopener noreferrer">Angular RTE</a></strong></h1 >' ,
69137 ) ;
70138 await expect ( unlink ) . toBeEnabled ( ) ;
71139
@@ -83,7 +151,7 @@ test('renders the configured plugin toolbar', async ({ page }) => {
83151 . getByRole ( 'button' , { name : 'Save' } )
84152 . click ( ) ;
85153 await expect ( page . locator ( 'pre' ) ) . toContainText (
86- '<strong><a href="/guide" target="_blank" rel="noopener noreferrer">Angular RTE</a></strong>' ,
154+ '<h1>< strong><a href="/guide" target="_blank" rel="noopener noreferrer">Angular RTE</a></strong></h1 >' ,
87155 ) ;
88156
89157 const popupPromise = page . waitForEvent ( 'popup' ) ;
@@ -98,7 +166,7 @@ test('renders the configured plugin toolbar', async ({ page }) => {
98166 . getByRole ( 'button' , { name : 'Unlink' } )
99167 . click ( ) ;
100168 await expect ( page . locator ( 'pre' ) ) . toContainText (
101- '<strong>Angular RTE</strong>' ,
169+ '<h1>< strong>Angular RTE</strong></h1 >' ,
102170 ) ;
103171
104172 await page . locator ( '.ProseMirror' ) . pressSequentially ( 'X' ) ;
0 commit comments