From 4f62746053f5ff7a869d3c4ead165fe8ab90389e Mon Sep 17 00:00:00 2001 From: Nhu Dinh <150406148+nhudinh0309@users.noreply.github.com> Date: Thu, 25 Jul 2024 17:59:47 +0700 Subject: [PATCH] V14 Added Content tests with various data types (#16809) * Added Content tests with content picker * Removed the test for content picker * Added Content tests with the default content picker * Added more Content tests with Content Picker data type * Added the Content tests with Dropdown * Added Content tests with Image Cropper * Updated upload file method due to test helper changes * Added Content tests with Image Cropper * Added Content tests with Image Cropper data type * Added Content tests with Media Picker data type * Updated Media tests due to ui helper changes * Bumped version of test helper and json builder * Make all Content tests run in pipeline - should remove it before merging * Fixed the name of tests * Updated the tests for Media Picker in Content section * Added the Content tests with Multiple Media Picker * Updated the Content test with Content Picker due to the test helper changes * Bumped version of test helper * Fixed the failing tests for Content * Removed Image Cropper test in this branch * Added more waits * Added smoke tags * Make smoke tests run in the pipeline --- .../package-lock.json | 24 +-- .../Umbraco.Tests.AcceptanceTest/package.json | 4 +- .../Content/ChildrenContent.spec.ts | 15 +- .../Content/ContentInfoTab.spec.ts | 14 +- .../Content/ContentWithCheckboxList.spec.ts | 2 +- .../Content/ContentWithContentPicker.spec.ts | 173 ++++++++++++++++++ .../Content/ContentWithDropdown.spec.ts | 90 +++++++++ .../Content/ContentWithMediaPicker.spec.ts | 127 +++++++++++++ .../ContentWithMultipleMediaPicker.spec.ts | 110 +++++++++++ .../ContentWithPropertyEditors.spec.ts | 30 +-- .../tests/DefaultConfig/Media/Media.spec.ts | 2 +- 11 files changed, 528 insertions(+), 63 deletions(-) create mode 100644 tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithContentPicker.spec.ts create mode 100644 tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDropdown.spec.ts create mode 100644 tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithMediaPicker.spec.ts create mode 100644 tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithMultipleMediaPicker.spec.ts diff --git a/tests/Umbraco.Tests.AcceptanceTest/package-lock.json b/tests/Umbraco.Tests.AcceptanceTest/package-lock.json index f3fa4a9e360d..531366e886b7 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/package-lock.json +++ b/tests/Umbraco.Tests.AcceptanceTest/package-lock.json @@ -7,8 +7,8 @@ "name": "acceptancetest", "hasInstallScript": true, "dependencies": { - "@umbraco/json-models-builders": "^2.0.9", - "@umbraco/playwright-testhelpers": "^2.0.0-beta.65", + "@umbraco/json-models-builders": "^2.0.13", + "@umbraco/playwright-testhelpers": "^2.0.0-beta.68", "camelize": "^1.0.0", "dotenv": "^16.3.1", "faker": "^4.1.0", @@ -132,24 +132,20 @@ } }, "node_modules/@umbraco/json-models-builders": { - "version": "2.0.9", - "resolved": "https://registry.npmjs.org/@umbraco/json-models-builders/-/json-models-builders-2.0.9.tgz", - "integrity": "sha512-p6LjcE38WsFCvLtRRRVOCuMvris3OXeoueFu0FZBOHk2r7PXiqYCBUls/KbKxqpixzVDAb48RBd1hV7sKPcm5A==", + "version": "2.0.13", + "resolved": "https://registry.npmjs.org/@umbraco/json-models-builders/-/json-models-builders-2.0.13.tgz", + "integrity": "sha512-HeI6I2BO8/3rJyinJTFxhpBSr/TaCc+S1Si+9SXIlze+Erq+yraor706mQDsgIuLfUzAYgmLLoQFxMVof/P7Kw==", "dependencies": { "camelize": "^1.0.1" } }, "node_modules/@umbraco/playwright-testhelpers": { - "version": "2.0.0-beta.65", - "resolved": "https://registry.npmjs.org/@umbraco/playwright-testhelpers/-/playwright-testhelpers-2.0.0-beta.65.tgz", - "integrity": "sha512-plSD/4hhVaMl2TItAaBOUQyuy0Qo5rW3EGIF0TvL3a01s6hNoW1DrOCZhWsOOsMTkgf+oScLEsVIBMk0uDLQrg==", + "version": "2.0.0-beta.68", + "resolved": "https://registry.npmjs.org/@umbraco/playwright-testhelpers/-/playwright-testhelpers-2.0.0-beta.68.tgz", + "integrity": "sha512-yWM62NhQpL06y9qeJflYhSNtbxsU0BBTFnbR4kykV9X2oHT5fjSgZ/o1ZWqNbRcQkfB0SCykTYQ4ur1oCyXO8w==", "dependencies": { - "@umbraco/json-models-builders": "2.0.9", - "camelize": "^1.0.0", - "faker": "^4.1.0", - "form-data": "^4.0.0", - "node-fetch": "^2.6.7", - "xhr2": "^0.2.1" + "@umbraco/json-models-builders": "2.0.13", + "node-fetch": "^2.6.7" } }, "node_modules/aggregate-error": { diff --git a/tests/Umbraco.Tests.AcceptanceTest/package.json b/tests/Umbraco.Tests.AcceptanceTest/package.json index f0f2a60b94e2..9313a5a94097 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/package.json +++ b/tests/Umbraco.Tests.AcceptanceTest/package.json @@ -21,8 +21,8 @@ "wait-on": "^7.2.0" }, "dependencies": { - "@umbraco/json-models-builders": "^2.0.9", - "@umbraco/playwright-testhelpers": "^2.0.0-beta.65", + "@umbraco/json-models-builders": "^2.0.13", + "@umbraco/playwright-testhelpers": "^2.0.0-beta.68", "camelize": "^1.0.0", "dotenv": "^16.3.1", "faker": "^4.1.0", diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ChildrenContent.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ChildrenContent.spec.ts index bcbb9656dc66..20067cd7f41d 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ChildrenContent.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ChildrenContent.spec.ts @@ -7,7 +7,7 @@ let contentId = ''; const contentName = 'TestContent'; const childContentName = 'ChildContent'; const documentTypeName = 'DocumentTypeForContent'; -const childDocumentTypeName = 'ChildDocumentTypeForContent'; +const childDocumentTypeName = 'ChildDocumentType'; test.beforeEach(async ({umbracoApi}) => { await umbracoApi.documentType.ensureNameNotExists(documentTypeName); @@ -32,7 +32,9 @@ test('can create child node', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) = // Act await umbracoUi.content.clickActionsMenuForContent(contentName); await umbracoUi.content.clickCreateButton(); - await umbracoUi.content.chooseDocumentType(documentTypeName); + await umbracoUi.content.chooseDocumentType(childDocumentTypeName); + // This wait is needed + await umbracoUi.waitForTimeout(500); await umbracoUi.content.enterContentName(childContentName); await umbracoUi.content.clickSaveButton(); @@ -51,8 +53,7 @@ test('can create child node', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) = await umbracoApi.document.ensureNameNotExists(childContentName); }); -// TODO: Remove skip when the front-end is ready. -test.skip('can create child node in child node', async ({umbracoApi, umbracoUi}) => { +test('can create child node in child node', async ({umbracoApi, umbracoUi}) => { // Arrange const childOfChildContentName = 'ChildOfChildContent'; const childOfChildDocumentTypeName = 'ChildOfChildDocumentType'; @@ -71,7 +72,7 @@ test.skip('can create child node in child node', async ({umbracoApi, umbracoUi}) await umbracoUi.content.clickCaretButtonForContentName(contentName); await umbracoUi.content.clickActionsMenuForContent(childContentName); await umbracoUi.content.clickCreateButton(); - await umbracoUi.content.clickLabelWithName(childOfChildDocumentTypeName); + await umbracoUi.content.chooseDocumentType(childOfChildDocumentTypeName); // This wait is needed await umbracoUi.waitForTimeout(500); await umbracoUi.content.enterContentName(childOfChildContentName); @@ -81,9 +82,7 @@ test.skip('can create child node in child node', async ({umbracoApi, umbracoUi}) await umbracoUi.content.isSuccessNotificationVisible(); const childOfChildData = await umbracoApi.document.getChildren(childContentId); expect(childOfChildData[0].variants[0].name).toBe(childOfChildContentName); - // verify that the child content displays in the tree after reloading children - await umbracoUi.content.clickActionsMenuForContent(contentName); - await umbracoUi.content.clickReloadButton(); + // verify that the child content displays in the tree await umbracoUi.content.clickCaretButtonForContentName(childContentName); await umbracoUi.content.doesContentTreeHaveName(childOfChildContentName); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentInfoTab.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentInfoTab.spec.ts index 79cf1211e052..5ec48a6a67c6 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentInfoTab.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentInfoTab.spec.ts @@ -18,8 +18,11 @@ test.afterEach(async ({umbracoApi}) => { test('can see correct information when published', async ({umbracoApi, umbracoUi}) => { // Arrange const notPublishContentLink = 'This document is published but is not in the cache'; - documentTypeId = await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(documentTypeName); - contentId = await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + const dataTypeName = 'Textstring'; + const contentText = 'This is test content text'; + const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); + documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id); + contentId = await umbracoApi.document.createDocumentWithTextContent(contentName, documentTypeId, contentText, dataTypeName); await umbracoUi.goToBackOffice(); await umbracoUi.content.goToSection(ConstantHelper.sections.content); @@ -47,8 +50,7 @@ test('can see correct information when published', async ({umbracoApi, umbracoUi await umbracoUi.content.doesCreatedDateHaveText(expectedCreatedDate); }); -// TODO: Remove skip when the frond-end is ready. Currently the document type is not opened after clicking to the button -test.skip('can open document type', async ({umbracoApi, umbracoUi}) => { +test('can open document type', async ({umbracoApi, umbracoUi}) => { // Arrange documentTypeId = await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(documentTypeName); contentId = await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); @@ -57,7 +59,6 @@ test.skip('can open document type', async ({umbracoApi, umbracoUi}) => { // Act await umbracoUi.content.openContent(contentName); - await umbracoUi.content.clickInfoTab(); await umbracoUi.content.clickDocumentTypeByName(documentTypeName); // Assert @@ -76,7 +77,6 @@ test('can open template', async ({umbracoApi, umbracoUi}) => { // Act await umbracoUi.content.openContent(contentName); - await umbracoUi.content.clickInfoTab(); await umbracoUi.content.clickTemplateByName(templateName); // Assert @@ -101,7 +101,6 @@ test('can change template', async ({umbracoApi, umbracoUi}) => { // Act await umbracoUi.content.openContent(contentName); - await umbracoUi.content.clickInfoTab(); await umbracoUi.content.changeTemplate(firstTemplateName, secondTemplateName); await umbracoUi.content.clickSaveButton(); @@ -129,7 +128,6 @@ test('cannot change to a template that is not allowed in the document type', asy // Act await umbracoUi.content.openContent(contentName); - await umbracoUi.content.clickInfoTab(); await umbracoUi.content.clickEditTemplateByName(firstTemplateName); // Assert diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithCheckboxList.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithCheckboxList.spec.ts index 71706203eaba..6435272481dc 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithCheckboxList.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithCheckboxList.spec.ts @@ -56,7 +56,7 @@ test('can publish content with the checkbox list data type', async ({umbracoApi, expect(contentData.values).toEqual([]); }); -test('can create content with the custom approved color data type', async ({umbracoApi, umbracoUi}) => { +test('can create content with the custom checkbox list data type', async ({umbracoApi, umbracoUi}) => { // Arrange const customDataTypeName = 'CustomCheckboxList'; const optionValues = ['testOption1', 'testOption2']; diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithContentPicker.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithContentPicker.spec.ts new file mode 100644 index 000000000000..478cc7e3b412 --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithContentPicker.spec.ts @@ -0,0 +1,173 @@ +import {ConstantHelper, test} from '@umbraco/playwright-testhelpers'; +import {expect} from "@playwright/test"; + +const contentName = 'TestContent'; +const documentTypeName = 'TestDocumentTypeForContent'; +const dataTypeName = 'Content Picker'; +const contentPickerDocumentTypeName = 'DocumentTypeForContentPicker'; +const contentPickerName = 'TestContentPicker'; +let contentPickerDocumentTypeId = ''; + +test.beforeEach(async ({umbracoApi, umbracoUi}) => { + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + await umbracoApi.document.ensureNameNotExists(contentName); + contentPickerDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(contentPickerDocumentTypeName); + await umbracoUi.goToBackOffice(); +}); + +test.afterEach(async ({umbracoApi}) => { + await umbracoApi.document.ensureNameNotExists(contentPickerName); + await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + await umbracoApi.documentType.ensureNameNotExists(contentPickerDocumentTypeName); +}); + +test('can create content with the content picker datatype', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => { + // Arrange + const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); + await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id); + const contentPickerId = await umbracoApi.document.createDefaultDocument(contentPickerName, contentPickerDocumentTypeId); + 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.addContentPicker(contentPickerName); + await umbracoUi.content.clickSaveButton(); + + // Assert + await umbracoUi.content.doesSuccessNotificationsHaveCount(1); + expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy(); + const contentData = await umbracoApi.document.getByName(contentName); + expect(contentData.values[0].value).toEqual(contentPickerId); +}); + +test('can publish content with the content picker data type', async ({umbracoApi, umbracoUi}) => { + // Arrange + const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); + await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id); + const contentPickerId = await umbracoApi.document.createDefaultDocument(contentPickerName, contentPickerDocumentTypeId); + 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.addContentPicker(contentPickerName); + await umbracoUi.content.clickSaveAndPublishButton(); + + // Assert + await umbracoUi.content.doesSuccessNotificationsHaveCount(2); + expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy(); + const contentData = await umbracoApi.document.getByName(contentName); + expect(contentData.values[0].value).toEqual(contentPickerId); +}); + +test('can open content picker in the content', async ({umbracoApi, umbracoUi}) => { + // Arrange + const customDataTypeName = 'CustomContentPicker'; + const customDataTypeId = await umbracoApi.dataType.createContentPickerDataTypeWithShowOpenButton(customDataTypeName); + await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId); + await umbracoApi.document.createDefaultDocument(contentPickerName, contentPickerDocumentTypeId); + 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.addContentPicker(contentPickerName); + + // Assert + await umbracoUi.content.isOpenButtonVisibleInContentPicker(contentPickerName); + await umbracoUi.content.clickContentPickerOpenButton(contentPickerName); + await umbracoUi.content.isNodeOpenForContentPicker(contentPickerName); + + // Clean + await umbracoApi.dataType.ensureNameNotExists(customDataTypeName); +}); + +test('can choose start node for the content picker in the content', async ({umbracoApi, umbracoUi}) => { + // Arrange + const customDataTypeName = 'CustomContentPicker'; + const childContentPickerDocumentTypeName = 'ChildDocumentTypeForContentPicker'; + const childContentPickerName = 'TestChildContentPicker'; + await umbracoApi.documentType.ensureNameNotExists(childContentPickerDocumentTypeName); + const childContentPickerDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentType(childContentPickerDocumentTypeName); + const contentPickerDocumentTypeId = await umbracoApi.documentType.createDocumentTypeWithAllowedChildNode(contentPickerName, childContentPickerDocumentTypeId); + const contentPickerId = await umbracoApi.document.createDefaultDocument(contentPickerName, contentPickerDocumentTypeId); + await umbracoApi.document.createDefaultDocumentWithParent(childContentPickerName, childContentPickerDocumentTypeId, contentPickerId); + // Create a custom content picker with start node + const customDataTypeId = await umbracoApi.dataType.createContentPickerDataTypeWithStartNode(customDataTypeName, contentPickerId); + await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId); + 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.clickChooseButton(); + + // Assert + await umbracoUi.content.isContentNameVisible(childContentPickerName); + await umbracoUi.content.isContentNameVisible(contentPickerName, false); + + // Clean + await umbracoApi.dataType.ensureNameNotExists(customDataTypeName); + await umbracoApi.document.ensureNameNotExists(childContentPickerName); +}); + +test.skip('can ignore user start node for the content picker in the content', async ({umbracoApi, umbracoUi}) => { + // Arrange + const customDataTypeName = 'CustomContentPicker'; + const childContentPickerDocumentTypeName = 'ChildDocumentTypeForContentPicker'; + const childContentPickerName = 'TestChildContentPicker'; + await umbracoApi.documentType.ensureNameNotExists(childContentPickerDocumentTypeName); + const childContentPickerDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentType(childContentPickerDocumentTypeName); + const contentPickerDocumentTypeId = await umbracoApi.documentType.createDocumentTypeWithAllowedChildNode(contentPickerName, childContentPickerDocumentTypeId); + const contentPickerId = await umbracoApi.document.createDefaultDocument(contentPickerName, contentPickerDocumentTypeId); + await umbracoApi.document.createDefaultDocumentWithParent(childContentPickerName, childContentPickerDocumentTypeId, contentPickerId); + // Create a custom content picker with the setting "ignore user start node" is enable + const customDataTypeId = await umbracoApi.dataType.createContentPickerDataTypeWithIgnoreUserStartNodes(customDataTypeName, contentPickerId); + await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId); + 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.clickChooseButton(); + + // Assert + await umbracoUi.content.isContentNameVisible(childContentPickerName); + await umbracoUi.content.isContentNameVisible(contentPickerName); + + // Clean + await umbracoApi.dataType.ensureNameNotExists(customDataTypeName); + await umbracoApi.document.ensureNameNotExists(childContentPickerName); +}); + +test('can remove content picker in the content', async ({umbracoApi, umbracoUi}) => { + // Arrange + const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id); + const contentPickerId = await umbracoApi.document.createDefaultDocument(contentPickerName, contentPickerDocumentTypeId); + await umbracoApi.document.createDocumentWithContentPicker(contentName, documentTypeId, contentPickerId); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + + // Act + await umbracoUi.content.openContent(contentName); + await umbracoUi.content.removeContentPicker(contentPickerName); + await umbracoUi.content.clickSaveButton(); + + // Assert + await umbracoUi.content.isSuccessNotificationVisible(); + const contentData = await umbracoApi.document.getByName(contentName); + expect(contentData.values).toEqual([]); +}); + diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDropdown.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDropdown.spec.ts new file mode 100644 index 000000000000..07343cfaa1f9 --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDropdown.spec.ts @@ -0,0 +1,90 @@ +import { ConstantHelper, test, AliasHelper } from '@umbraco/playwright-testhelpers'; +import {expect} from "@playwright/test"; + +const contentName = 'TestContent'; +const documentTypeName = 'TestDocumentTypeForContent'; + +const dataTypeNames = ['Dropdown', 'Dropdown multiple']; +for (const dataTypeName of dataTypeNames) { + test.describe(`${dataTypeName} tests`, () => { + 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 the ${dataTypeName} data type`, async ({umbracoApi, umbracoUi}) => { + // Arrange + const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); + await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id); + 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.values).toEqual([]); + }); + + test(`can publish content with the ${dataTypeName} data type`, async ({umbracoApi, umbracoUi}) => { + // Arrange + const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); + await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id); + 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.clickSaveAndPublishButton(); + + // Assert + await umbracoUi.content.doesSuccessNotificationsHaveCount(2); + expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy(); + const contentData = await umbracoApi.document.getByName(contentName); + expect(contentData.values).toEqual([]); + }); + + test(`can create content with the custom ${dataTypeName} data type`, async ({umbracoApi, umbracoUi}) => { + // Arrange + const customDataTypeName = 'CustomDropdown'; + const optionValues = ['testOption1', 'testOption2', 'testOption3']; + const selectedOptions = dataTypeName === 'Dropdown' ? [optionValues[0]] : optionValues; + const isMultiple = dataTypeName === 'Dropdown' ? false : true; + const customDataTypeId = await umbracoApi.dataType.createDropdownDataType(customDataTypeName, isMultiple, optionValues); + await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId); + 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.chooseDropdownOption(selectedOptions); + await umbracoUi.content.clickSaveAndPublishButton(); + + // Assert + await umbracoUi.content.doesSuccessNotificationsHaveCount(2); + expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy(); + const contentData = await umbracoApi.document.getByName(contentName); + expect(contentData.values[0].alias).toEqual(AliasHelper.toAlias(customDataTypeName)); + expect(contentData.values[0].value).toEqual(selectedOptions); + + // Clean + await umbracoApi.dataType.ensureNameNotExists(customDataTypeName); + }); + }); +} diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithMediaPicker.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithMediaPicker.spec.ts new file mode 100644 index 000000000000..b263700fd32c --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithMediaPicker.spec.ts @@ -0,0 +1,127 @@ +import { ConstantHelper, test, AliasHelper } from '@umbraco/playwright-testhelpers'; +import {expect} from "@playwright/test"; + +const dataTypeName = 'Media Picker'; +const contentName = 'TestContent'; +const documentTypeName = 'TestDocumentTypeForContent'; +const mediaFileName = 'TestMediaFileForContent'; +const mediaTypeName = 'File'; +let mediaFileId = ''; + +test.beforeEach(async ({umbracoApi, umbracoUi}) => { + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.media.ensureNameNotExists(mediaFileName); + mediaFileId = await umbracoApi.media.createDefaultMedia(mediaFileName, mediaTypeName); + await umbracoUi.goToBackOffice(); +}); + +test.afterEach(async ({umbracoApi}) => { + await umbracoApi.media.ensureNameNotExists(mediaFileName); + await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); +}); + +test('can create content with the media picker data type', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => { + // Arrange + const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); + await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id); + 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.clickChooseMediaPickerButton(); + await umbracoUi.content.selectMediaByName(mediaFileName); + await umbracoUi.content.clickSubmitButton(); + 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.values[0].alias).toEqual(AliasHelper.toAlias(dataTypeName)); + expect(contentData.values[0].value[0].mediaKey).toEqual(mediaFileId); + expect(contentData.values[0].value[0].mediaTypeAlias).toEqual(mediaTypeName); + expect(contentData.values[0].value[0].focalPoint).toBeNull(); + expect(contentData.values[0].value[0].crops).toEqual([]); +}); + +test('can publish content with the media picker data type', async ({umbracoApi, umbracoUi}) => { + // Arrange + const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); + await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id); + 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.clickChooseMediaPickerButton(); + await umbracoUi.content.selectMediaByName(mediaFileName); + await umbracoUi.content.clickSubmitButton(); + await umbracoUi.content.clickSaveAndPublishButton(); + + // Assert + await umbracoUi.content.doesSuccessNotificationsHaveCount(2); + expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy(); + const contentData = await umbracoApi.document.getByName(contentName); + expect(contentData.values[0].alias).toEqual(AliasHelper.toAlias(dataTypeName)); + expect(contentData.values[0].value[0].mediaKey).toEqual(mediaFileId); + expect(contentData.values[0].value[0].mediaTypeAlias).toEqual(mediaTypeName); + expect(contentData.values[0].value[0].focalPoint).toBeNull(); + expect(contentData.values[0].value[0].crops).toEqual([]); +}); + +test('can remove a media picker in the content', async ({umbracoApi, umbracoUi}) => { + // Arrange + const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id); + await umbracoApi.document.createDocumentWithOneMediaPicker(contentName, documentTypeId, mediaFileId); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + + // Act + await umbracoUi.content.openContent(contentName); + await umbracoUi.content.removeMediaPickerByName(mediaFileName); + await umbracoUi.content.clickSaveButton(); + + // Assert + await umbracoUi.content.doesSuccessNotificationsHaveCount(1); + expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy(); + const contentData = await umbracoApi.document.getByName(contentName); + expect(contentData.values).toEqual([]); +}); + +test('can limit the media picker in the content by setting the start node', async ({umbracoApi, umbracoUi}) => { + // Arrange + const customDataTypeName = 'CustomMediaPicker'; + const mediaFolderName = 'TestMediaFolder'; + const childMediaName = 'ChildMedia'; + await umbracoApi.media.ensureNameNotExists(mediaFolderName); + const mediaFolderId = await umbracoApi.media.createDefaultMediaFolder(mediaFolderName); + await umbracoApi.media.ensureNameNotExists(childMediaName); + await umbracoApi.media.createDefaultMedia(childMediaName, mediaTypeName, mediaFolderId); + const customDataTypeId = await umbracoApi.dataType.createMediaPickerDataTypeWithStartNodeId(customDataTypeName, mediaFolderId); + await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId); + 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.clickChooseMediaPickerButton(); + + // Assert + await umbracoUi.content.isMediaNameVisible(mediaFolderName, false); + await umbracoUi.content.isMediaNameVisible(childMediaName, true); + + // Clean + await umbracoApi.media.ensureNameNotExists(mediaFolderName); + await umbracoApi.media.ensureNameNotExists(childMediaName); + await umbracoApi.dataType.ensureNameNotExists(customDataTypeName); +}); + diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithMultipleMediaPicker.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithMultipleMediaPicker.spec.ts new file mode 100644 index 000000000000..fb3440ad1d93 --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithMultipleMediaPicker.spec.ts @@ -0,0 +1,110 @@ +import { ConstantHelper, test, AliasHelper } from '@umbraco/playwright-testhelpers'; +import {expect} from "@playwright/test"; + +const dataTypeName = 'Multiple Media Picker'; +const contentName = 'TestContent'; +const documentTypeName = 'TestDocumentTypeForContent'; +const firstMediaFileName = 'TestFirstMedia'; +const firstMediaTypeName = 'File'; +const secondMediaFileName = 'TestSecondMedia'; +const secondMediaTypeName = 'Image'; +let firstMediaFileId = ''; +let secondMediaFileId = ''; + +test.beforeEach(async ({umbracoApi, umbracoUi}) => { + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.media.ensureNameNotExists(firstMediaFileName); + firstMediaFileId = await umbracoApi.media.createDefaultMedia(firstMediaFileName, firstMediaTypeName); + await umbracoApi.media.ensureNameNotExists(secondMediaFileName); + secondMediaFileId = await umbracoApi.media.createDefaultMedia(secondMediaFileName, secondMediaTypeName); + await umbracoUi.goToBackOffice(); +}); + +test.afterEach(async ({umbracoApi}) => { + await umbracoApi.media.ensureNameNotExists(firstMediaFileName); + await umbracoApi.media.ensureNameNotExists(secondMediaFileName); + await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); +}); + +test('can create content with multiple media picker data type', async ({umbracoApi, umbracoUi}) => { + // Arrange + const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); + await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id); + 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.clickChooseMediaPickerButton(); + await umbracoUi.content.selectMediaByName(firstMediaFileName); + await umbracoUi.content.selectMediaByName(secondMediaFileName); + await umbracoUi.content.clickSubmitButton(); + await umbracoUi.content.clickSaveButton(); + + // Assert + await umbracoUi.content.doesSuccessNotificationsHaveCount(1); + expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy(); + const contentData = await umbracoApi.document.getByName(contentName); + expect(contentData.values[0].alias).toEqual(AliasHelper.toAlias(dataTypeName)); + expect(contentData.values[0].value.length).toBe(2); + expect(contentData.values[0].value[0].mediaKey).toEqual(firstMediaFileId); + expect(contentData.values[0].value[0].mediaTypeAlias).toEqual(firstMediaTypeName); + expect(contentData.values[0].value[1].mediaKey).toEqual(secondMediaFileId); + expect(contentData.values[0].value[1].mediaTypeAlias).toEqual(secondMediaTypeName); +}); + +test('can publish content with multiple media picker data type', async ({umbracoApi, umbracoUi}) => { + // Arrange + const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); + await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id); + 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.clickChooseMediaPickerButton(); + await umbracoUi.content.selectMediaByName(firstMediaFileName); + await umbracoUi.content.selectMediaByName(secondMediaFileName); + await umbracoUi.content.clickSubmitButton(); + await umbracoUi.content.clickSaveAndPublishButton(); + + // Assert + await umbracoUi.content.doesSuccessNotificationsHaveCount(2); + expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy(); + const contentData = await umbracoApi.document.getByName(contentName); + expect(contentData.values[0].alias).toEqual(AliasHelper.toAlias(dataTypeName)); + expect(contentData.values[0].value.length).toBe(2); + expect(contentData.values[0].value[0].mediaKey).toEqual(firstMediaFileId); + expect(contentData.values[0].value[0].mediaTypeAlias).toEqual(firstMediaTypeName); + expect(contentData.values[0].value[1].mediaKey).toEqual(secondMediaFileId); + expect(contentData.values[0].value[1].mediaTypeAlias).toEqual(secondMediaTypeName); +}); + +test('can remove a media picker in the content', async ({umbracoApi, umbracoUi}) => { + // Arrange + const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id); + await umbracoApi.document.createDocumentWithTwoMediaPicker(contentName, documentTypeId, firstMediaFileId, secondMediaFileId); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + + // Act + await umbracoUi.content.openContent(contentName); + await umbracoUi.content.removeMediaPickerByName(firstMediaFileName); + await umbracoUi.content.clickSaveButton(); + + // Assert + await umbracoUi.content.doesSuccessNotificationsHaveCount(1); + expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy(); + const contentData = await umbracoApi.document.getByName(contentName); + expect(contentData.values[0].alias).toEqual(AliasHelper.toAlias(dataTypeName)); + expect(contentData.values[0].value.length).toBe(1); + expect(contentData.values[0].value[0].mediaKey).toEqual(secondMediaFileId); + expect(contentData.values[0].value[0].mediaTypeAlias).toEqual(secondMediaTypeName); +}); + diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithPropertyEditors.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithPropertyEditors.spec.ts index a6f998e80acf..dcfaba9ff7f1 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithPropertyEditors.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithPropertyEditors.spec.ts @@ -86,7 +86,7 @@ test.skip('can create content with the upload file datatype', async ({umbracoApi await umbracoUi.content.clickCreateButton(); await umbracoUi.content.chooseDocumentType(documentTypeName); await umbracoUi.content.enterContentName(contentName); - await umbracoUi.content.changeFileTypeWithFileChooser('./fixtures/mediaLibrary/' + uploadFilePath); + await umbracoUi.content.uploadFile('./fixtures/mediaLibrary/' + uploadFilePath); await umbracoUi.content.clickSaveAndPublishButton(); // Assert @@ -120,34 +120,6 @@ test('can create content with the tags datatype', async ({umbracoApi, umbracoUi} expect(contentData.values[0].value).toEqual([tagName]); }); -test('can create content with the content picker datatype', async ({umbracoApi, umbracoUi}) => { - // Arrange - const dataTypeName = 'Content Picker'; - const contentPickerName = 'TestContentPicker'; - const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); - const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id); - const contentPickerId = await umbracoApi.document.createDefaultDocument(contentPickerName, documentTypeId); - 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.addContentPicker(contentPickerName); - await umbracoUi.content.clickSaveAndPublishButton(); - - // Assert - await umbracoUi.content.doesSuccessNotificationsHaveCount(2); - expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy(); - const contentData = await umbracoApi.document.getByName(contentName); - expect(contentData.values[0].value).toEqual(contentPickerId); - - // Clean - await umbracoApi.document.ensureNameNotExists(contentPickerName); -}); - // TODO: Remove skip and update the test when the front-end is ready. Currently the list of content is not displayed. test.skip('can create content with the list view - content datatype', async ({umbracoApi, umbracoUi}) => { // Arrange diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Media/Media.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Media/Media.spec.ts index 128a86fcfc4e..d116a46e8f35 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Media/Media.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Media/Media.spec.ts @@ -69,7 +69,7 @@ for (const mediaFileType of mediaFileTypes) { await umbracoUi.media.clickCreateMediaItemButton(); await umbracoUi.media.clickMediaTypeWithNameButton(mediaFileType.fileName); await umbracoUi.media.enterMediaItemName(mediaFileType.fileName); - await umbracoUi.media.changeFileTypeWithFileChooser('./fixtures/mediaLibrary/' + mediaFileType.filePath); + await umbracoUi.media.uploadFile('./fixtures/mediaLibrary/' + mediaFileType.filePath); await umbracoUi.media.clickSaveButton(); // Assert