1- import { ConstantHelper , NotificationConstantHelper , test } from '@umbraco/playwright-testhelpers' ;
1+ import { expect } from '@playwright/test' ;
2+ import { ConstantHelper , test } from '@umbraco/playwright-testhelpers' ;
23
34// Content Name
45const contentName = 'ContentName' ;
@@ -29,7 +30,7 @@ test.afterEach(async ({umbracoApi}) => {
2930 await umbracoApi . dataType . ensureNameNotExists ( blockGridName ) ;
3031} ) ;
3132
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} ) => {
3334 // Arrange
3435 propertyEditorId = await umbracoApi . dataType . createRadioboxDataType ( propertyEditorName , optionValues ) ;
3536 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
5758 await umbracoUi . content . isSuccessStateVisibleForSaveAndPublishButton ( ) ;
5859} ) ;
5960
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} ) => {
6162 // Arrange
6263 propertyEditorId = await umbracoApi . dataType . createCheckboxListDataType ( propertyEditorName , optionValues ) ;
6364 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
8586 await umbracoUi . content . isSuccessStateVisibleForSaveAndPublishButton ( ) ;
8687} ) ;
8788
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} ) => {
8990 // Arrange
9091 propertyEditorId = await umbracoApi . dataType . createDropdownDataType ( propertyEditorName , false , optionValues ) ;
9192 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
112113 // Assert
113114 await umbracoUi . content . isSuccessStateVisibleForSaveAndPublishButton ( ) ;
114115} ) ;
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