V16 QA Added acceptance tests for creating a document using blueprint (#19708)

* Added tests for creating content using document blueprint

* Updated tests due to api helper for document blueprint changes

* Bumped version

* Make all Blueprint tests runs in the pipeline

* Reverted npm command
This commit is contained in:
Nhu Dinh
2025-07-21 10:33:30 +07:00
committed by GitHub
parent d31b88b94a
commit 6d240b6a07
3 changed files with 211 additions and 12 deletions

View File

@@ -7,8 +7,8 @@
"name": "acceptancetest",
"hasInstallScript": true,
"dependencies": {
"@umbraco/json-models-builders": "^2.0.36",
"@umbraco/playwright-testhelpers": "^16.0.27",
"@umbraco/json-models-builders": "^2.0.37",
"@umbraco/playwright-testhelpers": "^16.0.28",
"camelize": "^1.0.0",
"dotenv": "^16.3.1",
"node-fetch": "^2.6.7"
@@ -58,20 +58,19 @@
}
},
"node_modules/@umbraco/json-models-builders": {
"version": "2.0.36",
"resolved": "https://registry.npmjs.org/@umbraco/json-models-builders/-/json-models-builders-2.0.36.tgz",
"integrity": "sha512-vQLL/y2ZIqrhCBe61W6YuA/C3KjGkva90WA09YfQuPL9HujOkJpVaP7KjJ0F8bBxwURy9tzMBFBLUz5fOdbkxQ==",
"version": "2.0.37",
"resolved": "https://registry.npmjs.org/@umbraco/json-models-builders/-/json-models-builders-2.0.37.tgz",
"integrity": "sha512-97cRUrD+oeEno9I+qFjq7lWVS0+aDEK44lQQYWmVPAkCuAG1HMpBTEblS45CflrmLtgrDuZx68WIVVGpk9JzgQ==",
"dependencies": {
"camelize": "^1.0.1"
}
},
"node_modules/@umbraco/playwright-testhelpers": {
"version": "16.0.27",
"resolved": "https://registry.npmjs.org/@umbraco/playwright-testhelpers/-/playwright-testhelpers-16.0.27.tgz",
"integrity": "sha512-KxjIpfFsiK5b1Au8QrlWceK88eo53VxogLs0LMrxsRS3rt4rdmD1YRP6U+yIucdPKnhVgfIsh40J/taGAZyPFQ==",
"license": "MIT",
"version": "16.0.28",
"resolved": "https://registry.npmjs.org/@umbraco/playwright-testhelpers/-/playwright-testhelpers-16.0.28.tgz",
"integrity": "sha512-l0RDfiXjQAtN2ykg7IX6ZSSW8GGLBm9RFO8WjsnRKAh7gZkH8+0DJdhx573m5bfZE6xa33TgyzIg9x+m/42/Lw==",
"dependencies": {
"@umbraco/json-models-builders": "2.0.36",
"@umbraco/json-models-builders": "2.0.37",
"node-fetch": "^2.6.7"
}
},

View File

