Skip to content

Commit e7da631

Browse files
authored
V16 Added acceptance tests for issue #17753 (#19876)
* Added tests for updating a variant block list with invalid text * Added tests for updating a variant block grid with invalid text * Bumped version of test helper * Make the tests for updating content with invalid text in a block run in the pipeline * Cleaned up * Updated test text * Reverted npm command
1 parent d23c2ac commit e7da631

File tree

4 files changed

+109
-12
lines changed

4 files changed

+109
-12
lines changed

tests/Umbraco.Tests.AcceptanceTest/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/Umbraco.Tests.AcceptanceTest/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
},
2323
"dependencies": {
2424
"@umbraco/json-models-builders": "^2.0.37",
25-
"@umbraco/playwright-testhelpers": "^16.0.33",
25+
"@umbraco/playwright-testhelpers": "^16.0.34",
2626
"camelize": "^1.0.0",
2727
"dotenv": "^16.3.1",
2828
"node-fetch": "^2.6.7"

tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/BlockGrid/BlockGridWithPropertyEditor.spec.ts

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
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
45
const 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+
});

tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/BlockList/BlockListWithPropertyEditor.spec.ts

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ test.afterEach(async ({umbracoApi}) => {
3131
await umbracoApi.dataType.ensureNameNotExists(blockListName);
3232
});
3333

34-
test('can not publish a block list with a mandatory radiobox without a value', async ({umbracoApi, umbracoUi}) => {
34+
test('cannot publish a block list with a mandatory radiobox without a value', async ({umbracoApi, umbracoUi}) => {
3535
// Arrange
3636
propertyEditorId = await umbracoApi.dataType.createRadioboxDataType(propertyEditorName, optionValues);
3737
elementTypeId = await umbracoApi.documentType.createDefaultElementType(blockName, elementGroupName, propertyEditorName, propertyEditorId, true);
@@ -60,7 +60,7 @@ test('can not publish a block list with a mandatory radiobox without a value', a
6060
expect(await umbracoApi.document.isDocumentPublished(contentId)).toBeTruthy();
6161
});
6262

63-
test('can not publish a block list with a mandatory checkbox list without a value', async ({umbracoApi, umbracoUi}) => {
63+
test('cannot publish a block list with a mandatory checkbox list without a value', async ({umbracoApi, umbracoUi}) => {
6464
// Arrange
6565
propertyEditorId = await umbracoApi.dataType.createCheckboxListDataType(propertyEditorName, optionValues);
6666
elementTypeId = await umbracoApi.documentType.createDefaultElementType(blockName, elementGroupName, propertyEditorName, propertyEditorId, true);
@@ -89,7 +89,7 @@ test('can not publish a block list with a mandatory checkbox list without a valu
8989
expect(await umbracoApi.document.isDocumentPublished(contentId)).toBeTruthy();
9090
});
9191

92-
test('can not publish a block list with a mandatory dropdown without a value', async ({umbracoApi, umbracoUi}) => {
92+
test('cannot publish a block list with a mandatory dropdown without a value', async ({umbracoApi, umbracoUi}) => {
9393
// Arrange
9494
propertyEditorId = await umbracoApi.dataType.createDropdownDataType(propertyEditorName, false, optionValues);
9595
elementTypeId = await umbracoApi.documentType.createDefaultElementType(blockName, elementGroupName, propertyEditorName, propertyEditorId, true);
@@ -117,3 +117,51 @@ test('can not publish a block list with a mandatory dropdown without a value', a
117117
await umbracoUi.content.isSuccessStateVisibleForSaveAndPublishButton();
118118
expect(await umbracoApi.document.isDocumentPublished(contentId)).toBeTruthy();
119119
});
120+
121+
test('cannot update a variant block list with invalid text', {tag: '@release'}, async ({umbracoApi, umbracoUi}) => {
122+
// Arrange
123+
const textStringElementDataTypeName = 'Textstring';
124+
const textStringElementRegex = '[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+';
125+
const wrongPropertyValue = 'This is an invalid email';
126+
const correctPropertyValue = '[email protected]';
127+
// Create a new language
128+
await umbracoApi.language.createDanishLanguage();
129+
// ElementType with textstring and regex only accept an email address
130+
const textStringElementDataType = await umbracoApi.dataType.getByName(textStringElementDataTypeName);
131+
elementTypeId = await umbracoApi.documentType.createElementTypeWithRegexValidation(blockName, elementGroupName, textStringElementDataTypeName, textStringElementDataType.id, textStringElementRegex);
132+
// Block List Editor with textstring
133+
blockListId = await umbracoApi.dataType.createBlockListDataTypeWithABlock(blockListName, elementTypeId);
134+
// Document Type with Block List Editor
135+
documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, blockListName, blockListId, documentTypeGroupName, true, true);
136+
// Creates content
137+
contentId = await umbracoApi.document.createDefaultDocumentWithEnglishCulture(contentName, documentTypeId);
138+
await umbracoUi.goToBackOffice();
139+
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
140+
141+
// Act
142+
await umbracoUi.content.goToContentWithName(contentName);
143+
await umbracoUi.content.clickAddBlockElementButton();
144+
await umbracoUi.content.clickBlockElementWithName(blockName);
145+
// Enter text in the textstring block that won't match regex
146+
await umbracoUi.content.enterPropertyValue(textStringElementDataTypeName, wrongPropertyValue);
147+
await umbracoUi.content.clickCreateModalButton();
148+
await umbracoUi.content.clickSaveButtonForContent();
149+
await umbracoUi.content.clickSaveButton();
150+
// Verify that the block list entry has an invalid badge
151+
await umbracoUi.content.doesPropertyHaveInvalidBadge(blockListName);
152+
await umbracoUi.content.clickEditBlockListEntryWithName(blockName);
153+
await umbracoUi.content.doesModalFormValidationMessageContainText(ConstantHelper.validationMessages.invalidValue);
154+
// Update the textstring block with a valid email address
155+
await umbracoUi.content.enterPropertyValue(textStringElementDataTypeName, correctPropertyValue);
156+
await umbracoUi.content.clickUpdateButton();
157+
await umbracoUi.content.clickSaveButtonForContent();
158+
await umbracoUi.content.clickSaveButton();
159+
160+
// Assert
161+
const contentData = await umbracoApi.document.getByName(contentName);
162+
expect(contentData.values[0].value.contentData[0].values[0].value).toContain(correctPropertyValue);
163+
const blockListValue = contentData.values.find(item => item.editorAlias === "Umbraco.BlockList")?.value;
164+
expect(blockListValue).toBeTruthy();
165+
await umbracoUi.content.clickEditBlockListEntryWithName(blockName);
166+
await umbracoUi.content.doesPropertyContainValue(textStringElementDataTypeName, correctPropertyValue);
167+
});

0 commit comments

Comments
 (0)