From 45f43a6b7ac632a76d4bd0f70176c37b69cdbf6c Mon Sep 17 00:00:00 2001 From: Nhu Dinh <150406148+nhudinh0309@users.noreply.github.com> Date: Fri, 27 Sep 2024 10:36:15 +0700 Subject: [PATCH] V14 Added Content tests with different document types properties (#17131) * Added tests for Allow At Root property * Added Content tests for Allowed Child Nodes property * Added Content tests for the Allow at root property * Added Content tests for the Allowed child node property * Added Content tests for the Collection property * Added Content tests with allow vary by culture * Added more waits * Updated tests due to api helper changes * Added Content tests with allowed templates * Bumped version of test helper * Updated code due to api helper changes * Fixed naming --- .../package-lock.json | 9 +- .../Umbraco.Tests.AcceptanceTest/package.json | 2 +- .../ContentWithAllowAtRoot.spec.ts | 27 ++++ .../ContentWithAllowVaryByCulture.spec.ts | 128 ++++++++++++++++ .../ContentWithAllowedChildNodes.spec.ts | 98 +++++++++++++ .../ContentWithAllowedTemplates.spec.ts | 66 +++++++++ .../ContentWithCollections.spec.ts | 138 ++++++++++++++++++ .../DocumentTypeDesignTab.spec.ts | 2 +- 8 files changed, 463 insertions(+), 7 deletions(-) create mode 100644 tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDocumentTypeProperties/ContentWithAllowAtRoot.spec.ts create mode 100644 tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDocumentTypeProperties/ContentWithAllowVaryByCulture.spec.ts create mode 100644 tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDocumentTypeProperties/ContentWithAllowedChildNodes.spec.ts create mode 100644 tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDocumentTypeProperties/ContentWithAllowedTemplates.spec.ts create mode 100644 tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDocumentTypeProperties/ContentWithCollections.spec.ts diff --git a/tests/Umbraco.Tests.AcceptanceTest/package-lock.json b/tests/Umbraco.Tests.AcceptanceTest/package-lock.json index bb227d8a12..99eeb24f0a 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/package-lock.json +++ b/tests/Umbraco.Tests.AcceptanceTest/package-lock.json @@ -8,7 +8,7 @@ "hasInstallScript": true, "dependencies": { "@umbraco/json-models-builders": "^2.0.20", - "@umbraco/playwright-testhelpers": "^2.0.0-beta.84", + "@umbraco/playwright-testhelpers": "^2.0.0-beta.86", "camelize": "^1.0.0", "dotenv": "^16.3.1", "node-fetch": "^2.6.7" @@ -64,10 +64,9 @@ } }, "node_modules/@umbraco/playwright-testhelpers": { - "version": "2.0.0-beta.84", - "resolved": "https://registry.npmjs.org/@umbraco/playwright-testhelpers/-/playwright-testhelpers-2.0.0-beta.84.tgz", - "integrity": "sha512-vH13Lg48knTkkLVTwhMXUKTOdjtmixFj0wF5Qhgb++13u4AVDb+oW+TbFwTjSYaLeNMraq5Uhwmto/XuJPs2Rw==", - "license": "MIT", + "version": "2.0.0-beta.86", + "resolved": "https://registry.npmjs.org/@umbraco/playwright-testhelpers/-/playwright-testhelpers-2.0.0-beta.86.tgz", + "integrity": "sha512-tF7nJCMgBJwaPtxWAuDOJ9lc3T11aO6ped9AxzAJTmzFdSJG16w8jzjWiNgCaU2xRsw5fRyos+I1YrFW249vLw==", "dependencies": { "@umbraco/json-models-builders": "2.0.20", "node-fetch": "^2.6.7" diff --git a/tests/Umbraco.Tests.AcceptanceTest/package.json b/tests/Umbraco.Tests.AcceptanceTest/package.json index 30706ad5de..a6949b54fa 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/package.json +++ b/tests/Umbraco.Tests.AcceptanceTest/package.json @@ -19,7 +19,7 @@ }, "dependencies": { "@umbraco/json-models-builders": "^2.0.20", - "@umbraco/playwright-testhelpers": "^2.0.0-beta.84", + "@umbraco/playwright-testhelpers": "^2.0.0-beta.86", "camelize": "^1.0.0", "dotenv": "^16.3.1", "node-fetch": "^2.6.7" diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDocumentTypeProperties/ContentWithAllowAtRoot.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDocumentTypeProperties/ContentWithAllowAtRoot.spec.ts new file mode 100644 index 0000000000..f028220533 --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDocumentTypeProperties/ContentWithAllowAtRoot.spec.ts @@ -0,0 +1,27 @@ +import {ConstantHelper, test} from '@umbraco/playwright-testhelpers'; + +const documentTypeName = 'TestDocumentTypeForContent'; + +test.beforeEach(async ({umbracoApi, umbracoUi}) => { + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + await umbracoUi.goToBackOffice(); +}); + +test.afterEach(async ({umbracoApi}) => { + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); +}); + +test('cannot create content if allow at root is disabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + const noAllowedDocumentTypeAvailableMessage = 'There are no allowed Document Types available for creating content here'; + await umbracoApi.documentType.createDefaultDocumentType(documentTypeName); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + + // Act + await umbracoUi.content.clickActionsMenuAtRoot(); + await umbracoUi.content.clickCreateButton(); + + // Assert + await umbracoUi.content.isDocumentTypeNameVisible(documentTypeName, false); + await umbracoUi.content.doesModalHaveText(noAllowedDocumentTypeAvailableMessage); +}); \ No newline at end of file diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDocumentTypeProperties/ContentWithAllowVaryByCulture.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDocumentTypeProperties/ContentWithAllowVaryByCulture.spec.ts new file mode 100644 index 0000000000..1c9fbc542f --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDocumentTypeProperties/ContentWithAllowVaryByCulture.spec.ts @@ -0,0 +1,128 @@ +import {ConstantHelper, test} from '@umbraco/playwright-testhelpers'; +import {expect} from "@playwright/test"; + +const contentName = 'TestContent'; +const documentTypeName = 'TestDocumentTypeForContent'; +const secondLanguageName = 'Danish'; + +test.beforeEach(async ({umbracoApi}) => { + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.language.ensureNameNotExists(secondLanguageName); + await umbracoApi.language.createDanishLanguage(); +}); + +test.afterEach(async ({umbracoApi}) => { + await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + await umbracoApi.language.ensureNameNotExists(secondLanguageName); +}); + +test('can create content with allow vary by culture enabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + await umbracoApi.documentType.createDocumentTypeWithAllowVaryByCulture(documentTypeName); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + + // Act + await umbracoUi.content.clickActionsMenuAtRoot(); + await umbracoUi.content.clickCreateButton(); + await umbracoUi.content.chooseDocumentType(documentTypeName); + await umbracoUi.content.enterContentName(contentName); + await umbracoUi.content.clickSaveButton(); + await umbracoUi.content.clickSaveAndCloseButton(); + + // Assert + await umbracoUi.content.isSuccessNotificationVisible(); + expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy(); +}); + +test('can create content with names that vary by culture', async ({umbracoApi, umbracoUi}) => { + // Arrange + const danishContentName = 'Test indhold'; + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithAllowVaryByCulture(documentTypeName); + 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.clickVariantSelectorButton(); + await umbracoUi.content.clickVariantAddModeButton(); + await umbracoUi.content.enterContentName(danishContentName); + await umbracoUi.content.clickSaveButton(); + await umbracoUi.content.clickSaveAndCloseButton(); + + // Assert + await umbracoUi.content.isSuccessNotificationVisible(); + expect(await umbracoApi.document.doesNameExist(danishContentName)).toBeTruthy(); + const contentData = await umbracoApi.document.getByName(danishContentName); + expect(contentData.variants.length).toBe(2); + expect(contentData.variants[0].name).toBe(contentName); + expect(contentData.variants[1].name).toBe(danishContentName); +}); + +test('can create content with names that vary by culture and content that is invariant', async ({umbracoApi, umbracoUi}) => { + // Arrange + const danishContentName = 'Test indhold'; + const textContent = 'This is a test text'; + const danishTextContent = 'Dette er testtekst'; + const dataTypeName = 'Textstring'; + const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id, 'Test Group', false); + await umbracoApi.document.createDocumentWithEnglishCultureAndTextContent(contentName, documentTypeId, textContent, dataTypeName); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + + // Act + await umbracoUi.content.goToContentWithName(contentName); + await umbracoUi.content.clickVariantSelectorButton(); + await umbracoUi.content.clickVariantAddModeButton(); + await umbracoUi.content.enterContentName(danishContentName); + await umbracoUi.content.enterTextstring(danishTextContent); + await umbracoUi.content.clickSaveButton(); + await umbracoUi.content.clickSaveAndCloseButton(); + + // Assert + await umbracoUi.content.isSuccessNotificationVisible(); + expect(await umbracoApi.document.doesNameExist(danishContentName)).toBeTruthy(); + const contentData = await umbracoApi.document.getByName(danishContentName); + expect(contentData.variants.length).toBe(2); + expect(contentData.variants[0].name).toBe(contentName); + expect(contentData.variants[1].name).toBe(danishContentName); + expect(contentData.values.length).toBe(1); + expect(contentData.values[0].value).toBe(danishTextContent); +}); + +test('can create content with names and content that vary by culture', async ({umbracoApi, umbracoUi}) => { + // Arrange + const danishContentName = 'Test indhold'; + const textContent = 'This is a test text'; + const danishTextContent = 'Dette er testtekst'; + const dataTypeName = 'Textstring'; + const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id, 'Test Group', true); + await umbracoApi.document.createDocumentWithEnglishCultureAndTextContent(contentName, documentTypeId, textContent, dataTypeName, true); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + + // Act + await umbracoUi.content.goToContentWithName(contentName); + await umbracoUi.content.clickVariantSelectorButton(); + await umbracoUi.content.clickVariantAddModeButton(); + await umbracoUi.content.enterContentName(danishContentName); + await umbracoUi.content.enterTextstring(danishTextContent); + await umbracoUi.content.clickSaveButton(); + await umbracoUi.content.clickSaveAndCloseButton(); + + // Assert + await umbracoUi.content.isSuccessNotificationVisible(); + expect(await umbracoApi.document.doesNameExist(danishContentName)).toBeTruthy(); + const contentData = await umbracoApi.document.getByName(danishContentName); + expect(contentData.variants.length).toBe(2); + expect(contentData.variants[0].name).toBe(contentName); + expect(contentData.variants[1].name).toBe(danishContentName); + expect(contentData.values.length).toBe(2); + expect(contentData.values[0].value).toBe(textContent); + expect(contentData.values[1].value).toBe(danishTextContent); +}); \ No newline at end of file diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDocumentTypeProperties/ContentWithAllowedChildNodes.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDocumentTypeProperties/ContentWithAllowedChildNodes.spec.ts new file mode 100644 index 0000000000..2016a0ee4c --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDocumentTypeProperties/ContentWithAllowedChildNodes.spec.ts @@ -0,0 +1,98 @@ +import {ConstantHelper, test} from '@umbraco/playwright-testhelpers'; +import {expect} from "@playwright/test"; + +const contentName = 'TestContent'; +const documentTypeName = 'TestDocumentTypeForContent'; + +test.beforeEach(async ({umbracoApi, umbracoUi}) => { + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoUi.goToBackOffice(); +}); + +test.afterEach(async ({umbracoApi}) => { + await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); +}); + +test('can create content with allowed child node enabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + const childDocumentTypeName = 'Test Child Document Type'; + const childDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentType(childDocumentTypeName); + await umbracoApi.documentType.createDocumentTypeWithAllowedChildNode(documentTypeName, childDocumentTypeId); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + + // Act + await umbracoUi.content.clickActionsMenuAtRoot(); + await umbracoUi.content.clickCreateButton(); + await umbracoUi.content.chooseDocumentType(documentTypeName); + await umbracoUi.content.enterContentName(contentName); + await umbracoUi.content.clickSaveButton(); + + // Assert + await umbracoUi.content.isSuccessNotificationVisible(); + expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy(); + + // Clean + await umbracoApi.documentType.ensureNameNotExists(childDocumentTypeName); +}); + +test('cannot create child content if allowed child node is disabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + const noAllowedDocumentTypeAvailableMessage = 'There are no allowed Document Types available for creating content here'; + const documentTypeId = await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(documentTypeName); + await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + + // Act + await umbracoUi.content.clickActionsMenuForContent(contentName); + await umbracoUi.content.clickCreateButton(); + + // Assert + await umbracoUi.content.isDocumentTypeNameVisible(documentTypeName, false); + await umbracoUi.content.doesModalHaveText(noAllowedDocumentTypeAvailableMessage); +}); + +test('can create multiple child nodes with different document types', async ({umbracoApi, umbracoUi}) => { + // Arrange + const firstChildDocumentTypeName = 'First Child Document Type'; + const secondChildDocumentTypeName = 'Second Child Document Type'; + const firstChildContentName = 'First Child Content'; + const secondChildContentName = 'Second Child Content'; + const firstChildDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentType(firstChildDocumentTypeName); + const secondChildDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentType(secondChildDocumentTypeName); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithAllowedTwoChildNodes(documentTypeName, firstChildDocumentTypeId, secondChildDocumentTypeId); + const contentId = await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + await umbracoApi.document.createDefaultDocumentWithParent(firstChildContentName, firstChildDocumentTypeId, contentId); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + + // Act + await umbracoUi.content.clickActionsMenuForContent(contentName); + await umbracoUi.content.clickCreateButton(); + await umbracoUi.content.chooseDocumentType(secondChildDocumentTypeName); + // This wait is needed + await umbracoUi.waitForTimeout(500); + await umbracoUi.content.enterContentName(secondChildContentName); + await umbracoUi.content.clickSaveButton(); + + // Assert + await umbracoUi.content.isSuccessNotificationVisible(); + expect(await umbracoApi.document.doesNameExist(secondChildContentName)).toBeTruthy(); + const childData = await umbracoApi.document.getChildren(contentId); + expect(childData.length).toBe(2); + expect(childData[0].variants[0].name).toBe(firstChildContentName); + expect(childData[1].variants[0].name).toBe(secondChildContentName); + // verify that the child content displays in the tree after reloading children + await umbracoUi.content.clickActionsMenuForContent(contentName); + await umbracoUi.content.clickReloadButton(); + await umbracoUi.content.clickCaretButtonForContentName(contentName); + await umbracoUi.content.doesContentTreeHaveName(firstChildContentName); + await umbracoUi.content.doesContentTreeHaveName(secondChildContentName); + + // Clean + await umbracoApi.document.ensureNameNotExists(firstChildContentName); + await umbracoApi.document.ensureNameNotExists(secondChildContentName); + await umbracoApi.documentType.ensureNameNotExists(firstChildDocumentTypeName); + await umbracoApi.documentType.ensureNameNotExists(secondChildDocumentTypeName); +}); \ No newline at end of file diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDocumentTypeProperties/ContentWithAllowedTemplates.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDocumentTypeProperties/ContentWithAllowedTemplates.spec.ts new file mode 100644 index 0000000000..f58d86c36e --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDocumentTypeProperties/ContentWithAllowedTemplates.spec.ts @@ -0,0 +1,66 @@ +import {ConstantHelper, test} from '@umbraco/playwright-testhelpers'; +import {expect} from "@playwright/test"; + +const contentName = 'TestContent'; +const documentTypeName = 'TestDocumentTypeForContent'; +const templateName = 'TestTemplate'; +let templateId = ''; + +test.beforeEach(async ({umbracoApi}) => { + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.template.ensureNameNotExists(templateName); + templateId = await umbracoApi.template.createDefaultTemplate(templateName); +}); + +test.afterEach(async ({umbracoApi}) => { + await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + await umbracoApi.template.ensureNameNotExists(templateName); +}); + +test('can create content with an allowed template', async ({umbracoApi, umbracoUi}) => { + // Arrange + await umbracoApi.documentType.createDocumentTypeWithAllowedTemplate(documentTypeName, templateId, true); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + + // Act + await umbracoUi.content.clickActionsMenuAtRoot(); + await umbracoUi.content.clickCreateButton(); + await umbracoUi.content.chooseDocumentType(documentTypeName); + await umbracoUi.content.enterContentName(contentName); + await umbracoUi.content.clickSaveButton(); + + // Assert + await umbracoUi.content.isSuccessNotificationVisible(); + expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy(); + const contentData = await umbracoApi.document.getByName(contentName); + expect(contentData.template.id).toBe(templateId); +}); + +test('can create content with multiple allowed templates', async ({umbracoApi, umbracoUi}) => { + // Arrange + const defaultTemplateName = 'TestDefaultTemplate'; + await umbracoApi.template.ensureNameNotExists(defaultTemplateName); + const defaultTemplateId = await umbracoApi.template.createDefaultTemplate(templateName); + await umbracoApi.documentType.createDocumentTypeWithTwoAllowedTemplates(documentTypeName, templateId, defaultTemplateId, true, defaultTemplateId); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + + // Act + await umbracoUi.content.clickActionsMenuAtRoot(); + await umbracoUi.content.clickCreateButton(); + await umbracoUi.content.chooseDocumentType(documentTypeName); + await umbracoUi.content.enterContentName(contentName); + await umbracoUi.content.clickSaveButton(); + + // Assert + await umbracoUi.content.isSuccessNotificationVisible(); + expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy(); + const contentData = await umbracoApi.document.getByName(contentName); + expect(contentData.template.id).toBe(defaultTemplateId); + + // Clean + await umbracoApi.template.ensureNameNotExists(defaultTemplateName); +}); \ No newline at end of file diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDocumentTypeProperties/ContentWithCollections.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDocumentTypeProperties/ContentWithCollections.spec.ts new file mode 100644 index 0000000000..837f7ababa --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDocumentTypeProperties/ContentWithCollections.spec.ts @@ -0,0 +1,138 @@ +import {ConstantHelper, test} from '@umbraco/playwright-testhelpers'; +import {expect} from "@playwright/test"; + +const contentName = 'TestContent'; +const documentTypeName = 'TestDocumentTypeForContent'; +const childDocumentTypeName = 'TestChildDocumentType'; +const firstChildContentName = 'First Child Content'; +const secondChildContentName = 'Second Child Content'; +const dataTypeName = 'List View - Content'; +let dataTypeData; + +test.beforeEach(async ({umbracoApi}) => { + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + await umbracoApi.document.ensureNameNotExists(contentName); + dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); +}); + +test.afterEach(async ({umbracoApi}) => { + await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); +}); + +test('can create content configured as a collection', async ({umbracoApi, umbracoUi}) => { + // Arrange + const noItemsToShowMessage = 'There are no items to show in the list.'; + await umbracoApi.documentType.createDocumentTypeWithCollectionId(documentTypeName, dataTypeData.id); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + + // Act + await umbracoUi.content.clickActionsMenuAtRoot(); + await umbracoUi.content.clickCreateButton(); + await umbracoUi.content.chooseDocumentType(documentTypeName); + await umbracoUi.content.enterContentName(contentName); + await umbracoUi.content.clickSaveButton(); + + // Assert + await umbracoUi.content.isSuccessNotificationVisible(); + await umbracoUi.content.isTabNameVisible('Collection'); + await umbracoUi.content.doesDocumentWorkspaceHaveText(noItemsToShowMessage); + expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy(); +}); + +test('can create child content in a collection', async ({umbracoApi, umbracoUi}) => { + // Arrange + const expectedNames = [firstChildContentName]; + const childDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentType(childDocumentTypeName); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithAllowedChildNodeAndCollectionId(documentTypeName, childDocumentTypeId, dataTypeData.id); + const contentId = await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + + // Act + await umbracoUi.content.clickActionsMenuForContent(contentName); + await umbracoUi.content.clickCreateButton(); + await umbracoUi.content.chooseDocumentType(childDocumentTypeName); + // This wait is needed + await umbracoUi.waitForTimeout(500); + await umbracoUi.content.enterContentName(firstChildContentName); + await umbracoUi.content.clickSaveButton(); + + // Assert + const childData = await umbracoApi.document.getChildren(contentId); + expect(childData.length).toBe(expectedNames.length); + expect(childData[0].variants[0].name).toBe(firstChildContentName); + // verify that the child content displays in collection list after reloading tree + await umbracoUi.waitForTimeout(1000); + await umbracoUi.content.clickActionsMenuForContent(contentName); + await umbracoUi.content.clickReloadButton(); + await umbracoUi.content.goToContentWithName(contentName); + await umbracoUi.content.doesDocumentTableColumnNameValuesMatch(expectedNames); + + // Clean + await umbracoApi.document.ensureNameNotExists(firstChildContentName); + await umbracoApi.documentType.ensureNameNotExists(childDocumentTypeName); +}); + +test('can create multiple child nodes in a collection', async ({umbracoApi, umbracoUi}) => { + // Arrange + const expectedNames = [secondChildContentName, firstChildContentName]; + const childDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentType(childDocumentTypeName); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithAllowedChildNodeAndCollectionId(documentTypeName, childDocumentTypeId, dataTypeData.id); + const contentId = await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + await umbracoApi.document.createDefaultDocumentWithParent(firstChildContentName, childDocumentTypeId, contentId); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + + // Act + await umbracoUi.content.clickActionsMenuForContent(contentName); + await umbracoUi.content.clickCreateButton(); + await umbracoUi.content.chooseDocumentType(childDocumentTypeName); + // This wait is needed + await umbracoUi.waitForTimeout(500); + await umbracoUi.content.enterContentName(secondChildContentName); + await umbracoUi.content.clickSaveButton(); + + // Assert + const childData = await umbracoApi.document.getChildren(contentId); + expect(childData.length).toBe(expectedNames.length); + expect(childData[0].variants[0].name).toBe(firstChildContentName); + expect(childData[1].variants[0].name).toBe(secondChildContentName); + // verify that the child content displays in collection list after reloading tree + await umbracoUi.waitForTimeout(1000); + await umbracoUi.content.clickActionsMenuForContent(contentName); + await umbracoUi.content.clickReloadButton(); + await umbracoUi.content.goToContentWithName(contentName); + await umbracoUi.content.doesDocumentTableColumnNameValuesMatch(expectedNames); + + // Clean + await umbracoApi.document.ensureNameNotExists(firstChildContentName); + await umbracoApi.document.ensureNameNotExists(secondChildContentName); + await umbracoApi.documentType.ensureNameNotExists(childDocumentTypeName); +}); + +test('can search in a collection of content', async ({umbracoApi, umbracoUi}) => { + // Arrange + const searchKeyword = 'First'; + const expectedSearchResult = [firstChildContentName]; + const childDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentType(childDocumentTypeName); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithAllowedChildNodeAndCollectionId(documentTypeName, childDocumentTypeId, dataTypeData.id); + const contentId = await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + await umbracoApi.document.createDefaultDocumentWithParent(firstChildContentName, childDocumentTypeId, contentId); + await umbracoApi.document.createDefaultDocumentWithParent(secondChildContentName, childDocumentTypeId, contentId); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + + // Act + await umbracoUi.content.goToContentWithName(contentName); + await umbracoUi.content.searchByKeywordInCollection(searchKeyword); + + // Assert + await umbracoUi.content.doesDocumentTableColumnNameValuesMatch(expectedSearchResult); + + // Clean + await umbracoApi.document.ensureNameNotExists(firstChildContentName); + await umbracoApi.document.ensureNameNotExists(secondChildContentName); + await umbracoApi.documentType.ensureNameNotExists(childDocumentTypeName); +}); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/DocumentType/DocumentTypeDesignTab.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/DocumentType/DocumentTypeDesignTab.spec.ts index eb87b7288a..3f19d68085 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/DocumentType/DocumentTypeDesignTab.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/DocumentType/DocumentTypeDesignTab.spec.ts @@ -397,7 +397,7 @@ test('can enable validation for a property in a document type', async ({umbracoA test('can allow vary by culture for a property in a document type', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => { // Arrange const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); - await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id, groupName, true); + await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id, groupName, false); await umbracoUi.documentType.goToSection(ConstantHelper.sections.settings); // Act