@@ -20,8 +20,8 @@
"typescript": "^4.8.3"
},
"dependencies": {
"@umbraco/json-models-builders": "^2.0.36",
"@umbraco/playwright-testhelpers": "^16.0.27",
"@umbraco/json-models-builders": "^2.0.37",
"@umbraco/playwright-testhelpers": "^16.0.28",
"camelize": "^1.0.0",
"dotenv": "^16.3.1",
"node-fetch": "^2.6.7"

View File

@@ -0,0 +1,200 @@
import {AliasHelper, ConstantHelper, test} from '@umbraco/playwright-testhelpers';
import {expect} from "@playwright/test";
// Content
const contentName = 'TestContentFromBlueprint';
const textContent = 'This is a block in document blueprint';
// Document Type
const documentTypeName = 'TestDocumentTypeForContent';
const groupName = 'TestGroup';
// Document Blueprint
const documentBlueprintName = 'TestDocumentBlueprint';
const documentBlueprintDanishName = 'TestDocumentBlueprint-DA';
// ElementType
const elementGroupName = 'ElementGroup';
const elementTypeName = 'TestElement';
const richTextDataTypeUiAlias = 'Richtext editor';
const elementDataTypeUiAlias = 'Umbraco.RichText';
const elementPropertyName = 'TipTapProperty'
// DataType
const blockDataTypeName = 'TestBlockEditor';
test.beforeEach(async ({umbracoApi}) => {
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
await umbracoApi.document.ensureNameNotExists(contentName);
await umbracoApi.documentBlueprint.ensureNameNotExists(documentBlueprintName);
});
test.afterEach(async ({umbracoApi}) => {
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
await umbracoApi.document.ensureNameNotExists(contentName);
await umbracoApi.document.ensureNameNotExists(documentBlueprintName);
await umbracoApi.documentBlueprint.ensureNameNotExists(documentBlueprintName);
await umbracoApi.documentType.ensureNameNotExists(elementTypeName);
await umbracoApi.dataType.ensureNameNotExists(blockDataTypeName);
});
test('can create content using an invariant document blueprint', async ({umbracoApi, umbracoUi}) => {
// Arrange
const dataTypeName = 'Textstring';
const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id);
await umbracoApi.documentBlueprint.createDocumentBlueprintWithTextBoxValue(documentBlueprintName, documentTypeId, dataTypeName, textContent);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
// Act
await umbracoUi.content.clickActionsMenuAtRoot();
await umbracoUi.content.clickCreateActionMenuOption();
await umbracoUi.content.chooseDocumentType(documentTypeName);
await umbracoUi.content.clickModalMenuItemWithName(documentBlueprintName);
await umbracoUi.content.clickSaveButtonForContent();
// Assert
await umbracoUi.content.waitForContentToBeCreated();
expect(await umbracoApi.document.doesNameExist(documentBlueprintName)).toBeTruthy();
const contentData = await umbracoApi.document.getByName(documentBlueprintName);
expect(contentData.values[0].value).toBe(textContent);
});
test('can create content using a variant document blueprint', async ({umbracoApi, umbracoUi}) => {
// Arrange
const dataTypeName = 'Textstring';
await umbracoApi.language.createDanishLanguage();
const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
const documentTypeId = await umbracoApi.documentType.createVariantDocumentTypeWithInvariantPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id);
await umbracoApi.documentBlueprint.createDocumenBlueprintWithEnglishCultureAndDanishCultureAndTextBoxValue(documentBlueprintName, documentBlueprintDanishName, documentTypeId, dataTypeName, textContent);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
// Act
await umbracoUi.content.clickActionsMenuAtRoot();
await umbracoUi.content.clickCreateActionMenuOption();
await umbracoUi.content.chooseDocumentType(documentTypeName);
await umbracoUi.content.clickModalMenuItemWithName(documentBlueprintName);
await umbracoUi.content.clickSaveButtonForContent();
await umbracoUi.content.clickSaveButton();
// Assert
await umbracoUi.content.waitForContentToBeCreated();
expect(await umbracoApi.document.doesNameExist(documentBlueprintName)).toBeTruthy();
const contentData = await umbracoApi.document.getByName(documentBlueprintName);
expect(contentData.values[0].value).toBe(textContent);
expect(contentData.variants[0].name).toBe(documentBlueprintName);
expect(contentData.variants[1].name).toBe(documentBlueprintDanishName);
// Clean
await umbracoApi.language.ensureNameNotExists('Danish');
});
test('can create content with different name using an invariant document blueprint', async ({umbracoApi, umbracoUi}) => {
// Arrange
const dataTypeName = 'Textstring';
const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id);
await umbracoApi.documentBlueprint.createDocumentBlueprintWithTextBoxValue(documentBlueprintName, documentTypeId, dataTypeName, textContent);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
// Act
await umbracoUi.content.clickActionsMenuAtRoot();
await umbracoUi.content.clickCreateActionMenuOption();
await umbracoUi.content.chooseDocumentType(documentTypeName);
await umbracoUi.content.clickModalMenuItemWithName(documentBlueprintName);
await umbracoUi.content.enterContentName(contentName);
await umbracoUi.content.clickSaveButtonForContent();
// Assert
await umbracoUi.content.waitForContentToBeCreated();
expect(await umbracoApi.document.doesNameExist(documentBlueprintName)).toBeFalsy();
expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy();
const contentData = await umbracoApi.document.getByName(contentName);
expect(contentData.values[0].value).toBe(textContent);
});
test('can create content with different name using a variant document blueprint', async ({umbracoApi, umbracoUi}) => {
// Arrange
const dataTypeName = 'Textstring';
await umbracoApi.language.createDanishLanguage();
const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
const documentTypeId = await umbracoApi.documentType.createVariantDocumentTypeWithInvariantPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id);
await umbracoApi.documentBlueprint.createDocumenBlueprintWithEnglishCultureAndDanishCultureAndTextBoxValue(documentBlueprintName, documentBlueprintDanishName, documentTypeId, dataTypeName, textContent);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
// Act
await umbracoUi.content.clickActionsMenuAtRoot();
await umbracoUi.content.clickCreateActionMenuOption();
await umbracoUi.content.chooseDocumentType(documentTypeName);
await umbracoUi.content.clickModalMenuItemWithName(documentBlueprintName);
await umbracoUi.content.enterContentName(contentName);
await umbracoUi.content.clickSaveButtonForContent();
await umbracoUi.content.clickSaveButton();
// Assert
await umbracoUi.content.waitForContentToBeCreated();
expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy();
const contentData = await umbracoApi.document.getByName(contentName);
expect(contentData.values[0].value).toBe(textContent);
expect(contentData.variants[0].name).toBe(contentName);
expect(contentData.variants[1].name).toBe(documentBlueprintDanishName);
// Clean
await umbracoApi.language.ensureNameNotExists('Danish');
});
test('can create content using a document blueprint with block list', async ({umbracoApi, umbracoUi}) => {
// Arrange
await umbracoApi.dataType.ensureNameNotExists(blockDataTypeName);
const tipTapDataType = await umbracoApi.dataType.getByName(richTextDataTypeUiAlias);
const tipTapDataTypeId = tipTapDataType.id;
const elementTypeId = await umbracoApi.documentType.createDefaultElementType(elementTypeName, elementGroupName, elementPropertyName, tipTapDataTypeId);
await umbracoApi.documentBlueprint.createDefaultDocumentBlueprintWithABlockListEditorAndBlockWithValue(documentBlueprintName, documentTypeName, blockDataTypeName, elementTypeId, AliasHelper.toAlias(elementPropertyName), elementDataTypeUiAlias, textContent, groupName);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
// Act
await umbracoUi.content.clickActionsMenuAtRoot();
await umbracoUi.content.clickCreateActionMenuOption();
await umbracoUi.content.chooseDocumentType(documentTypeName);
await umbracoUi.content.clickModalMenuItemWithName(documentBlueprintName);
await umbracoUi.content.clickSaveButtonForContent();
// Assert
await umbracoUi.content.waitForContentToBeCreated();
expect(await umbracoApi.document.doesNameExist(documentBlueprintName)).toBeTruthy();
const contentData = await umbracoApi.document.getByName(documentBlueprintName);
expect(contentData.values[0].value.contentData[0].values[0].value.markup).toEqual(textContent);
const blockListValue = contentData.values.find(item => item.editorAlias === "Umbraco.BlockList")?.value;
expect(blockListValue).toBeTruthy();
});
test('can create content using a document blueprint with block grid', async ({umbracoApi, umbracoUi}) => {
// Arrange
await umbracoApi.dataType.ensureNameNotExists(blockDataTypeName);
const tipTapDataType = await umbracoApi.dataType.getByName(richTextDataTypeUiAlias);
const tipTapDataTypeId = tipTapDataType.id;
const elementTypeId = await umbracoApi.documentType.createDefaultElementType(elementTypeName, elementGroupName, elementPropertyName, tipTapDataTypeId);
await umbracoApi.documentBlueprint.createDefaultDocumentBlueprintWithABlockGridEditorAndBlockWithValue(documentBlueprintName, documentTypeName, blockDataTypeName, elementTypeId, AliasHelper.toAlias(elementPropertyName), richTextDataTypeUiAlias, textContent);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
// Act
await umbracoUi.content.clickActionsMenuAtRoot();
await umbracoUi.content.clickCreateActionMenuOption();
await umbracoUi.content.chooseDocumentType(documentTypeName);
await umbracoUi.content.clickModalMenuItemWithName(documentBlueprintName);
await umbracoUi.content.clickSaveButtonForContent();
// Assert
await umbracoUi.content.waitForContentToBeCreated();
expect(await umbracoApi.document.doesNameExist(documentBlueprintName)).toBeTruthy();
const contentData = await umbracoApi.document.getByName(documentBlueprintName);
expect(contentData.values[0].value.contentData[0].values[0].value.markup).toEqual(textContent);
const blockListValue = contentData.values.find(item => item.editorAlias === "Umbraco.BlockGrid")?.value;
expect(blockListValue).toBeTruthy();
});