1
- import { ConstantHelper , NotificationConstantHelper , test } from '@umbraco/playwright-testhelpers' ;
1
+ import { expect } from '@playwright/test' ;
2
+ import { ConstantHelper , test } from '@umbraco/playwright-testhelpers' ;
2
3
3
4
// Content Name
4
5
const contentName = 'ContentName' ;
@@ -29,7 +30,7 @@ test.afterEach(async ({umbracoApi}) => {
29
30
await umbracoApi . dataType . ensureNameNotExists ( blockGridName ) ;
30
31
} ) ;
31
32
32
- test ( 'can not publish a block grid with a mandatory radiobox without a value' , async ( { umbracoApi, umbracoUi} ) => {
33
+ test ( 'cannot publish a block grid with a mandatory radiobox without a value' , async ( { umbracoApi, umbracoUi} ) => {
33
34
// Arrange
34
35
propertyEditorId = await umbracoApi . dataType . createRadioboxDataType ( propertyEditorName , optionValues ) ;
35
36
elementTypeId = await umbracoApi . documentType . createDefaultElementType ( blockName , elementGroupName , propertyEditorName , propertyEditorId , true ) ;
@@ -57,7 +58,7 @@ test('can not publish a block grid with a mandatory radiobox without a value', a
57
58
await umbracoUi . content . isSuccessStateVisibleForSaveAndPublishButton ( ) ;
58
59
} ) ;
59
60
60
- test ( 'can not publish a block grid with a mandatory checkbox list without a value' , async ( { umbracoApi, umbracoUi} ) => {
61
+ test ( 'cannot publish a block grid with a mandatory checkbox list without a value' , async ( { umbracoApi, umbracoUi} ) => {
61
62
// Arrange
62
63
propertyEditorId = await umbracoApi . dataType . createCheckboxListDataType ( propertyEditorName , optionValues ) ;
63
64
elementTypeId = await umbracoApi . documentType . createDefaultElementType ( blockName , elementGroupName , propertyEditorName , propertyEditorId , true ) ;
@@ -85,7 +86,7 @@ test('can not publish a block grid with a mandatory checkbox list without a valu
85
86
await umbracoUi . content . isSuccessStateVisibleForSaveAndPublishButton ( ) ;
86
87
} ) ;
87
88
88
- test ( 'can not publish a block grid with a mandatory dropdown without a value' , async ( { umbracoApi, umbracoUi} ) => {
89
+ test ( 'cannot publish a block grid with a mandatory dropdown without a value' , async ( { umbracoApi, umbracoUi} ) => {
89
90
// Arrange
90
91
propertyEditorId = await umbracoApi . dataType . createDropdownDataType ( propertyEditorName , false , optionValues ) ;
91
92
elementTypeId = await umbracoApi . documentType . createDefaultElementType ( blockName , elementGroupName , propertyEditorName , propertyEditorId , true ) ;
@@ -112,3 +113,51 @@ test('can not publish a block grid with a mandatory dropdown without a value', a
112
113
// Assert
113
114
await umbracoUi . content . isSuccessStateVisibleForSaveAndPublishButton ( ) ;
114
115
} ) ;
116
+
117
+ test ( 'cannot update a variant block grid with invalid text' , { tag : '@release' } , async ( { umbracoApi, umbracoUi} ) => {
118
+ // Arrange
119
+ const textStringElementDataTypeName = 'Textstring' ;
120
+ const textStringElementRegex = '[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+' ;
121
+ const wrongPropertyValue = 'This is an invalid email' ;
122
+ const correctPropertyValue = '[email protected] ' ;
123
+ // Create a new language
124
+ await umbracoApi . language . createDanishLanguage ( ) ;
125
+ // ElementType with textstring and regex only accept an email address
126
+ const textStringElementDataType = await umbracoApi . dataType . getByName ( textStringElementDataTypeName ) ;
127
+ elementTypeId = await umbracoApi . documentType . createElementTypeWithRegexValidation ( blockName , elementGroupName , textStringElementDataTypeName , textStringElementDataType . id , textStringElementRegex ) ;
128
+ // Block Grid Editor with textstring
129
+ blockGridId = await umbracoApi . dataType . createBlockGridWithABlock ( blockGridName , elementTypeId ) ;
130
+ // Document Type with Block Grid Editor
131
+ documentTypeId = await umbracoApi . documentType . createDocumentTypeWithPropertyEditor ( documentTypeName , blockGridName , blockGridId , documentTypeGroupName , true , true ) ;
132
+ // Creates content
133
+ await umbracoApi . document . createDefaultDocumentWithEnglishCulture ( contentName , documentTypeId ) ;
134
+ await umbracoUi . goToBackOffice ( ) ;
135
+ await umbracoUi . content . goToSection ( ConstantHelper . sections . content ) ;
136
+
137
+ // Act
138
+ await umbracoUi . content . goToContentWithName ( contentName ) ;
139
+ await umbracoUi . content . clickAddBlockElementButton ( ) ;
140
+ await umbracoUi . content . clickBlockElementWithName ( blockName ) ;
141
+ // Enter text in the textstring block that won't match regex
142
+ await umbracoUi . content . enterPropertyValue ( textStringElementDataTypeName , wrongPropertyValue ) ;
143
+ await umbracoUi . content . clickCreateModalButton ( ) ;
144
+ await umbracoUi . content . clickSaveButtonForContent ( ) ;
145
+ await umbracoUi . content . clickSaveButton ( ) ;
146
+ // Verify that the Block Grid entry has an invalid badge
147
+ await umbracoUi . content . doesPropertyHaveInvalidBadge ( blockGridName ) ;
148
+ await umbracoUi . content . clickBlockElementWithName ( blockName ) ;
149
+ await umbracoUi . content . doesModalFormValidationMessageContainText ( ConstantHelper . validationMessages . invalidValue ) ;
150
+ // Update the textstring block with a valid email address
151
+ await umbracoUi . content . enterPropertyValue ( textStringElementDataTypeName , correctPropertyValue ) ;
152
+ await umbracoUi . content . clickUpdateButton ( ) ;
153
+ await umbracoUi . content . clickSaveButtonForContent ( ) ;
154
+ await umbracoUi . content . clickSaveButton ( ) ;
155
+
156
+ // Assert
157
+ const contentData = await umbracoApi . document . getByName ( contentName ) ;
158
+ expect ( contentData . values [ 0 ] . value . contentData [ 0 ] . values [ 0 ] . value ) . toContain ( correctPropertyValue ) ;
159
+ const blockListValue = contentData . values . find ( item => item . editorAlias === "Umbraco.BlockGrid" ) ?. value ;
160
+ expect ( blockListValue ) . toBeTruthy ( ) ;
161
+ await umbracoUi . content . clickBlockElementWithName ( blockName ) ;
162
+ await umbracoUi . content . doesPropertyContainValue ( textStringElementDataTypeName , correctPropertyValue ) ;
163
+ } ) ;
0 commit comments