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
This commit is contained in:
Nhu Dinh
2025-08-08 09:47:28 +07:00
committed by GitHub
parent d23c2acd63
commit e7da631ec2
4 changed files with 109 additions and 12 deletions

View File

@@ -8,7 +8,7 @@
"hasInstallScript": true,
"dependencies": {
"@umbraco/json-models-builders": "^2.0.37",
"@umbraco/playwright-testhelpers": "^16.0.33",
"@umbraco/playwright-testhelpers": "^16.0.34",
"camelize": "^1.0.0",
"dotenv": "^16.3.1",
"node-fetch": "^2.6.7"
@@ -67,9 +67,9 @@
}
},
"node_modules/@umbraco/playwright-testhelpers": {
"version": "16.0.33",
"resolved": "https://registry.npmjs.org/@umbraco/playwright-testhelpers/-/playwright-testhelpers-16.0.33.tgz",
"integrity": "sha512-sqUWuGmKwfhvQ+mmDCQwIWRu07tGVILuQaVs4dF1R7Z3KGPsQY0PKIulzDSgOyTHZLUnlxQudtr4i0alm3XHgQ==",
"version": "16.0.34",
"resolved": "https://registry.npmjs.org/@umbraco/playwright-testhelpers/-/playwright-testhelpers-16.0.34.tgz",
"integrity": "sha512-hCOqSUrTVZPNxD3DP+olYz/QFc8HwyZ1QZR6gTv87nIkAlvEjk44+7KblPartfBXQDd93uvasptr7dO3XCapZA==",
"dependencies": {
"@umbraco/json-models-builders": "2.0.37",
"node-fetch": "^2.6.7"

View File

@@ -22,7 +22,7 @@
},
"dependencies": {
"@umbraco/json-models-builders": "^2.0.37",
"@umbraco/playwright-testhelpers": "^16.0.33",
"@umbraco/playwright-testhelpers": "^16.0.34",
"camelize": "^1.0.0",
"dotenv": "^16.3.1",
"node-fetch": "^2.6.7"

View File

@@ -1,4 +1,5 @@
import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers';
import {expect} from '@playwright/test';
import {ConstantHelper, test} from '@umbraco/playwright-testhelpers';
// Content Name
const contentName = 'ContentName';
@@ -29,7 +30,7 @@ test.afterEach(async ({umbracoApi}) => {
await umbracoApi.dataType.ensureNameNotExists(blockGridName);
});
test('can not publish a block grid with a mandatory radiobox without a value', async ({umbracoApi, umbracoUi}) => {
test('cannot publish a block grid with a mandatory radiobox without a value', async ({umbracoApi, umbracoUi}) => {
// Arrange
propertyEditorId = await umbracoApi.dataType.createRadioboxDataType(propertyEditorName, optionValues);
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
await umbracoUi.content.isSuccessStateVisibleForSaveAndPublishButton();
});
test('can not publish a block grid with a mandatory checkbox list without a value', async ({umbracoApi, umbracoUi}) => {
test('cannot publish a block grid with a mandatory checkbox list without a value', async ({umbracoApi, umbracoUi}) => {
// Arrange
propertyEditorId = await umbracoApi.dataType.createCheckboxListDataType(propertyEditorName, optionValues);
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
await umbracoUi.content.isSuccessStateVisibleForSaveAndPublishButton();
});
test('can not publish a block grid with a mandatory dropdown without a value', async ({umbracoApi, umbracoUi}) => {
test('cannot publish a block grid with a mandatory dropdown without a value', async ({umbracoApi, umbracoUi}) => {
// Arrange
propertyEditorId = await umbracoApi.dataType.createDropdownDataType(propertyEditorName, false, optionValues);
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
// Assert
await umbracoUi.content.isSuccessStateVisibleForSaveAndPublishButton();
});
test('cannot update a variant block grid with invalid text', {tag: '@release'}, async ({umbracoApi, umbracoUi}) => {
// Arrange
const textStringElementDataTypeName = 'Textstring';
const textStringElementRegex = '[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+';
const wrongPropertyValue = 'This is an invalid email';
const correctPropertyValue = 'validemail@test.com';
// Create a new language
await umbracoApi.language.createDanishLanguage();
// ElementType with textstring and regex only accept an email address
const textStringElementDataType = await umbracoApi.dataType.getByName(textStringElementDataTypeName);
elementTypeId = await umbracoApi.documentType.createElementTypeWithRegexValidation(blockName, elementGroupName, textStringElementDataTypeName, textStringElementDataType.id, textStringElementRegex);
// Block Grid Editor with textstring
blockGridId = await umbracoApi.dataType.createBlockGridWithABlock(blockGridName, elementTypeId);
// Document Type with Block Grid Editor
documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, blockGridName, blockGridId, documentTypeGroupName, true, true);
// Creates content
await umbracoApi.document.createDefaultDocumentWithEnglishCulture(contentName, documentTypeId);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
// Act
await umbracoUi.content.goToContentWithName(contentName);
await umbracoUi.content.clickAddBlockElementButton();
await umbracoUi.content.clickBlockElementWithName(blockName);
// Enter text in the textstring block that won't match regex
await umbracoUi.content.enterPropertyValue(textStringElementDataTypeName, wrongPropertyValue);
await umbracoUi.content.clickCreateModalButton();
await umbracoUi.content.clickSaveButtonForContent();
await umbracoUi.content.clickSaveButton();
// Verify that the Block Grid entry has an invalid badge
await umbracoUi.content.doesPropertyHaveInvalidBadge(blockGridName);
await umbracoUi.content.clickBlockElementWithName(blockName);
await umbracoUi.content.doesModalFormValidationMessageContainText(ConstantHelper.validationMessages.invalidValue);
// Update the textstring block with a valid email address
await umbracoUi.content.enterPropertyValue(textStringElementDataTypeName, correctPropertyValue);
await umbracoUi.content.clickUpdateButton();
await umbracoUi.content.clickSaveButtonForContent();
await umbracoUi.content.clickSaveButton();
// Assert
const contentData = await umbracoApi.document.getByName(contentName);
expect(contentData.values[0].value.contentData[0].values[0].value).toContain(correctPropertyValue);
const blockListValue = contentData.values.find(item => item.editorAlias === "Umbraco.BlockGrid")?.value;
expect(blockListValue).toBeTruthy();
await umbracoUi.content.clickBlockElementWithName(blockName);
await umbracoUi.content.doesPropertyContainValue(textStringElementDataTypeName, correctPropertyValue);
});

View File

@@ -31,7 +31,7 @@ test.afterEach(async ({umbracoApi}) => {
await umbracoApi.dataType.ensureNameNotExists(blockListName);
});
test('can not publish a block list with a mandatory radiobox without a value', async ({umbracoApi, umbracoUi}) => {
test('cannot publish a block list with a mandatory radiobox without a value', async ({umbracoApi, umbracoUi}) => {
// Arrange
propertyEditorId = await umbracoApi.dataType.createRadioboxDataType(propertyEditorName, optionValues);
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
expect(await umbracoApi.document.isDocumentPublished(contentId)).toBeTruthy();
});
test('can not publish a block list with a mandatory checkbox list without a value', async ({umbracoApi, umbracoUi}) => {
test('cannot publish a block list with a mandatory checkbox list without a value', async ({umbracoApi, umbracoUi}) => {
// Arrange
propertyEditorId = await umbracoApi.dataType.createCheckboxListDataType(propertyEditorName, optionValues);
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
expect(await umbracoApi.document.isDocumentPublished(contentId)).toBeTruthy();
});
test('can not publish a block list with a mandatory dropdown without a value', async ({umbracoApi, umbracoUi}) => {
test('cannot publish a block list with a mandatory dropdown without a value', async ({umbracoApi, umbracoUi}) => {
// Arrange
propertyEditorId = await umbracoApi.dataType.createDropdownDataType(propertyEditorName, false, optionValues);
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
await umbracoUi.content.isSuccessStateVisibleForSaveAndPublishButton();
expect(await umbracoApi.document.isDocumentPublished(contentId)).toBeTruthy();
});
test('cannot update a variant block list with invalid text', {tag: '@release'}, async ({umbracoApi, umbracoUi}) => {
// Arrange
const textStringElementDataTypeName = 'Textstring';
const textStringElementRegex = '[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+';
const wrongPropertyValue = 'This is an invalid email';
const correctPropertyValue = 'validemail@test.com';
// Create a new language
await umbracoApi.language.createDanishLanguage();
// ElementType with textstring and regex only accept an email address
const textStringElementDataType = await umbracoApi.dataType.getByName(textStringElementDataTypeName);
elementTypeId = await umbracoApi.documentType.createElementTypeWithRegexValidation(blockName, elementGroupName, textStringElementDataTypeName, textStringElementDataType.id, textStringElementRegex);
// Block List Editor with textstring
blockListId = await umbracoApi.dataType.createBlockListDataTypeWithABlock(blockListName, elementTypeId);
// Document Type with Block List Editor
documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, blockListName, blockListId, documentTypeGroupName, true, true);
// Creates content
contentId = await umbracoApi.document.createDefaultDocumentWithEnglishCulture(contentName, documentTypeId);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
// Act
await umbracoUi.content.goToContentWithName(contentName);
await umbracoUi.content.clickAddBlockElementButton();
await umbracoUi.content.clickBlockElementWithName(blockName);
// Enter text in the textstring block that won't match regex
await umbracoUi.content.enterPropertyValue(textStringElementDataTypeName, wrongPropertyValue);
await umbracoUi.content.clickCreateModalButton();
await umbracoUi.content.clickSaveButtonForContent();
await umbracoUi.content.clickSaveButton();
// Verify that the block list entry has an invalid badge
await umbracoUi.content.doesPropertyHaveInvalidBadge(blockListName);
await umbracoUi.content.clickEditBlockListEntryWithName(blockName);
await umbracoUi.content.doesModalFormValidationMessageContainText(ConstantHelper.validationMessages.invalidValue);
// Update the textstring block with a valid email address
await umbracoUi.content.enterPropertyValue(textStringElementDataTypeName, correctPropertyValue);
await umbracoUi.content.clickUpdateButton();
await umbracoUi.content.clickSaveButtonForContent();
await umbracoUi.content.clickSaveButton();
// Assert
const contentData = await umbracoApi.document.getByName(contentName);
expect(contentData.values[0].value.contentData[0].values[0].value).toContain(correctPropertyValue);
const blockListValue = contentData.values.find(item => item.editorAlias === "Umbraco.BlockList")?.value;
expect(blockListValue).toBeTruthy();
await umbracoUi.content.clickEditBlockListEntryWithName(blockName);
await umbracoUi.content.doesPropertyContainValue(textStringElementDataTypeName, correctPropertyValue);
});