1+ import { ConstantHelper , NotificationConstantHelper , test } from '@umbraco/playwright-testhelpers' ;
2+ import { expect } from "@playwright/test" ;
3+
4+ const contentName = 'TestContent' ;
5+ const documentTypeName = 'TestDocumentTypeForContent' ;
6+ const customDataTypeName = 'Test RTE Tiptap Style Select' ;
7+ const inputText = 'This is Tiptap test' ;
8+
9+ test . beforeEach ( async ( { umbracoApi, umbracoUi} ) => {
10+ const customDataTypeId = await umbracoApi . dataType . createTiptapDataTypeWithStyleSelect ( customDataTypeName ) ;
11+ const documentTypeId = await umbracoApi . documentType . createDocumentTypeWithPropertyEditor ( documentTypeName , customDataTypeName , customDataTypeId ) ;
12+ await umbracoApi . document . createDefaultDocument ( contentName , documentTypeId ) ;
13+ await umbracoUi . goToBackOffice ( ) ;
14+ await umbracoUi . content . goToSection ( ConstantHelper . sections . content ) ;
15+ await umbracoUi . content . goToContentWithName ( contentName ) ;
16+ await umbracoUi . content . enterRTETipTapEditor ( inputText ) ;
17+ await umbracoUi . content . selectAllRTETipTapEditorText ( ) ;
18+ } )
19+
20+ test . afterEach ( async ( { umbracoApi} ) => {
21+ await umbracoApi . document . ensureNameNotExists ( contentName ) ;
22+ await umbracoApi . documentType . ensureNameNotExists ( documentTypeName ) ;
23+ await umbracoApi . dataType . ensureNameNotExists ( customDataTypeName ) ;
24+ } ) ;
25+
26+ test ( 'can apply page header format' , async ( { umbracoApi, umbracoUi} ) => {
27+ // Arrange
28+ await umbracoUi . content . clickStyleSelectButton ( ) ;
29+
30+ // Act
31+ await umbracoUi . content . hoverCascadingMenuItemWithName ( 'Headers' ) ;
32+ await umbracoUi . content . clickCascadingMenuItemWithName ( 'Page header' ) ;
33+ await umbracoUi . content . clickSaveButton ( ) ;
34+
35+ // Assert
36+ await umbracoUi . content . doesSuccessNotificationHaveText ( NotificationConstantHelper . success . saved ) ;
37+ const contentData = await umbracoApi . document . getByName ( contentName ) ;
38+ expect ( contentData . values [ 0 ] . value . markup ) . toEqual ( '<h2>' + inputText + '</h2><p></p>' ) ;
39+ } ) ;
40+
41+ test ( 'can apply section header format' , async ( { umbracoApi, umbracoUi} ) => {
42+ // Arrange
43+ await umbracoUi . content . clickStyleSelectButton ( ) ;
44+
45+ // Act
46+ await umbracoUi . content . hoverCascadingMenuItemWithName ( 'Headers' ) ;
47+ await umbracoUi . content . clickCascadingMenuItemWithName ( 'Section header' ) ;
48+ await umbracoUi . content . clickSaveButton ( ) ;
49+
50+ // Assert
51+ await umbracoUi . content . doesSuccessNotificationHaveText ( NotificationConstantHelper . success . saved ) ;
52+ const contentData = await umbracoApi . document . getByName ( contentName ) ;
53+ expect ( contentData . values [ 0 ] . value . markup ) . toEqual ( '<h3>' + inputText + '</h3><p></p>' ) ;
54+ } ) ;
55+
56+ test ( 'can apply paragraph header format' , async ( { umbracoApi, umbracoUi} ) => {
57+ // Arrange
58+ await umbracoUi . content . clickStyleSelectButton ( ) ;
59+
60+ // Act
61+ await umbracoUi . content . hoverCascadingMenuItemWithName ( 'Headers' ) ;
62+ await umbracoUi . content . clickCascadingMenuItemWithName ( 'Paragraph header' ) ;
63+ await umbracoUi . content . clickSaveButton ( ) ;
64+
65+ // Assert
66+ await umbracoUi . content . doesSuccessNotificationHaveText ( NotificationConstantHelper . success . saved ) ;
67+ const contentData = await umbracoApi . document . getByName ( contentName ) ;
68+ expect ( contentData . values [ 0 ] . value . markup ) . toEqual ( '<h4>' + inputText + '</h4><p></p>' ) ;
69+ } ) ;
70+
71+ test ( 'can apply paragraph blocks format' , async ( { umbracoApi, umbracoUi} ) => {
72+ // Arrange
73+ await umbracoUi . content . clickStyleSelectButton ( ) ;
74+
75+ // Act
76+ await umbracoUi . content . hoverCascadingMenuItemWithName ( 'Blocks' ) ;
77+ await umbracoUi . content . clickCascadingMenuItemWithName ( 'Paragraph' ) ;
78+ await umbracoUi . content . clickSaveButton ( ) ;
79+
80+ // Assert
81+ await umbracoUi . content . doesSuccessNotificationHaveText ( NotificationConstantHelper . success . saved ) ;
82+ const contentData = await umbracoApi . document . getByName ( contentName ) ;
83+ expect ( contentData . values [ 0 ] . value . markup ) . toEqual ( '<p>' + inputText + '</p>' ) ;
84+ } ) ;
85+
86+ test ( 'can apply block quote format' , async ( { umbracoApi, umbracoUi} ) => {
87+ // Arrange
88+ await umbracoUi . content . clickStyleSelectButton ( ) ;
89+
90+ // Act
91+ await umbracoUi . content . hoverCascadingMenuItemWithName ( 'Containers' ) ;
92+ await umbracoUi . content . clickCascadingMenuItemWithName ( 'Block quote' ) ;
93+ await umbracoUi . content . clickSaveButton ( ) ;
94+
95+ // Assert
96+ await umbracoUi . content . doesSuccessNotificationHaveText ( NotificationConstantHelper . success . saved ) ;
97+ const contentData = await umbracoApi . document . getByName ( contentName ) ;
98+ expect ( contentData . values [ 0 ] . value . markup ) . toEqual ( '<blockquote><p>' + inputText + '</p></blockquote><p></p>' ) ;
99+ } ) ;
100+
101+ test ( 'can apply code block format' , async ( { umbracoApi, umbracoUi} ) => {
102+ // Arrange
103+ await umbracoUi . content . clickStyleSelectButton ( ) ;
104+
105+ // Act
106+ await umbracoUi . content . hoverCascadingMenuItemWithName ( 'Containers' ) ;
107+ await umbracoUi . content . clickCascadingMenuItemWithName ( 'Code block' ) ;
108+ await umbracoUi . content . clickSaveButton ( ) ;
109+
110+ // Assert
111+ await umbracoUi . content . doesSuccessNotificationHaveText ( NotificationConstantHelper . success . saved ) ;
112+ const contentData = await umbracoApi . document . getByName ( contentName ) ;
113+ expect ( contentData . values [ 0 ] . value . markup ) . toEqual ( '<pre><code>' + inputText + '</code></pre><p></p>' ) ;
114+ } ) ;
0 commit comments