diff --git a/tests/Umbraco.Tests.AcceptanceTest/fixtures/packageLibrary/package.xml b/tests/Umbraco.Tests.AcceptanceTest/fixtures/packageLibrary/package.xml index 72693f113d..f3a15e7154 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/fixtures/packageLibrary/package.xml +++ b/tests/Umbraco.Tests.AcceptanceTest/fixtures/packageLibrary/package.xml @@ -11,8 +11,6 @@ - - diff --git a/tests/Umbraco.Tests.AcceptanceTest/package-lock.json b/tests/Umbraco.Tests.AcceptanceTest/package-lock.json index e1a56c1f85..3ca1a953ce 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.25", - "@umbraco/playwright-testhelpers": "^15.0.0-beta.6", + "@umbraco/playwright-testhelpers": "^15.0.1", "camelize": "^1.0.0", "dotenv": "^16.3.1", "node-fetch": "^2.6.7" @@ -58,14 +58,16 @@ "version": "2.0.25", "resolved": "https://registry.npmjs.org/@umbraco/json-models-builders/-/json-models-builders-2.0.25.tgz", "integrity": "sha512-bFO4AuXUlkyRtBolqOnAvlW12B7Zh/cee3DHShAb+KaXdAC9LzvHYCSH33yJRk2Qc9KvK6ECAMamhiBcT1cMWw==", + "license": "MIT", "dependencies": { "camelize": "^1.0.1" } }, "node_modules/@umbraco/playwright-testhelpers": { - "version": "15.0.0-beta.6", - "resolved": "https://registry.npmjs.org/@umbraco/playwright-testhelpers/-/playwright-testhelpers-15.0.0-beta.6.tgz", - "integrity": "sha512-qwvqg3fzBGXqhH25hLwjLeciazE413ee34R6Ejbg/epKoIcxF/WbMN9NNosBbamlXPg5iCKv3nr543YHTGX1Jw==", + "version": "15.0.1", + "resolved": "https://registry.npmjs.org/@umbraco/playwright-testhelpers/-/playwright-testhelpers-15.0.1.tgz", + "integrity": "sha512-6ow0oSZ1SqR1ES7yudXjagXvV2C6eOWZoBNLvHAkwMeYtHroaQ44Gn+n+TEgu6S3ipa6cr0LBlrUWL19dpEWMw==", + "license": "MIT", "dependencies": { "@umbraco/json-models-builders": "2.0.25", "node-fetch": "^2.6.7" diff --git a/tests/Umbraco.Tests.AcceptanceTest/package.json b/tests/Umbraco.Tests.AcceptanceTest/package.json index e1f07c7c04..0a6519dfd3 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/package.json +++ b/tests/Umbraco.Tests.AcceptanceTest/package.json @@ -21,7 +21,7 @@ }, "dependencies": { "@umbraco/json-models-builders": "^2.0.25", - "@umbraco/playwright-testhelpers": "^15.0.0-beta.6", + "@umbraco/playwright-testhelpers": "^15.0.1", "camelize": "^1.0.0", "dotenv": "^16.3.1", "node-fetch": "^2.6.7" diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/Content.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/Content.spec.ts index 0c7a869eb0..07f16cab9f 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/Content.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/Content.spec.ts @@ -1,4 +1,4 @@ -import {ConstantHelper, test} from '@umbraco/playwright-testhelpers'; +import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers'; import {expect} from "@playwright/test"; let documentTypeId = ''; @@ -32,7 +32,7 @@ test('can create empty content', async ({umbracoApi, umbracoUi}) => { await umbracoUi.content.clickSaveButton(); // Assert - await umbracoUi.content.isSuccessNotificationVisible(); + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy(); const contentData = await umbracoApi.document.getByName(contentName); expect(contentData.variants[0].state).toBe(expectedState); @@ -54,6 +54,8 @@ test('can save and publish empty content', {tag: '@smoke'}, async ({umbracoApi, // Assert await umbracoUi.content.doesSuccessNotificationsHaveCount(2); + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.published); expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy(); const contentData = await umbracoApi.document.getByName(contentName); expect(contentData.variants[0].state).toBe(expectedState); @@ -75,7 +77,7 @@ test('can create content', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => { await umbracoUi.content.clickSaveButton(); // Assert - await umbracoUi.content.isSuccessNotificationVisible(); + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy(); const contentData = await umbracoApi.document.getByName(contentName); expect(contentData.values[0].value).toBe(contentText); @@ -96,7 +98,7 @@ test('can rename content', async ({umbracoApi, umbracoUi}) => { await umbracoUi.content.clickSaveButton(); // Assert - await umbracoUi.content.isSuccessNotificationVisible(); + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const updatedContentData = await umbracoApi.document.get(contentId); expect(updatedContentData.variants[0].name).toEqual(contentName); }); @@ -116,7 +118,7 @@ test('can update content', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => { await umbracoUi.content.clickSaveButton(); // Assert - await umbracoUi.content.isSuccessNotificationVisible(); + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const updatedContentData = await umbracoApi.document.get(contentId); expect(updatedContentData.variants[0].name).toEqual(contentName); expect(updatedContentData.values[0].value).toBe(contentText); @@ -135,7 +137,7 @@ test('can publish content', async ({umbracoApi, umbracoUi}) => { await umbracoUi.content.clickPublishButton(); // Assert - await umbracoUi.content.isSuccessNotificationVisible(); + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.published); const contentData = await umbracoApi.document.getByName(contentName); expect(contentData.variants[0].state).toBe('Published'); }); @@ -145,8 +147,7 @@ test('can unpublish content', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) = 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); - const publishData = {"publishSchedules":[{"culture":null}]}; - await umbracoApi.document.publish(contentId, publishData); + await umbracoApi.document.publish(contentId); await umbracoUi.goToBackOffice(); await umbracoUi.content.goToSection(ConstantHelper.sections.content); @@ -156,7 +157,7 @@ test('can unpublish content', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) = await umbracoUi.content.clickConfirmToUnpublishButton(); // Assert - await umbracoUi.content.isSuccessNotificationVisible(); + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.unpublished); const contentData = await umbracoApi.document.getByName(contentName); expect(contentData.variants[0].state).toBe('Draft'); }); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithCustomDataType.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithCustomDataType.spec.ts new file mode 100644 index 0000000000..c13538b73f --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithCustomDataType.spec.ts @@ -0,0 +1,317 @@ +import {ConstantHelper, test, AliasHelper} from '@umbraco/playwright-testhelpers'; +import {expect} from "@playwright/test"; + +const contentName = 'TestContent'; +const documentTypeName = 'TestDocumentTypeForContent'; +let customDataTypeName = ''; + +test.beforeEach(async ({umbracoApi}) => { + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + await umbracoApi.document.ensureNameNotExists(contentName); +}); + +test.afterEach(async ({umbracoApi}) => { + await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + await umbracoApi.dataType.ensureNameNotExists(customDataTypeName); +}); + +test('can create content with the custom data type with email address property editor', async ({umbracoApi, umbracoUi}) => { + // Arrange + customDataTypeName = 'Email Address'; + const customDataTypeId = await umbracoApi.dataType.createEmailAddressDataType(customDataTypeName); + await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId); + 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.values).toEqual([]); +}); + +test('can add text to the email address in the content section', async ({umbracoApi, umbracoUi}) => { + // Arrange + customDataTypeName = 'Email Address'; + const emailAddress = 'test@acceptance.test'; + const customDataTypeId = await umbracoApi.dataType.createEmailAddressDataType(customDataTypeName); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId); + await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + + // Act + await umbracoUi.content.goToContentWithName(contentName); + await umbracoUi.content.enterTextstring(emailAddress); + 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(customDataTypeName)); + expect(contentData.values[0].value).toEqual(emailAddress); +}); + +test('can create content with the custom data type with decimal property editor', async ({umbracoApi, umbracoUi}) => { + // Arrange + customDataTypeName = 'Decimal'; + const customDataTypeId = await umbracoApi.dataType.createDecimalDataType(customDataTypeName); + await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId); + 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.values).toEqual([]); +}); + +test('can add decimal number to the decimal in the content section', async ({umbracoApi, umbracoUi}) => { + // Arrange + customDataTypeName = 'Decimal'; + const decimal = 3.9; + const customDataTypeId = await umbracoApi.dataType.createDecimalDataType(customDataTypeName); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId); + await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + + // Act + await umbracoUi.content.goToContentWithName(contentName); + await umbracoUi.content.enterNumeric(decimal); + 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(customDataTypeName)); + expect(contentData.values[0].value).toEqual(decimal); +}); + +// Skip this test as currently there is no code editor property editor available. +test.skip('can create content with the custom data type with code editor property editor', async ({umbracoApi, umbracoUi}) => { + // Arrange + customDataTypeName = 'Code Editor'; + const customDataTypeId = await umbracoApi.dataType.createCodeEditorDataType(customDataTypeName); + await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId); + 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.values).toEqual([]); +}); + +test('can add javascript code to the code editor in the content section', async ({umbracoApi, umbracoUi}) => { + // Arrange + customDataTypeName = 'Code Editor'; + const javascriptCode = 'const test = \'This is the acceptance test\';'; + const customDataTypeId = await umbracoApi.dataType.createCodeEditorDataType(customDataTypeName); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId); + await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + + // Act + await umbracoUi.content.goToContentWithName(contentName); + await umbracoUi.content.enterCodeEditorValue(javascriptCode); + 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(customDataTypeName)); + expect(contentData.values[0].value).toEqual(javascriptCode); +}); + +test('can create content with the custom data type with markdown editor property editor', async ({umbracoApi, umbracoUi}) => { + // Arrange + customDataTypeName = 'Markdown Editor'; + const customDataTypeId = await umbracoApi.dataType.createMarkdownEditorDataType(customDataTypeName); + await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId); + 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.values).toEqual([]); +}); + +test('can add code to the markdown editor in the content section', async ({umbracoApi, umbracoUi}) => { + // Arrange + customDataTypeName = 'Markdown Editor'; + const inputText = '# This is test heading\r\n> This is test quote'; + const customDataTypeId = await umbracoApi.dataType.createMarkdownEditorDataType(customDataTypeName); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId); + await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + + // Act + await umbracoUi.content.goToContentWithName(contentName); + await umbracoUi.content.enterMarkdownEditorValue(inputText); + 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(customDataTypeName)); + expect(contentData.values[0].value).toEqual(inputText); +}); + +test('can create content with the custom data type with multiple text string property editor', async ({umbracoApi, umbracoUi}) => { + // Arrange + customDataTypeName = 'Multiple Text String'; + const customDataTypeId = await umbracoApi.dataType.createMultipleTextStringDataType(customDataTypeName); + await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId); + 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.values).toEqual([]); +}); + +test('can add string to the multiple text string in the content section', async ({umbracoApi, umbracoUi}) => { + // Arrange + customDataTypeName = 'Multiple Text String'; + const multipleTextStringValue = 'Test text string item'; + const customDataTypeId = await umbracoApi.dataType.createMultipleTextStringDataType(customDataTypeName); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId); + await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + + // Act + await umbracoUi.content.goToContentWithName(contentName); + await umbracoUi.content.addMultipleTextStringItem(multipleTextStringValue); + 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(customDataTypeName)); + expect(contentData.values[0].value).toEqual([multipleTextStringValue]); +}); + +test('can create content with the custom data type with slider property editor', async ({umbracoApi, umbracoUi}) => { + // Arrange + customDataTypeName = 'Slider'; + const customDataTypeId = await umbracoApi.dataType.createSliderDataTyper(customDataTypeName); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId); + await umbracoApi.document.createDefaultDocument(contentName, 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.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 change slider value in the content section', async ({umbracoApi, umbracoUi}) => { + // Arrange + customDataTypeName = 'Slider'; + const sliderValue = 10; + const expectedValue = { + "from": sliderValue, + "to": sliderValue + } + const customDataTypeId = await umbracoApi.dataType.createSliderDataTyper(customDataTypeName); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId); + await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + + // Act + await umbracoUi.content.goToContentWithName(contentName); + await umbracoUi.content.changeSliderValue(sliderValue.toString()); + 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(customDataTypeName)); + expect(contentData.values[0].value).toEqual(expectedValue); +}); + +test('can save content after changing the property editor of the custom data type', async ({umbracoApi, umbracoUi}) => { + // Arrange + customDataTypeName = 'Custom Text String'; + const inputText = 'Test textstring'; + const customDataTypeId = await umbracoApi.dataType.createTextstringDataType(customDataTypeName); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId); + await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + + // Act + // Update the property editor of the custom data type + const customDataTypeData = await umbracoApi.dataType.getByName(customDataTypeName); + customDataTypeData.editorAlias = 'Umbraco.MultipleTextstring'; + customDataTypeData.editorUiAlias = 'Umb.PropertyEditorUi.MultipleTextString'; + await umbracoApi.dataType.update(customDataTypeId, customDataTypeData); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + await umbracoUi.content.goToContentWithName(contentName); + await umbracoUi.content.addMultipleTextStringItem(inputText); + await umbracoUi.content.clickSaveButton(); + + // Assert + await umbracoUi.content.isSuccessNotificationVisible(); +}); \ No newline at end of file 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..cc1b17b9a4 --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDocumentTypeProperties/ContentWithAllowAtRoot.spec.ts @@ -0,0 +1,25 @@ +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 + 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); +}); 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..ff8664c33b --- /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..8ac6b133c8 --- /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..d31b884ea1 --- /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..2c369a772b --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDocumentTypeProperties/ContentWithCollections.spec.ts @@ -0,0 +1,137 @@ +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 + 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.doesContentListHaveNoItemsInList(); + 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/Content/ContentWithListViewContent.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithListViewContent.spec.ts new file mode 100644 index 0000000000..ee86e4eef7 --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithListViewContent.spec.ts @@ -0,0 +1,393 @@ +import {ConstantHelper, test} from '@umbraco/playwright-testhelpers'; +import {expect} from "@playwright/test"; + +const contentName = 'TestContent'; +const documentTypeName = 'TestDocumentTypeForContent'; +const dataTypeName = 'List View - Content Custom'; +const childDocumentTypeName = 'ChildDocumentTypeForContent'; +const childContentName = 'ChildContent'; + +test.beforeEach(async ({umbracoApi, umbracoUi}) => { + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.dataType.ensureNameNotExists(dataTypeName); + await umbracoApi.documentType.ensureNameNotExists(childDocumentTypeName); + await umbracoUi.goToBackOffice(); +}); + +test.afterEach(async ({umbracoApi}) => { + await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + await umbracoApi.dataType.ensureNameNotExists(dataTypeName); + await umbracoApi.documentType.ensureNameNotExists(childDocumentTypeName); +}); + +test('can create content with the list view data type', async ({umbracoApi, umbracoUi}) => { + // Arrange + const expectedState = 'Draft'; + const defaultListViewDataTypeName = 'List View - Content'; + const childDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentType(childDocumentTypeName); + const dataTypeData = await umbracoApi.dataType.getByName(defaultListViewDataTypeName); + await umbracoApi.documentType.createDocumentTypeWithAPropertyEditorAndAnAllowedChildNode(documentTypeName, defaultListViewDataTypeName, dataTypeData.id, childDocumentTypeId); + 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.variants[0].state).toBe(expectedState); + expect(await umbracoApi.document.getChildrenAmount(contentData.id)).toEqual(0); +}); + +test('can publish content with the list view data type', async ({umbracoApi, umbracoUi}) => { + // Arrange + const expectedState = 'Published'; + const childDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentType(childDocumentTypeName); + await umbracoApi.dataType.createListViewContentDataType(dataTypeName); + const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithAPropertyEditorAndAnAllowedChildNode(documentTypeName, dataTypeName, dataTypeData.id, childDocumentTypeId); + const documentId = await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + + // Act + await umbracoUi.content.goToContentWithName(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.variants[0].state).toBe(expectedState); + expect(await umbracoApi.document.getChildrenAmount(documentId)).toEqual(0); +}); + +test('can create content with a child in the list', async ({umbracoApi, umbracoUi}) => { + // Arrange + const childDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentType(childDocumentTypeName); + await umbracoApi.dataType.createListViewContentDataType(dataTypeName); + const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithAPropertyEditorAndAnAllowedChildNode(documentTypeName, dataTypeName, dataTypeData.id, childDocumentTypeId); + const documentId = await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + await umbracoUi.content.goToContentWithName(contentName); + + // Act + await umbracoUi.content.clickCreateContentWithName(childDocumentTypeName); + await umbracoUi.content.enterNameInContainer(childContentName); + await umbracoUi.content.clickSaveModalButton(); + + // Assert + await umbracoUi.content.isSuccessNotificationVisible(); + expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy(); + expect(await umbracoApi.document.getChildrenAmount(documentId)).toEqual(1); +}); + +test('can publish content with a child in the list', async ({umbracoApi, umbracoUi}) => { + // Arrange + const expectedState = 'Published'; + const childDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentType(childDocumentTypeName); + await umbracoApi.dataType.createListViewContentDataType(dataTypeName); + const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithAPropertyEditorAndAnAllowedChildNode(documentTypeName, dataTypeName, dataTypeData.id, childDocumentTypeId); + const documentId = await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + await umbracoApi.document.createDefaultDocumentWithParent(childContentName, childDocumentTypeId, documentId); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + await umbracoUi.content.goToContentWithName(contentName); + + // Act + await umbracoUi.content.clickSaveAndPublishButton(); + await umbracoUi.content.goToContentInListViewWithName(childContentName); + await umbracoUi.content.clickContainerSaveAndPublishButton(); + + // Assert + await umbracoUi.content.doesSuccessNotificationsHaveCount(2); + expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy(); + const contentData = await umbracoApi.document.getByName(contentName); + expect(contentData.variants[0].state).toBe(expectedState); + expect(await umbracoApi.document.getChildrenAmount(documentId)).toEqual(1); + // Checks if child is published + const childContentData = await umbracoApi.document.getByName(childContentName); + expect(childContentData.variants[0].state).toBe(expectedState); +}); + +test('can not publish child in a list when parent is not published', async ({umbracoApi, umbracoUi}) => { + // Arrange + const expectedState = 'Draft'; + const childDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentType(childDocumentTypeName); + await umbracoApi.dataType.createListViewContentDataType(dataTypeName); + const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithAPropertyEditorAndAnAllowedChildNode(documentTypeName, dataTypeName, dataTypeData.id, childDocumentTypeId); + const documentId = await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + await umbracoApi.document.createDefaultDocumentWithParent(childContentName, childDocumentTypeId, documentId); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + await umbracoUi.content.goToContentWithName(contentName); + + // Act + await umbracoUi.content.goToContentInListViewWithName(childContentName); + await umbracoUi.content.clickContainerSaveAndPublishButton(); + + // Assert + // Content created, but not published + await umbracoUi.content.doesSuccessNotificationsHaveCount(1); + await umbracoUi.content.isErrorNotificationVisible(); + const contentData = await umbracoApi.document.getByName(contentName); + expect(contentData.variants[0].state).toBe(expectedState); + expect(await umbracoApi.document.getChildrenAmount(documentId)).toEqual(1); + // Checks if child is still in draft + const childContentData = await umbracoApi.document.getByName(childContentName); + expect(childContentData.variants[0].state).toBe(expectedState); +}); + +test('child is removed from list after child content is deleted', async ({umbracoApi, umbracoUi}) => { + // Arrange + const childDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentType(childDocumentTypeName); + await umbracoApi.dataType.createListViewContentDataType(dataTypeName); + const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithAPropertyEditorAndAnAllowedChildNode(documentTypeName, dataTypeName, dataTypeData.id, childDocumentTypeId); + const documentId = await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + await umbracoApi.document.createDefaultDocumentWithParent(childContentName, childDocumentTypeId, documentId); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + expect(await umbracoApi.document.getChildrenAmount(documentId)).toEqual(1); + + // Act + await umbracoUi.content.clickCaretButtonForContentName(contentName); + await umbracoUi.content.clickActionsMenuForContent(childContentName); + await umbracoUi.content.clickTrashButton(); + await umbracoUi.content.clickConfirmTrashButton(); + + // Assert + await umbracoUi.content.goToContentWithName(contentName); + await umbracoUi.content.doesContentListHaveNoItemsInList(); + expect(await umbracoApi.document.getChildrenAmount(documentId)).toEqual(0); + expect(await umbracoApi.document.doesNameExist(childContentName)).toBeFalsy(); +}); + +test('can sort list by name', async ({umbracoApi, umbracoUi}) => { + // Arrange + const childDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentType(childDocumentTypeName); + const secondChildContentName = 'ASecondChildContent'; + await umbracoApi.dataType.createListViewContentDataType(dataTypeName); + const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithAPropertyEditorAndAnAllowedChildNode(documentTypeName, dataTypeName, dataTypeData.id, childDocumentTypeId); + const documentId = await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + await umbracoApi.document.createDefaultDocumentWithParent(childContentName, childDocumentTypeId, documentId); + await umbracoApi.document.createDefaultDocumentWithParent(secondChildContentName, childDocumentTypeId, documentId); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + const childAmountBeforeDelete = await umbracoApi.document.getChildrenAmount(documentId); + expect(childAmountBeforeDelete).toEqual(2); + await umbracoUi.content.goToContentWithName(contentName); + + // Act + await umbracoUi.content.clickNameButtonInListView(); + + // Assert + expect(await umbracoApi.document.getChildrenAmount(documentId)).toEqual(2); + await umbracoUi.content.doesFirstItemInListViewHaveName(secondChildContentName); +}); + +test('can publish child content from list', async ({umbracoApi, umbracoUi}) => { + // Arrange + const expectedState = 'Published'; + const childDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentType(childDocumentTypeName); + await umbracoApi.dataType.createListViewContentDataTypeWithAllPermissions(dataTypeName); + const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithAPropertyEditorAndAnAllowedChildNode(documentTypeName, dataTypeName, dataTypeData.id, childDocumentTypeId); + const documentId = await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + await umbracoApi.document.createDefaultDocumentWithParent(childContentName, childDocumentTypeId, documentId); + const publishData = {"publishSchedules": [{"culture": null}]}; + await umbracoApi.document.publish(documentId, publishData); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + await umbracoUi.content.goToContentWithName(contentName); + + // Act + await umbracoUi.content.selectContentWithNameInListView(childContentName); + await umbracoUi.content.clickPublishSelectedListItems(); + + // Assert + await umbracoUi.content.isSuccessNotificationVisible(); + expect(await umbracoApi.document.getChildrenAmount(documentId)).toEqual(1); + const childContentData = await umbracoApi.document.getByName(childContentName); + expect(childContentData.variants[0].state).toBe(expectedState); +}); + +test('can not publish child content from list when parent is not published', async ({umbracoApi, umbracoUi}) => { + // Arrange + const expectedState = 'Draft'; + const childDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentType(childDocumentTypeName); + await umbracoApi.dataType.createListViewContentDataTypeWithAllPermissions(dataTypeName); + const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithAPropertyEditorAndAnAllowedChildNode(documentTypeName, dataTypeName, dataTypeData.id, childDocumentTypeId); + const documentId = await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + await umbracoApi.document.createDefaultDocumentWithParent(childContentName, childDocumentTypeId, documentId); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + await umbracoUi.content.goToContentWithName(contentName); + + // Act + await umbracoUi.content.selectContentWithNameInListView(childContentName); + await umbracoUi.content.clickPublishSelectedListItems(); + + // Assert + await umbracoUi.content.isErrorNotificationVisible(); + const childContentData = await umbracoApi.document.getByName(childContentName); + expect(childContentData.variants[0].state).toBe(expectedState); +}); + +test('can unpublish child content from list', async ({umbracoApi, umbracoUi}) => { + // Arrange + const expectedState = 'Draft'; + const childDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentType(childDocumentTypeName); + await umbracoApi.dataType.createListViewContentDataTypeWithAllPermissions(dataTypeName); + const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithAPropertyEditorAndAnAllowedChildNode(documentTypeName, dataTypeName, dataTypeData.id, childDocumentTypeId); + const documentId = await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + const childDocumentId = await umbracoApi.document.createDefaultDocumentWithParent(childContentName, childDocumentTypeId, documentId); + const publishData = {"publishSchedules": [{"culture": null}]}; + await umbracoApi.document.publish(documentId, publishData); + await umbracoApi.document.publish(childDocumentId, publishData); + const childContentDataBeforeUnpublished = await umbracoApi.document.getByName(childContentName); + expect(childContentDataBeforeUnpublished.variants[0].state).toBe('Published'); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + await umbracoUi.content.goToContentWithName(contentName); + + // Act + await umbracoUi.content.selectContentWithNameInListView(childContentName); + await umbracoUi.content.clickUnpublishSelectedListItems(); + await umbracoUi.content.clickConfirmToUnpublishButton(); + + // Assert + await umbracoUi.content.isSuccessNotificationVisible(); + const childContentData = await umbracoApi.document.getByName(childContentName); + expect(childContentData.variants[0].state).toBe(expectedState); +}); + +test('can duplicate child content in list', async ({umbracoApi, umbracoUi}) => { + // Arrange + const secondDocumentName = 'SecondDocument'; + await umbracoApi.document.ensureNameNotExists(secondDocumentName); + const childDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentType(childDocumentTypeName); + await umbracoApi.dataType.createListViewContentDataTypeWithAllPermissions(dataTypeName); + const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithAPropertyEditorAndAnAllowedChildNode(documentTypeName, dataTypeName, dataTypeData.id, childDocumentTypeId); + const documentId = await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + const secondDocumentId = await umbracoApi.document.createDefaultDocument(secondDocumentName, documentTypeId); + await umbracoApi.document.createDefaultDocumentWithParent(childContentName, childDocumentTypeId, documentId); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + await umbracoUi.content.goToContentWithName(contentName); + + // Act + await umbracoUi.content.selectContentWithNameInListView(childContentName); + await umbracoUi.content.clickDuplicateToSelectedListItems(); + await umbracoUi.content.selectDocumentWithNameAtRoot(secondDocumentName); + + // Assert + await umbracoUi.content.isSuccessNotificationVisible(); + await umbracoUi.content.doesFirstItemInListViewHaveName(childContentName); + await umbracoUi.content.goToContentWithName(secondDocumentName); + await umbracoUi.content.doesFirstItemInListViewHaveName(childContentName); + // Checks firstContentNode + expect(await umbracoApi.document.getChildrenAmount(documentId)).toEqual(1); + // Checks secondContentNode + expect(await umbracoApi.document.getChildrenAmount(secondDocumentId)).toEqual(1); +}); + +test('can move child content in list', async ({umbracoApi, umbracoUi}) => { + // Arrange + const secondDocumentName = 'SecondDocument'; + await umbracoApi.document.ensureNameNotExists(secondDocumentName); + const childDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentType(childDocumentTypeName); + await umbracoApi.dataType.createListViewContentDataTypeWithAllPermissions(dataTypeName); + const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithAPropertyEditorAndAnAllowedChildNode(documentTypeName, dataTypeName, dataTypeData.id, childDocumentTypeId); + const documentId = await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + const secondDocumentId = await umbracoApi.document.createDefaultDocument(secondDocumentName, documentTypeId); + await umbracoApi.document.createDefaultDocumentWithParent(childContentName, childDocumentTypeId, documentId); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + await umbracoUi.content.goToContentWithName(contentName); + + // Act + await umbracoUi.content.selectContentWithNameInListView(childContentName); + await umbracoUi.content.clickMoveToSelectedListItems(); + await umbracoUi.content.selectDocumentWithNameAtRoot(secondDocumentName); + + // Assert + await umbracoUi.content.isSuccessNotificationVisible(); + await umbracoUi.content.doesListViewContainCount(0); + await umbracoUi.content.goToContentWithName(secondDocumentName); + await umbracoUi.content.doesFirstItemInListViewHaveName(childContentName); + // Checks firstContentNode + expect(await umbracoApi.document.getChildrenAmount(documentId)).toEqual(0); + // Checks secondContentNode + expect(await umbracoApi.document.getChildrenAmount(secondDocumentId)).toEqual(1); +}); + +test('can trash child content in list', async ({umbracoApi, umbracoUi}) => { + // Arrange + const childDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentType(childDocumentTypeName); + await umbracoApi.dataType.createListViewContentDataTypeWithAllPermissions(dataTypeName); + const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithAPropertyEditorAndAnAllowedChildNode(documentTypeName, dataTypeName, dataTypeData.id, childDocumentTypeId); + const documentId = await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + await umbracoApi.document.createDefaultDocumentWithParent(childContentName, childDocumentTypeId, documentId); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + await umbracoUi.content.goToContentWithName(contentName); + + // Act + await umbracoUi.content.selectContentWithNameInListView(childContentName); + await umbracoUi.content.clickTrashSelectedListItems(); + await umbracoUi.content.clickConfirmTrashButton(); + + // Assert + await umbracoUi.content.isSuccessNotificationVisible(); + await umbracoUi.content.doesListViewContainCount(0); + expect(await umbracoApi.document.getChildrenAmount(documentId)).toEqual(0); + await umbracoUi.content.isItemVisibleInRecycleBin(childContentName); +}); + +test('can search for child content in list', async ({umbracoApi, umbracoUi}) => { + // Arrange + const secondChildName = 'SecondChildDocument'; + await umbracoApi.document.ensureNameNotExists(secondChildName); + const childDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentType(childDocumentTypeName); + await umbracoApi.dataType.createListViewContentDataTypeWithAllPermissions(dataTypeName); + const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithAPropertyEditorAndAnAllowedChildNode(documentTypeName, dataTypeName, dataTypeData.id, childDocumentTypeId); + const documentId = await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + await umbracoApi.document.createDefaultDocumentWithParent(childContentName, childDocumentTypeId, documentId); + await umbracoApi.document.createDefaultDocumentWithParent(secondChildName, childDocumentTypeId, documentId); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + await umbracoUi.content.goToContentWithName(contentName); + await umbracoUi.content.doesListViewContainCount(2); + + // Act + await umbracoUi.content.searchByKeywordInCollection(childContentName); + + // Assert + await umbracoUi.content.doesListViewContainCount(1); + await umbracoUi.content.doesFirstItemInListViewHaveName(childContentName); +}); + +test('can change from list view to grid view in list', async ({umbracoApi, umbracoUi}) => { + // Arrange + const childDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentType(childDocumentTypeName); + await umbracoApi.dataType.createListViewContentDataTypeWithAllPermissions(dataTypeName); + const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithAPropertyEditorAndAnAllowedChildNode(documentTypeName, dataTypeName, dataTypeData.id, childDocumentTypeId); + const documentId = await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + await umbracoApi.document.createDefaultDocumentWithParent(childContentName, childDocumentTypeId, documentId); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + await umbracoUi.content.goToContentWithName(contentName); + await umbracoUi.content.isDocumentListViewVisible(); + + // Act + await umbracoUi.content.changeToGridView(); + + // Assert + await umbracoUi.content.isDocumentGridViewVisible(); +}); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithMemberPicker.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithMemberPicker.spec.ts index 31d51ffdfd..62eec89659 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithMemberPicker.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithMemberPicker.spec.ts @@ -22,7 +22,7 @@ test.beforeEach(async ({umbracoApi, umbracoUi}) => { test.afterEach(async ({umbracoApi}) => { await umbracoApi.memberType.ensureNameNotExists(memberTypeName); await umbracoApi.member.ensureNameNotExists(memberName); - await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.document.ensureNameNotExists(contentName); await umbracoApi.documentType.ensureNameNotExists(documentTypeName); }); @@ -64,7 +64,7 @@ test('can publish content with the member picker data type', async ({umbracoApi, await umbracoUi.content.goToContentWithName(contentName); await umbracoUi.content.clickChooseMemberPickerButton(); await umbracoUi.content.selectMemberByName(memberName); - await umbracoUi.content.clickChooseModalButton(); + await umbracoUi.content.clickChooseContainerButton(); await umbracoUi.content.clickSaveAndPublishButton(); // Assert @@ -93,4 +93,4 @@ test('can remove a member picker in the content', async ({umbracoApi, umbracoUi} expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy(); const contentData = await umbracoApi.document.getByName(contentName); expect(contentData.values).toEqual([]); -}); \ No newline at end of file +}); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithMultiURLPicker.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithMultiURLPicker.spec.ts index da3d8ddc76..f713427c3e 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithMultiURLPicker.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithMultiURLPicker.spec.ts @@ -13,12 +13,11 @@ test.beforeEach(async ({umbracoApi}) => { }); test.afterEach(async ({umbracoApi}) => { - await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.document.ensureNameNotExists(contentName); await umbracoApi.documentType.ensureNameNotExists(documentTypeName); }); -// TODO: Remove skip when the front-end is ready. Currently it is impossible to link an unpublish document -test.skip('can create content with the document link', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => { +test('can create content with the document link', {tag: '@smoke'}, async ({page, umbracoApi, umbracoUi}) => { // Arrange const expectedState = 'Draft'; const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); @@ -28,6 +27,8 @@ test.skip('can create content with the document link', {tag: '@smoke'}, async ({ const documentTypeForLinkedDocumentId = await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(documentTypeForLinkedDocumentName); const linkedDocumentName = 'LinkedDocument'; const linkedDocumentId = await umbracoApi.document.createDefaultDocument(linkedDocumentName, documentTypeForLinkedDocumentId); + await umbracoUi.waitForTimeout(2000); + await umbracoApi.document.publish(linkedDocumentId); await umbracoUi.goToBackOffice(); await umbracoUi.content.goToSection(ConstantHelper.sections.content); @@ -39,7 +40,7 @@ test.skip('can create content with the document link', {tag: '@smoke'}, async ({ await umbracoUi.content.clickAddMultiURLPickerButton(); await umbracoUi.content.clickLinkToDocumentButton(); await umbracoUi.content.selectLinkByName(linkedDocumentName); - await umbracoUi.content.clickChooseModalButton(); + await umbracoUi.content.clickButtonWithName('Choose'); await umbracoUi.content.clickSubmitButton(); await umbracoUi.content.clickSaveButton(); @@ -62,8 +63,7 @@ test.skip('can create content with the document link', {tag: '@smoke'}, async ({ await umbracoApi.document.ensureNameNotExists(linkedDocumentName); }); -// TODO: Remove skip when the front-end is ready. Currently it is impossible to link an unpublish document -test.skip('can publish content with the document link', async ({umbracoApi, umbracoUi}) => { +test('can publish content with the document link', async ({umbracoApi, umbracoUi}) => { // Arrange const expectedState = 'Published'; const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); @@ -74,6 +74,8 @@ test.skip('can publish content with the document link', async ({umbracoApi, umbr const documentTypeForLinkedDocumentId = await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(documentTypeForLinkedDocumentName); const linkedDocumentName = 'ContentToPick'; const linkedDocumentId = await umbracoApi.document.createDefaultDocument(linkedDocumentName, documentTypeForLinkedDocumentId); + await umbracoUi.waitForTimeout(2000); + await umbracoApi.document.publish(linkedDocumentId); await umbracoUi.goToBackOffice(); await umbracoUi.content.goToSection(ConstantHelper.sections.content); @@ -82,7 +84,7 @@ test.skip('can publish content with the document link', async ({umbracoApi, umbr await umbracoUi.content.clickAddMultiURLPickerButton(); await umbracoUi.content.clickLinkToDocumentButton(); await umbracoUi.content.selectLinkByName(linkedDocumentName); - await umbracoUi.content.clickChooseModalButton(); + await umbracoUi.content.clickButtonWithName('Choose'); await umbracoUi.content.clickSubmitButton(); await umbracoUi.content.clickSaveAndPublishButton(); @@ -133,8 +135,7 @@ test('can create content with the external link', async ({umbracoApi, umbracoUi} expect(contentData.values[0].value[0].url).toEqual(link); }); -// TODO: Remove skip when the code is updated due to UI changes -test.skip('can create content with the media link', async ({umbracoApi, umbracoUi}) => { +test('can create content with the media link', async ({umbracoApi, umbracoUi}) => { // Arrange const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id); @@ -149,7 +150,10 @@ test.skip('can create content with the media link', async ({umbracoApi, umbracoU // Act await umbracoUi.content.goToContentWithName(contentName); await umbracoUi.content.clickAddMultiURLPickerButton(); - await umbracoUi.content.selectLinkByName(mediaFileName); + await umbracoUi.content.clickLinkToMediaButton(); + await umbracoUi.content.selectMediaWithName(mediaFileName); + await umbracoUi.content.clickMediaPickerModalSubmitButton(); + await umbracoUi.waitForTimeout(500); await umbracoUi.content.clickSubmitButton(); await umbracoUi.content.clickSaveButton(); @@ -169,8 +173,7 @@ test.skip('can create content with the media link', async ({umbracoApi, umbracoU await umbracoApi.media.ensureNameNotExists(mediaFileName); }); -// TODO: Remove skip when the code is updated due to UI changes -test.skip('can add multiple links in the content', async ({umbracoApi, umbracoUi}) => { +test('can add multiple links in the content', async ({umbracoApi, umbracoUi}) => { // Arrange const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id); @@ -186,7 +189,10 @@ test.skip('can add multiple links in the content', async ({umbracoApi, umbracoUi await umbracoUi.content.goToContentWithName(contentName); // Add media link await umbracoUi.content.clickAddMultiURLPickerButton(); - await umbracoUi.content.selectLinkByName(mediaFileName); + await umbracoUi.content.clickLinkToMediaButton(); + await umbracoUi.content.selectMediaWithName(mediaFileName); + await umbracoUi.content.clickMediaPickerModalSubmitButton(); + await umbracoUi.waitForTimeout(500); await umbracoUi.content.clickSubmitButton(); // Add external link await umbracoUi.content.clickAddMultiURLPickerButton(); @@ -224,7 +230,7 @@ test('can remove the URL picker in the content', async ({umbracoApi, umbracoUi}) await umbracoApi.document.createDocumentWithExternalLinkURLPicker(contentName, documentTypeId, link, linkTitle); await umbracoUi.goToBackOffice(); await umbracoUi.content.goToSection(ConstantHelper.sections.content); - + // Act await umbracoUi.content.goToContentWithName(contentName); await umbracoUi.content.removeUrlPickerByName(linkTitle); @@ -237,8 +243,7 @@ test('can remove the URL picker in the content', async ({umbracoApi, umbracoUi}) expect(contentData.values).toEqual([]); }); -// TODO: Remove skip when the code is updated due to UI changes -test.skip('can edit the URL picker in the content', async ({umbracoApi, umbracoUi}) => { +test('can edit the URL picker in the content', async ({umbracoApi, umbracoUi}) => { // Arrange const updatedLinkTitle = 'Updated Umbraco Documentation'; const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); @@ -246,10 +251,10 @@ test.skip('can edit the URL picker in the content', async ({umbracoApi, umbracoU await umbracoApi.document.createDocumentWithExternalLinkURLPicker(contentName, documentTypeId, link, linkTitle); await umbracoUi.goToBackOffice(); await umbracoUi.content.goToSection(ConstantHelper.sections.content); - + // Act await umbracoUi.content.goToContentWithName(contentName); - await umbracoUi.content.clickEditUrlPickerButtonByName(linkTitle); + await umbracoUi.content.clickLinkWithName(linkTitle); await umbracoUi.content.enterLinkTitle(updatedLinkTitle); await umbracoUi.content.clickSubmitButton(); await umbracoUi.content.clickSaveButton(); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/CultureAndHostnames.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/CultureAndHostnames.spec.ts index d006dc8e07..2f4b301ea9 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/CultureAndHostnames.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/CultureAndHostnames.spec.ts @@ -109,6 +109,7 @@ test('can add culture and hostname for multiple languages', async ({umbracoApi, // Act await umbracoUi.content.clickActionsMenuForContent(contentName); await umbracoUi.content.clickCultureAndHostnamesButton(); + await umbracoUi.waitForTimeout(500); await umbracoUi.content.clickAddNewDomainButton(); await umbracoUi.content.enterDomain(domainName, 0); await umbracoUi.content.selectDomainLanguageOption(languageName, 0); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/DataType/DataType.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/DataType/DataType.spec.ts index cf3b771973..12fddb5d0c 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/DataType/DataType.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/DataType/DataType.spec.ts @@ -1,4 +1,4 @@ -import {test} from '@umbraco/playwright-testhelpers'; +import {NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers'; import {expect} from "@playwright/test"; const dataTypeName = 'TestDataType'; @@ -24,7 +24,7 @@ test('can create a data type', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) await umbracoUi.dataType.clickSaveButton(); // Assert - await umbracoUi.dataType.isSuccessNotificationVisible(); + await umbracoUi.dataType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.dataType.doesNameExist(dataTypeName)).toBeTruthy(); }); @@ -41,6 +41,7 @@ test('can rename a data type', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) await umbracoUi.dataType.clickSaveButton(); // Assert + await umbracoUi.dataType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); expect(await umbracoApi.dataType.doesNameExist(dataTypeName)).toBeTruthy(); expect(await umbracoApi.dataType.doesNameExist(wrongDataTypeName)).toBeFalsy(); }); @@ -55,7 +56,7 @@ test('can delete a data type', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) await umbracoUi.dataType.deleteDataType(dataTypeName); // Assert - await umbracoUi.dataType.isSuccessNotificationVisible(); + await umbracoUi.dataType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.deleted); expect(await umbracoApi.dataType.doesNameExist(dataTypeName)).toBeFalsy(); }); @@ -75,6 +76,7 @@ test('can change property editor in a data type', {tag: '@smoke'}, async ({umbra await umbracoUi.dataType.clickSaveButton(); // Assert + await umbracoUi.dataType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); expect(await umbracoApi.dataType.doesNameExist(dataTypeName)).toBeTruthy(); const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); expect(dataTypeData.editorAlias).toBe(updatedEditorAlias); @@ -110,7 +112,7 @@ test('can change settings', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => await umbracoUi.dataType.clickSaveButton(); // Assert - await umbracoUi.dataType.isSuccessNotificationVisible(); + await umbracoUi.dataType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); expect(dataTypeData.values).toContainEqual(expectedDataTypeValues); }); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/DataType/DataTypeFolder.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/DataType/DataTypeFolder.spec.ts index 83606f4da1..ce7983581d 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/DataType/DataTypeFolder.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/DataType/DataTypeFolder.spec.ts @@ -1,4 +1,4 @@ -import {test} from '@umbraco/playwright-testhelpers'; +import {NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers'; import {expect} from "@playwright/test"; const dataTypeName = 'TestDataType'; @@ -23,6 +23,7 @@ test('can create a data type folder', async ({umbracoApi, umbracoUi}) => { await umbracoUi.dataType.createFolder(dataTypeFolderName); // Assert + await umbracoUi.dataType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.dataType.doesNameExist(dataTypeFolderName)).toBeTruthy(); }); @@ -41,6 +42,7 @@ test('can rename a data type folder', async ({umbracoApi, umbracoUi}) => { await umbracoUi.dataType.clickConfirmRenameFolderButton(); // Assert + await umbracoUi.dataType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); expect(await umbracoApi.dataType.doesNameExist(dataTypeFolderName)).toBeTruthy(); expect(await umbracoApi.dataType.doesNameExist(wrongDataTypeFolderName)).toBeFalsy(); }); @@ -55,6 +57,7 @@ test('can delete a data type folder', {tag: '@smoke'}, async ({umbracoApi, umbra await umbracoUi.dataType.deleteDataTypeFolder(dataTypeFolderName); // Assert + await umbracoUi.dataType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.deleted); expect(await umbracoApi.dataType.doesFolderExist(dataTypeFolderName)).toBeFalsy(); }); @@ -75,6 +78,7 @@ test('can create a data type in a folder', async ({umbracoApi, umbracoUi}) => { await umbracoUi.dataType.clickSaveButton(); // Assert + await umbracoUi.dataType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.dataType.doesNameExist(dataTypeName)).toBeTruthy(); const dataTypeChildren = await umbracoApi.dataType.getChildren(dataTypeFolderId); expect(dataTypeChildren[0].name).toBe(dataTypeName); @@ -94,6 +98,7 @@ test('can create a folder in a folder', async ({umbracoApi, umbracoUi}) => { await umbracoUi.dataType.createFolder(childFolderName); // Assert + await umbracoUi.dataType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.dataType.doesNameExist(childFolderName)).toBeTruthy(); const dataTypeChildren = await umbracoApi.dataType.getChildren(dataTypeFolderId); expect(dataTypeChildren[0].name).toBe(childFolderName); @@ -114,7 +119,7 @@ test('can create a folder in a folder in a folder', async ({umbracoApi, umbracoU await umbracoUi.dataType.createFolder(childOfChildFolderName); // Assert - await umbracoUi.dataType.isSuccessNotificationVisible(); + await umbracoUi.dataType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.dataType.doesNameExist(childOfChildFolderName)).toBeTruthy(); const childrenFolderData = await umbracoApi.dataType.getChildren(childFolderId); expect(childrenFolderData[0].name).toBe(childOfChildFolderName); @@ -135,7 +140,7 @@ test('cannot delete a non-empty data type folder', async ({umbracoApi, umbracoUi await umbracoUi.dataType.deleteDataTypeFolder(dataTypeFolderName); // Assert - await umbracoUi.dataType.isErrorNotificationVisible(); + await umbracoUi.dataType.doesErrorNotificationHaveText(NotificationConstantHelper.error.notEmptyFolder); expect(await umbracoApi.dataType.doesNameExist(dataTypeName)).toBeTruthy(); expect(await umbracoApi.dataType.doesNameExist(dataTypeFolderName)).toBeTruthy(); const dataTypeChildren = await umbracoApi.dataType.getChildren(dataTypeFolderId); @@ -161,7 +166,7 @@ test('can move a data type to a data type folder', async ({umbracoApi, umbracoUi await umbracoUi.dataType.moveDataTypeToFolder(dataTypeFolderName); // Assert - await umbracoUi.dataType.isSuccessNotificationVisible(); + await umbracoUi.dataType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.moved); const dataTypeInFolder = await umbracoApi.dataType.getChildren(dataTypeFolderId); expect(dataTypeInFolder[0].id).toEqual(dataTypeId); @@ -184,7 +189,7 @@ test('can duplicate a data type to a data type folder', async ({umbracoApi, umbr await umbracoUi.dataType.duplicateDataTypeToFolder(dataTypeFolderName); // Assert - await umbracoUi.dataType.isSuccessNotificationVisible(); + await umbracoUi.dataType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.duplicated); const dataTypeInFolder = await umbracoApi.dataType.getChildren(dataTypeFolderId); expect(dataTypeInFolder[0].name).toEqual(dataTypeName + ' (copy)'); expect(await umbracoApi.dataType.doesNameExist(dataTypeName)).toBeTruthy(); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/DataType/ListView.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/DataType/ListView.spec.ts index ce0e66668c..83f4f03cc7 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/DataType/ListView.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/DataType/ListView.spec.ts @@ -216,8 +216,7 @@ for (const listViewType of listViewTypes) { expect(dataTypeData.values).toContainEqual(expectedDataTypeValues); }); - // Skip this test as there is no setting for content app icon - test.skip('can update content app icon', async ({umbracoApi, umbracoUi}) => { + test('can update workspace view icon', async ({umbracoApi, umbracoUi}) => { // Arrange const iconValue = 'icon-activity'; const expectedDataTypeValues = { @@ -227,8 +226,8 @@ for (const listViewType of listViewTypes) { // Act await umbracoUi.dataType.goToDataType(listViewType); - await umbracoUi.dataType.clickContentAppIconButton(); - await umbracoUi.dataType.chooseContentAppIconByValue(iconValue); + await umbracoUi.dataType.clickSelectIconButton(); + await umbracoUi.dataType.chooseWorkspaceViewIconByValue(iconValue); await umbracoUi.dataType.clickSaveButton(); // Assert @@ -236,18 +235,17 @@ for (const listViewType of listViewTypes) { expect(dataTypeData.values).toContainEqual(expectedDataTypeValues); }); - // Skip this test as there is no setting for content app icon - test.skip('can update content app name', async ({umbracoApi, umbracoUi}) => { + test('can update workspace view name', async ({umbracoApi, umbracoUi}) => { // Arrange - const contentAppName = 'Test Content App Name'; + const WorkspaceViewName = 'Test Content Name'; const expectedDataTypeValues = { "alias": "tabName", - "value": contentAppName + "value": WorkspaceViewName }; // Act await umbracoUi.dataType.goToDataType(listViewType); - await umbracoUi.dataType.enterContentAppName(contentAppName); + await umbracoUi.dataType.enterWorkspaceViewName(WorkspaceViewName); await umbracoUi.dataType.clickSaveButton(); // Assert @@ -255,8 +253,7 @@ for (const listViewType of listViewTypes) { expect(dataTypeData.values).toContainEqual(expectedDataTypeValues); }); - // Skip this test as there is no setting for content app icon - test.skip('can enable show content app first', async ({umbracoApi, umbracoUi}) => { + test('can enable show content workspace view first', async ({umbracoApi, umbracoUi}) => { // Arrange const expectedDataTypeValues = { "alias": "showContentFirst", @@ -265,7 +262,7 @@ for (const listViewType of listViewTypes) { // Act await umbracoUi.dataType.goToDataType(listViewType); - await umbracoUi.dataType.clickShowContentAppFirstSlider(); + await umbracoUi.dataType.clickShowContentWorkspaceViewFirstSlider(); await umbracoUi.dataType.clickSaveButton(); // Assert diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Dictionary/Dictionary.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Dictionary/Dictionary.spec.ts index c475d31e01..dc2c2cc8f0 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Dictionary/Dictionary.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Dictionary/Dictionary.spec.ts @@ -1,4 +1,4 @@ -import {ConstantHelper, test} from '@umbraco/playwright-testhelpers'; +import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers'; import {expect} from "@playwright/test"; const dictionaryName = 'TestDictionaryItem'; @@ -24,7 +24,7 @@ test('can create a dictionary item', async ({umbracoApi, umbracoUi}) => { // Assert expect(await umbracoApi.dictionary.doesNameExist(dictionaryName)).toBeTruthy(); - await umbracoUi.dictionary.isSuccessNotificationVisible(); + await umbracoUi.dictionary.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); await umbracoUi.dictionary.clickLeftArrowButton(); // Verify the dictionary item displays in the tree and in the list await umbracoUi.dictionary.isDictionaryTreeItemVisible(dictionaryName); @@ -42,7 +42,7 @@ test('can delete a dictionary item', async ({umbracoApi, umbracoUi}) => { await umbracoUi.dictionary.deleteDictionary(); // Assert - await umbracoUi.dictionary.isSuccessNotificationVisible(); + await umbracoUi.dictionary.doesSuccessNotificationHaveText(NotificationConstantHelper.success.deleted); expect(await umbracoApi.dictionary.doesNameExist(dictionaryName)).toBeFalsy(); // Verify the dictionary item does not display in the tree await umbracoUi.dictionary.isDictionaryTreeItemVisible(dictionaryName, false); @@ -66,7 +66,7 @@ test('can create a dictionary item in a dictionary', {tag: '@smoke'}, async ({um await umbracoUi.dictionary.clickSaveButton(); // Assert - await umbracoUi.dictionary.isSuccessNotificationVisible(); + await umbracoUi.dictionary.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); const dictionaryChildren = await umbracoApi.dictionary.getChildren(parentDictionaryId); expect(dictionaryChildren[0].name).toEqual(dictionaryName); await umbracoUi.dictionary.clickLeftArrowButton(); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Media/ListViewMedia.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Media/ListViewMedia.spec.ts new file mode 100644 index 0000000000..f28ae14ca0 --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Media/ListViewMedia.spec.ts @@ -0,0 +1,160 @@ +import {expect} from '@playwright/test'; +import {ConstantHelper, test} from '@umbraco/playwright-testhelpers'; + +const dataTypeName = 'List View - Media'; +let dataTypeDefaultData = null; +const firstMediaFileName = 'FirstMediaFile'; +const secondMediaFileName = 'SecondMediaFile'; + +test.beforeEach(async ({umbracoUi, umbracoApi}) => { + dataTypeDefaultData = await umbracoApi.dataType.getByName(dataTypeName); + await umbracoApi.media.ensureNameNotExists(firstMediaFileName); + await umbracoApi.media.ensureNameNotExists(secondMediaFileName); + await umbracoApi.media.createDefaultMediaFile(firstMediaFileName); + await umbracoApi.media.createDefaultMediaFile(secondMediaFileName); + await umbracoUi.goToBackOffice(); +}); + +test.afterEach(async ({umbracoApi}) => { + if (dataTypeDefaultData !== null) { + await umbracoApi.dataType.update(dataTypeDefaultData.id, dataTypeDefaultData); + } + await umbracoApi.media.ensureNameNotExists(firstMediaFileName); + await umbracoApi.media.ensureNameNotExists(secondMediaFileName); + await umbracoApi.media.emptyRecycleBin(); +}); + +test('can change the the default sort order for the list in the media section', async ({umbracoApi, umbracoUi}) => { + // Arrange + const sortOrder = 'creator'; + const expectedMediaValues = await umbracoApi.media.getAllMediaNames(sortOrder); + + // Act + await umbracoApi.dataType.updateListViewMediaDataType('orderBy', sortOrder); + await umbracoUi.media.goToSection(ConstantHelper.sections.media); + await umbracoUi.media.changeToListView(); + await umbracoUi.waitForTimeout(500); + + // Assert + await umbracoUi.media.isMediaListViewVisible(); + await umbracoUi.media.doesMediaListNameValuesMatch(expectedMediaValues); +}); + +test('can change the the order direction for the list in the media section', async ({umbracoApi, umbracoUi}) => { + // Arrange + const expectedMediaValues = await umbracoApi.media.getAllMediaNames('updateDate', 'Ascending'); + + // Act + await umbracoApi.dataType.updateListViewMediaDataType('orderDirection', 'asc'); + await umbracoUi.media.goToSection(ConstantHelper.sections.media); + + // Assert + await umbracoUi.media.isMediaGridViewVisible(); + await umbracoUi.media.doesMediaGridValuesMatch(expectedMediaValues); + await umbracoUi.media.changeToListView(); + await umbracoUi.waitForTimeout(500); + await umbracoUi.media.isMediaListViewVisible(); + await umbracoUi.media.doesMediaListNameValuesMatch(expectedMediaValues); +}); + +test('can add more columns to the list in the media section', async ({umbracoApi, umbracoUi}) => { + // Arrange + const expectedColumns = ['Name', 'Last edited', 'Updated by', 'Size']; + const updatedValue = [ + {"alias": "updateDate", "header": "Last edited", "isSystem": true}, + {"alias": "creator", "header": "Updated by", "isSystem": true}, + {"alias": "umbracoBytes", "header": "Size", "isSystem": 0} + ]; + + // Act + await umbracoApi.dataType.updateListViewMediaDataType('includeProperties', updatedValue); + await umbracoUi.media.goToSection(ConstantHelper.sections.media); + await umbracoUi.media.changeToListView(); + await umbracoUi.waitForTimeout(500); + + // Assert + await umbracoUi.media.isMediaListViewVisible(); + await umbracoUi.media.doesMediaListHeaderValuesMatch(expectedColumns); +}); + +test('can disable one view in the media section', async ({umbracoApi, umbracoUi}) => { + // Arrange + const updatedValue = [ + { + "name": "List", + "collectionView": "Umb.CollectionView.Media.Table", + "icon": "icon-list", + "isSystem": true, + "selected": true + } + ]; + + // Act + await umbracoApi.dataType.updateListViewMediaDataType('layouts', updatedValue); + await umbracoUi.media.goToSection(ConstantHelper.sections.media); + + // Assert + await umbracoUi.media.isViewBundleButtonVisible(false); + await umbracoUi.media.isMediaListViewVisible(); + await umbracoUi.media.isMediaGridViewVisible(false); +}); + +test('can allow bulk trash in the media section', async ({umbracoApi, umbracoUi}) => { + // Arrange + const updatedValue = { + "allowBulkPublish": false, + "allowBulkUnpublish": false, + "allowBulkCopy": false, + "allowBulkDelete": true, + "allowBulkMove": false + }; + + // Act + await umbracoApi.dataType.updateListViewMediaDataType('bulkActionPermissions', updatedValue); + await umbracoUi.media.goToSection(ConstantHelper.sections.media); + await umbracoUi.media.selectMediaByName(firstMediaFileName); + await umbracoUi.media.selectMediaByName(secondMediaFileName); + await umbracoUi.media.clickBulkTrashButton(); + await umbracoUi.media.clickConfirmTrashButton(); + + // Assert + await umbracoUi.media.reloadMediaTree(); + expect(await umbracoApi.media.doesNameExist(firstMediaFileName)).toBeFalsy(); + expect(await umbracoApi.media.doesNameExist(secondMediaFileName)).toBeFalsy(); + expect(await umbracoApi.media.doesMediaItemExistInRecycleBin(firstMediaFileName)).toBeTruthy(); + expect(await umbracoApi.media.doesMediaItemExistInRecycleBin(secondMediaFileName)).toBeTruthy(); + await umbracoUi.media.isItemVisibleInRecycleBin(firstMediaFileName); + await umbracoUi.media.isItemVisibleInRecycleBin(secondMediaFileName, true, false); +}); + +test('can allow bulk move in the media section', async ({umbracoApi, umbracoUi}) => { + // Arrange + const mediaFolderName = 'Test Folder Name'; + const updatedValue = { + "allowBulkPublish": false, + "allowBulkUnpublish": false, + "allowBulkCopy": false, + "allowBulkDelete": false, + "allowBulkMove": true + }; + await umbracoApi.media.ensureNameNotExists(mediaFolderName); + const mediaFolderId = await umbracoApi.media.createDefaultMediaFolder(mediaFolderName); + + // Act + await umbracoApi.dataType.updateListViewMediaDataType('bulkActionPermissions', updatedValue); + await umbracoUi.media.goToSection(ConstantHelper.sections.media); + await umbracoUi.media.selectMediaByName(firstMediaFileName); + await umbracoUi.media.selectMediaByName(secondMediaFileName); + await umbracoUi.media.clickBulkMoveToButton(); + await umbracoUi.media.clickCaretButtonForName('Media'); + await umbracoUi.media.clickModalTextByName(mediaFolderName); + await umbracoUi.media.clickChooseModalButton(); + + // Assert + await umbracoUi.media.isSuccessNotificationVisible(); + expect(await umbracoApi.media.doesMediaItemHaveChildName(mediaFolderId, firstMediaFileName)).toBeTruthy(); + expect(await umbracoApi.media.doesMediaItemHaveChildName(mediaFolderId, secondMediaFileName)).toBeTruthy(); + + // Clean + await umbracoApi.media.ensureNameNotExists(mediaFolderName); +}); 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 dfc1cb9630..266bf7b2db 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Media/Media.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Media/Media.spec.ts @@ -1,4 +1,4 @@ -import {ConstantHelper, test} from '@umbraco/playwright-testhelpers'; +import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers'; import {expect} from '@playwright/test'; const mediaFileName = 'TestMediaFile'; @@ -27,7 +27,7 @@ test.skip('can not create a empty media file', async ({umbracoApi, umbracoUi}) = // Assert await umbracoUi.media.isErrorNotificationVisible(); - await umbracoUi.media.isTreeItemVisible(mediaFileName, false); + await umbracoUi.media.isMediaTreeItemVisible(mediaFileName, false); expect(await umbracoApi.media.doesNameExist(mediaFileName)).toBeFalsy(); }); @@ -45,8 +45,8 @@ test('can rename a media file', async ({umbracoApi, umbracoUi}) => { await umbracoUi.media.clickSaveButton(); // Assert - await umbracoUi.media.isSuccessNotificationVisible(); - await umbracoUi.media.isTreeItemVisible(mediaFileName); + await umbracoUi.media.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + await umbracoUi.media.isMediaTreeItemVisible(mediaFileName); expect(await umbracoApi.media.doesNameExist(mediaFileName)).toBeTruthy(); }); @@ -73,8 +73,9 @@ for (const mediaFileType of mediaFileTypes) { await umbracoUi.media.clickSaveButton(); // Assert - await umbracoUi.media.isSuccessNotificationVisible(); - await umbracoUi.media.isTreeItemVisible(mediaFileType.fileName); + await umbracoUi.media.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); + await umbracoUi.media.reloadMediaTree(); + await umbracoUi.media.isMediaTreeItemVisible(mediaFileType.fileName); expect(await umbracoApi.media.doesNameExist(mediaFileType.fileName)).toBeTruthy(); // Clean @@ -94,8 +95,8 @@ test('can create a folder', async ({umbracoApi, umbracoUi}) => { await umbracoUi.media.clickSaveButton(); // Assert - await umbracoUi.media.isSuccessNotificationVisible(); - await umbracoUi.media.isTreeItemVisible(folderName); + await umbracoUi.media.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); + await umbracoUi.media.isMediaTreeItemVisible(folderName); expect(await umbracoApi.media.doesNameExist(folderName)).toBeTruthy(); // Clean @@ -134,10 +135,11 @@ test('can create a folder in a folder', async ({umbracoApi, umbracoUi}) => { await umbracoUi.media.clickSaveButton(); // Assert - await umbracoUi.media.isSuccessNotificationVisible(); - await umbracoUi.media.isTreeItemVisible(parentFolderName); + await umbracoUi.media.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); + await umbracoUi.media.isMediaTreeItemVisible(parentFolderName); + await umbracoUi.media.isMediaTreeItemVisible(folderName, false); await umbracoUi.media.clickMediaCaretButtonForName(parentFolderName); - await umbracoUi.media.isTreeItemVisible(folderName); + await umbracoUi.media.isMediaTreeItemVisible(folderName, true); // Clean await umbracoApi.media.ensureNameNotExists(parentFolderName); @@ -175,6 +177,7 @@ test('can trash a media item', async ({umbracoApi, umbracoUi}) => { await umbracoUi.media.clickConfirmTrashButton(); // Assert + await umbracoUi.media.doesSuccessNotificationHaveText(NotificationConstantHelper.success.movedToRecycleBin); await umbracoUi.media.isItemVisibleInRecycleBin(mediaFileName); expect(await umbracoApi.media.doesNameExist(mediaFileName)).toBeFalsy(); expect(await umbracoApi.media.doesMediaItemExistInRecycleBin(mediaFileName)).toBeTruthy(); @@ -195,9 +198,10 @@ test('can restore a media item from the recycle bin', async ({umbracoApi, umbrac await umbracoUi.media.restoreMediaItem(mediaFileName); // Assert + await umbracoUi.media.doesSuccessNotificationHaveText(NotificationConstantHelper.success.restored); await umbracoUi.media.isItemVisibleInRecycleBin(mediaFileName, false); await umbracoUi.media.reloadMediaTree(); - await umbracoUi.media.isTreeItemVisible(mediaFileName); + await umbracoUi.media.isMediaTreeItemVisible(mediaFileName); expect(await umbracoApi.media.doesNameExist(mediaFileName)).toBeTruthy(); expect(await umbracoApi.media.doesMediaItemExistInRecycleBin(mediaFileName)).toBeFalsy(); @@ -217,6 +221,7 @@ test('can delete a media item from the recycle bin', async ({umbracoApi, umbraco await umbracoUi.media.deleteMediaItem(mediaFileName); // Assert + await umbracoUi.media.doesSuccessNotificationHaveText(NotificationConstantHelper.success.deleted); await umbracoUi.media.isItemVisibleInRecycleBin(mediaFileName, false); expect(await umbracoApi.media.doesNameExist(mediaFileName)).toBeFalsy(); expect(await umbracoApi.media.doesMediaItemExistInRecycleBin(mediaFileName)).toBeFalsy(); @@ -236,6 +241,7 @@ test('can empty the recycle bin', async ({umbracoApi, umbracoUi}) => { // Assert await umbracoUi.media.isItemVisibleInRecycleBin(mediaFileName, false); + await umbracoUi.media.doesSuccessNotificationHaveText(NotificationConstantHelper.success.emptiedRecycleBin); expect(await umbracoApi.media.doesNameExist(mediaFileName)).toBeFalsy(); expect(await umbracoApi.media.doesMediaItemExistInRecycleBin(mediaFileName)).toBeFalsy(); }); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Members/MemberGroups.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Members/MemberGroups.spec.ts index 0ca851097b..afbe007ac6 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Members/MemberGroups.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Members/MemberGroups.spec.ts @@ -1,4 +1,4 @@ -import {test} from '@umbraco/playwright-testhelpers'; +import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers'; import {expect} from "@playwright/test"; const memberGroupName = 'Test Member Group'; @@ -20,7 +20,7 @@ test('can create a member group', {tag: '@smoke'}, async ({umbracoApi, umbracoUi await umbracoUi.memberGroup.clickSaveButton(); // Assert - await umbracoUi.memberGroup.isSuccessNotificationVisible(); + await umbracoUi.memberGroup.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); await umbracoUi.memberGroup.clickLeftArrowButton(); await umbracoUi.memberGroup.isMemberGroupNameVisible(memberGroupName); expect(await umbracoApi.memberGroup.doesNameExist(memberGroupName)).toBeTruthy(); @@ -32,7 +32,7 @@ test('cannot create member group with empty name', async ({umbracoApi, umbracoUi await umbracoUi.memberGroup.clickSaveButton(); // Assert - await umbracoUi.memberGroup.isErrorNotificationVisible(); + await umbracoUi.memberGroup.doesErrorNotificationHaveText(NotificationConstantHelper.error.emptyName); expect(await umbracoApi.memberGroup.doesNameExist(memberGroupName)).toBeFalsy(); }); @@ -47,7 +47,7 @@ test('cannot create member group with duplicate name', async ({umbracoApi, umbra await umbracoUi.memberGroup.clickSaveButton(); // Assert - await umbracoUi.memberGroup.isErrorNotificationVisible(); + await umbracoUi.memberGroup.doesErrorNotificationHaveText(NotificationConstantHelper.error.duplicateName); }); test('can delete a member group', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => { diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Members/Members.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Members/Members.spec.ts index 955c667bfb..61f30db521 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Members/Members.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Members/Members.spec.ts @@ -1,4 +1,4 @@ -import {ConstantHelper, test} from '@umbraco/playwright-testhelpers'; +import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers'; import {expect} from "@playwright/test"; let memberId = ''; @@ -38,7 +38,7 @@ test('can create a member', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => await umbracoUi.member.clickSaveButton(); // Assert - await umbracoUi.member.isSuccessNotificationVisible(); + await umbracoUi.member.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.member.doesNameExist(memberName)).toBeTruthy(); }); @@ -54,7 +54,7 @@ test('can edit comments', async ({umbracoApi, umbracoUi}) => { await umbracoUi.member.clickSaveButton(); // Assert - await umbracoUi.member.isSuccessNotificationVisible(); + await umbracoUi.member.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const memberData = await umbracoApi.member.get(memberId); expect(memberData.values[0].value).toBe(comment); }); @@ -72,7 +72,7 @@ test('can edit username', async ({umbracoApi, umbracoUi}) => { await umbracoUi.member.clickSaveButton(); // Assert - await umbracoUi.member.isSuccessNotificationVisible(); + await umbracoUi.member.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const memberData = await umbracoApi.member.get(memberId); expect(memberData.username).toBe(updatedUsername); }); @@ -90,7 +90,7 @@ test('can edit email', async ({umbracoApi, umbracoUi}) => { await umbracoUi.member.clickSaveButton(); // Assert - await umbracoUi.member.isSuccessNotificationVisible(); + await umbracoUi.member.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const memberData = await umbracoApi.member.get(memberId); expect(memberData.email).toBe(updatedEmail); }); @@ -110,7 +110,7 @@ test('can edit password', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => { await umbracoUi.member.clickSaveButton(); // Assert - await umbracoUi.member.isSuccessNotificationVisible(); + await umbracoUi.member.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); }); test('can add member group', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => { @@ -128,7 +128,7 @@ test('can add member group', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => await umbracoUi.member.clickSaveButton(); // Assert - await umbracoUi.member.isSuccessNotificationVisible(); + await umbracoUi.member.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const memberData = await umbracoApi.member.get(memberId); expect(memberData.groups[0]).toBe(memberGroupId); @@ -152,7 +152,7 @@ test('can remove member group', async ({umbracoApi, umbracoUi}) => { await umbracoUi.member.clickSaveButton(); // Assert - await umbracoUi.member.isSuccessNotificationVisible(); + await umbracoUi.member.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const memberData = await umbracoApi.member.get(memberId); expect(memberData.groups.length).toBe(0); @@ -196,7 +196,7 @@ test('can enable approved', async ({umbracoApi, umbracoUi}) => { await umbracoUi.member.clickSaveButton(); // Assert - await umbracoUi.member.isSuccessNotificationVisible(); + await umbracoUi.member.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const memberData = await umbracoApi.member.get(memberId); expect(memberData.isApproved).toBe(true); }); @@ -206,7 +206,7 @@ test('can delete member', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => { memberTypeId = await umbracoApi.memberType.createDefaultMemberType(memberTypeName); memberId = await umbracoApi.member.createDefaultMember(memberName, memberTypeId, email, username, password); await umbracoUi.member.goToMembers(); - + // Act await umbracoUi.member.clickMemberLinkByName(memberName); await umbracoUi.memberGroup.clickActionsButton(); @@ -214,7 +214,7 @@ test('can delete member', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => { await umbracoUi.memberGroup.clickConfirmToDeleteButton(); // Assert - await umbracoUi.member.isSuccessNotificationVisible(); + await umbracoUi.member.doesSuccessNotificationHaveText(NotificationConstantHelper.success.deleted); expect(await umbracoApi.member.doesNameExist(memberName)).toBeFalsy(); }); @@ -235,7 +235,7 @@ test('cannot create member with invalid email', async ({umbracoApi, umbracoUi}) await umbracoUi.member.clickSaveButton(); // Assert - await umbracoUi.member.isErrorNotificationVisible(); + await umbracoUi.member.doesErrorNotificationHaveText(NotificationConstantHelper.error.invalidEmail); expect(await umbracoApi.member.doesNameExist(memberName)).toBeFalsy(); }); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Packages/CreatedPackages.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Packages/CreatedPackages.spec.ts index 0b72f77f0c..a0073862ae 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Packages/CreatedPackages.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Packages/CreatedPackages.spec.ts @@ -1,373 +1,347 @@ -import {ConstantHelper, test} from '@umbraco/playwright-testhelpers'; -import {expect} from '@playwright/test'; -import * as fs from 'fs'; - -const packageName = 'TestPackage'; - -test.beforeEach(async ({umbracoApi, umbracoUi}) => { - await umbracoApi.package.ensureNameNotExists(packageName); - await umbracoUi.goToBackOffice(); - await umbracoUi.package.goToSection(ConstantHelper.sections.packages); - await umbracoUi.package.clickCreatedTab(); -}); - -test.afterEach(async ({umbracoApi}) => { - await umbracoApi.package.ensureNameNotExists(packageName); -}); - -test.skip('can create a empty package', {tag: '@smoke'}, async ({umbracoUi}) => { - // Act - await umbracoUi.package.clickCreatePackageButton(); - await umbracoUi.package.enterPackageName(packageName); - await umbracoUi.package.clickSaveChangesToPackageButton(); - - // Assert - await umbracoUi.package.isPackageNameVisible(packageName); -}); - -test.skip('can update package name', async ({umbracoApi, umbracoUi}) => { - // Arrange - const wrongPackageName = 'WrongPackageName'; - await umbracoApi.package.ensureNameNotExists(wrongPackageName); - await umbracoApi.package.createEmptyPackage(wrongPackageName); - await umbracoUi.reloadPage(); - - // Act - await umbracoUi.package.clickExistingPackageName(wrongPackageName); - await umbracoUi.package.enterPackageName(packageName); - await umbracoUi.package.clickSaveChangesToPackageButton(); - - // Assert - await umbracoUi.package.isPackageNameVisible(packageName); - expect(umbracoApi.package.doesNameExist(packageName)).toBeTruthy(); -}); - -test.skip('can delete a package', async ({umbracoApi, umbracoUi}) => { - // Arrange - await umbracoApi.package.createEmptyPackage(packageName); - await umbracoUi.reloadPage(); - - // Act - await umbracoUi.package.clickDeleteButtonForPackageName(packageName); - await umbracoUi.package.clickDeleteExactLabel(); - - // Assert - await umbracoUi.package.isPackageNameVisible(packageName, false); - expect(await umbracoApi.package.doesNameExist(packageName)).toBeFalsy(); -}); - -// TODO: Update the locators for the choose button. If it is updated or not -// TODO: Remove .skip when the test is able to run. Currently it is not possible to add content to a package -test.skip('can create a package with content', async ({page, umbracoApi, umbracoUi}) => { - // Arrange - const documentTypeName = 'TestDocumentType'; - const documentName = 'TestDocument'; - await umbracoApi.documentType.ensureNameNotExists(documentTypeName); - await umbracoApi.package.createEmptyPackage(packageName); - const documentTypeId = await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(documentTypeName); - const documentId = await umbracoApi.document.createDefaultDocument(documentName, documentTypeId); - await umbracoUi.reloadPage(); - - // Act - await umbracoUi.package.clickExistingPackageName(packageName); - // The frontend has updated the button name to "Choose" of "Add". But they are a bit unsure if they want to change it to select instead. - // So for the moment I have used the page instead of our UiHelper. Because it is easier to change the locator. - // await umbracoUi.package.clickAddContentToPackageButton(); - await page.locator('[label="Content"] >> [label="Choose"]').click(); - await umbracoUi.package.clickLabelWithName(documentName); - await umbracoUi.package.clickChooseBtn(); - await umbracoUi.package.clickSaveChangesToPackageButton(); - - // Assert - const packageData = await umbracoApi.package.getByName(packageName); - expect(packageData.contentNodeId == documentId).toBeTruthy(); - await umbracoUi.package.clickExistingPackageName(packageName); - expect(umbracoUi.package.isButtonWithNameVisible(documentName + ' ' + documentId)).toBeTruthy(); - - // Clean - await umbracoApi.documentType.ensureNameNotExists(documentTypeName); -}); - -// Currently unable to run this test. Because you are not able to save a mediaId -test.skip('can create a package with media', async ({umbracoApi, umbracoUi}) => { - // Arrange - const mediaTypeName = 'TestMediaType'; - const mediaName = 'TestMedia'; - await umbracoApi.mediaType.ensureNameNotExists(mediaTypeName); - await umbracoApi.package.createEmptyPackage(packageName); - const mediaTypeId = await umbracoApi.mediaType.createDefaultMediaType(mediaTypeName); - const mediaId = await umbracoApi.media.createDefaultMedia(mediaName, mediaTypeId); - await umbracoUi.reloadPage(); - - // Act - await umbracoUi.package.clickExistingPackageName(packageName); - await umbracoUi.package.clickAddMediaToPackageButton(); - await umbracoUi.package.clickCaretButton(); - await umbracoUi.package.clickLabelWithName(mediaName); - await umbracoUi.package.clickSubmitButton(); - await umbracoUi.package.clickSaveChangesToPackageButton(); - - // Assert - await umbracoUi.package.clickExistingPackageName(packageName); - expect(umbracoUi.package.isButtonWithNameVisible(mediaTypeName + ' ' + mediaId)).toBeTruthy(); - const packageData = await umbracoApi.package.getByName(packageName); - expect(packageData.mediaIds[0] == mediaId).toBeTruthy(); - - // Clean - await umbracoApi.mediaType.ensureNameNotExists(mediaTypeName); -}); - -test.skip('can create a package with document types', async ({umbracoApi, umbracoUi}) => { - // Arrange - const documentTypeName = 'TestDocumentType'; - await umbracoApi.documentType.ensureNameNotExists(documentTypeName); - await umbracoApi.package.createEmptyPackage(packageName); - const documentTypeId = await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(documentTypeName); - await umbracoUi.reloadPage(); - - // Act - await umbracoUi.package.clickExistingPackageName(packageName); - await umbracoUi.package.clickAddDocumentTypeToPackageButton(); - await umbracoUi.package.clickCaretButton(); - await umbracoUi.package.clickLabelWithName(documentTypeName); - await umbracoUi.package.clickSubmitButton(); - await umbracoUi.package.clickSaveChangesToPackageButton(); - - // Assert - await umbracoUi.package.clickExistingPackageName(packageName); - expect(umbracoUi.package.isButtonWithNameVisible(documentTypeName + ' ' + documentTypeId)).toBeTruthy(); - const packageData = await umbracoApi.package.getByName(packageName); - expect(packageData.documentTypes[0] == documentTypeId).toBeTruthy(); - - // Clean - await umbracoApi.documentType.ensureNameNotExists(documentTypeName); -}); - -// TODO: Remove .skip when the test is able to run. Currently waiting for button -test.skip('can create a package with media types', async ({umbracoApi, umbracoUi}) => { - // Arrange - const mediaTypeName = 'TestMediaType'; - await umbracoApi.mediaType.ensureNameNotExists(mediaTypeName); - await umbracoApi.package.createEmptyPackage(packageName); - const mediaTypeId = await umbracoApi.mediaType.createDefaultMediaType(mediaTypeName); - await umbracoUi.reloadPage(); - - // Act - await umbracoUi.package.clickExistingPackageName(packageName); - await umbracoUi.package.clickAddMediaTypeToPackageButton(); - await umbracoUi.package.clickCaretButton(); - await umbracoUi.package.clickLabelWithName(mediaTypeName); - await umbracoUi.package.clickSubmitButton() - await umbracoUi.package.clickSaveChangesToPackageButton(); - - // Assert - await umbracoUi.package.clickExistingPackageName(packageName); - expect(umbracoUi.package.isButtonWithNameVisible(mediaTypeName + ' ' + mediaTypeId)).toBeTruthy(); - const packageData = await umbracoApi.package.getByName(packageName); - expect(packageData.mediaTypes[0] == mediaTypeId).toBeTruthy(); - - // Clean - await umbracoApi.mediaType.ensureNameNotExists(mediaTypeName); -}); - -// TODO: Remove .skip when the test is able to run. After adding a language to a package and saving. The language is not saved or anything. -test.skip('can create a package with languages', async ({umbracoApi, umbracoUi}) => { - // Arrange - const languageId = await umbracoApi.language.createDefaultDanishLanguage(); - await umbracoApi.package.createEmptyPackage(packageName); - await umbracoUi.reloadPage(); - const languageData = await umbracoApi.language.get(languageId); - const languageName = languageData.name; - - // Act - await umbracoUi.package.clickExistingPackageName(packageName); - await umbracoUi.package.clickAddLanguageToPackageButton(); - await umbracoUi.package.clickCaretButton(); - await umbracoUi.package.clickLabelWithName(languageName); - await umbracoUi.package.clickSubmitButton() - await umbracoUi.package.clickSaveChangesToPackageButton(); - - // Assert - await umbracoUi.package.clickExistingPackageName(packageName); - expect(umbracoUi.package.isButtonWithNameVisible(languageName + ' ' + languageId)).toBeTruthy(); - const packageData = await umbracoApi.package.getByName(packageName); - expect(packageData.languages[0] == languageId).toBeTruthy(); - - // Clean - await umbracoApi.language.ensureNameNotExists(languageName); -}); - -// TODO: Remove .skip when the test is able to run. Currently waiting for button -test.skip('can create a package with dictionary', async ({umbracoApi, umbracoUi}) => { - // Arrange - const dictionaryName = 'TestDictionary'; - await umbracoApi.dictionary.createDefaultDictionary(dictionaryName); - await umbracoApi.package.createEmptyPackage(packageName); - await umbracoUi.reloadPage(); - - // Act - await umbracoUi.package.clickExistingPackageName(packageName); - await umbracoUi.package.clickAddDictionaryToPackageButton(); - await umbracoUi.package.clickCaretButton(); - await umbracoUi.package.clickLabelWithName(dictionaryName); - await umbracoUi.package.clickSubmitButton() - await umbracoUi.package.clickSaveChangesToPackageButton(); - - // Assert - await umbracoUi.package.clickExistingPackageName(packageName); - expect(umbracoUi.package.isButtonWithNameVisible(dictionaryName)).toBeTruthy(); - const packageData = await umbracoApi.package.getByName(packageName); - expect(packageData.dictionaryItems[0] == dictionaryName).toBeTruthy(); - - // Clean - await umbracoApi.dictionary.ensureNameNotExists(dictionaryName); -}); - -// TODO: Remove .skip when the test is able to run. After adding a dataType to a package and saving. The datatype is not saved or anything. -test.skip('can create a package with data types', async ({umbracoApi, umbracoUi}) => { - // Arrange - const dataTypeName = 'TestDataType'; - const dataTypeId = await umbracoApi.dataType.createDateTypeDataType(dataTypeName); - await umbracoApi.package.createEmptyPackage(packageName); - await umbracoUi.reloadPage(); - - // Act - await umbracoUi.package.clickExistingPackageName(packageName); - await umbracoUi.package.clickAddDataTypesToPackageButton(); - await umbracoUi.package.clickCaretButton(); - await umbracoUi.package.clickLabelWithName(dataTypeName); - await umbracoUi.package.clickSubmitButton() - await umbracoUi.package.clickSaveChangesToPackageButton(); - - // Assert - await umbracoUi.package.clickExistingPackageName(packageName); - expect(umbracoUi.package.isButtonWithNameVisible(dataTypeName)).toBeTruthy(); - const packageData = await umbracoApi.package.getByName(packageName); - expect(packageData.dataTypes[0] == dataTypeId).toBeTruthy(); - - // Clean - await umbracoApi.dictionary.ensureNameNotExists(dataTypeName); -}); - -// TODO: Remove .skip when the test is able to run. Currently waiting for button -test.skip('can create a package with templates', async ({umbracoApi, umbracoUi}) => { - // Arrange - const templateName = 'TestTemplate'; - const templateId = await umbracoApi.template.createDefaultTemplate(templateName); - await umbracoApi.package.createEmptyPackage(packageName); - await umbracoUi.reloadPage(); - - // Act - await umbracoUi.package.clickExistingPackageName(packageName); - await umbracoUi.package.clickAddTemplatesToPackageButton(); - await umbracoUi.package.clickCaretButton(); - await umbracoUi.package.clickLabelWithName(templateName); - await umbracoUi.package.clickSubmitButton() - await umbracoUi.package.clickSaveChangesToPackageButton(); - - // Assert - await umbracoUi.package.clickExistingPackageName(packageName); - expect(umbracoUi.package.isButtonWithNameVisible(templateName)).toBeTruthy(); - const packageData = await umbracoApi.package.getByName(packageName); - expect(packageData.templates[0] == templateId).toBeTruthy(); - - // Clean - await umbracoApi.template.ensureNameNotExists(templateName); -}); - -// TODO: Remove .skip when the test is able to run. Currently waiting for button -test.skip('can create a package with stylesheets', async ({umbracoApi, umbracoUi}) => { - // Arrange - const stylesheetName = 'TestStylesheet'; - const stylesheetId = await umbracoApi.stylesheet.createDefaultStylesheet(stylesheetName); - await umbracoApi.package.createEmptyPackage(packageName); - await umbracoUi.reloadPage(); - - // Act - await umbracoUi.package.clickExistingPackageName(packageName); - await umbracoUi.package.clickAddStylesheetToPackageButton(); - await umbracoUi.package.clickCaretButton(); - await umbracoUi.package.clickLabelWithName(stylesheetName); - await umbracoUi.package.clickSubmitButton() - await umbracoUi.package.clickSaveChangesToPackageButton(); - - // Assert - await umbracoUi.package.clickExistingPackageName(packageName); - expect(umbracoUi.package.isButtonWithNameVisible(stylesheetName)).toBeTruthy(); - const packageData = await umbracoApi.package.getByName(packageName); - expect(packageData.stylesheets[0] == stylesheetId).toBeTruthy(); - - // Clean - await umbracoApi.stylesheet.ensureNameNotExists(stylesheetName); -}); - -// TODO: Remove .skip when the test is able to run. Currently waiting for button -test.skip('can create a package with scripts', async ({umbracoApi, umbracoUi}) => { - // Arrange - const scriptName = 'TestScripts'; - const scriptId = await umbracoApi.script.createDefaultScript(scriptName); - await umbracoApi.package.createEmptyPackage(packageName); - await umbracoUi.reloadPage(); - - // Act - await umbracoUi.package.clickExistingPackageName(packageName); - await umbracoUi.package.clickAddScriptToPackageButton(); - await umbracoUi.package.clickCaretButton(); - await umbracoUi.package.clickLabelWithName(scriptName); - await umbracoUi.package.clickSubmitButton() - await umbracoUi.package.clickSaveChangesToPackageButton(); - - // Assert - await umbracoUi.package.clickExistingPackageName(packageName); - expect(umbracoUi.package.isButtonWithNameVisible(scriptName)).toBeTruthy(); - const packageData = await umbracoApi.package.getByName(packageName); - expect(packageData.scripts[0] == scriptId).toBeTruthy(); - - // Clean - await umbracoApi.script.ensureNameNotExists(scriptName); -}); - -// TODO: Remove .skip when the test is able to run. Currently waiting for button -test.skip('can create a package with partial views', async ({umbracoApi, umbracoUi}) => { - // Arrange - const partialViewName = 'TestPartialView'; - const partialViewId = await umbracoApi.partialView.createDefaultPartialView(partialViewName); - await umbracoApi.package.createEmptyPackage(packageName); - await umbracoUi.reloadPage(); - - // Act - await umbracoUi.package.clickExistingPackageName(packageName); - await umbracoUi.package.clickAddPartialViewToPackageButton(); - await umbracoUi.package.clickCaretButton(); - await umbracoUi.package.clickLabelWithName(partialViewName); - await umbracoUi.package.clickSubmitButton() - await umbracoUi.package.clickSaveChangesToPackageButton(); - - // Assert - await umbracoUi.package.clickExistingPackageName(packageName); - expect(umbracoUi.package.isButtonWithNameVisible(partialViewName)).toBeTruthy(); - const packageData = await umbracoApi.package.getByName(packageName); - expect(packageData.partialViews[0] == partialViewId).toBeTruthy(); - - // Clean - await umbracoApi.package.ensureNameNotExists(packageName); -}); - -// Currently you are not able to download a package -//TODO: Remove skip when the frontend is ready -test.skip('can download a package', async ({umbracoApi, umbracoUi}) => { - // Arrange - const packageId = await umbracoApi.package.createEmptyPackage(packageName); - await umbracoUi.reloadPage(); - - // Act - await umbracoUi.package.clickExistingPackageName(packageName); - const packageData = await umbracoUi.package.downloadPackage(packageId); - // Reads the packageFixture we have in the fixture library - const path = require('path'); - const filePath = path.resolve('./fixtures/packageLibrary/package.xml'); - const packageFixture = fs.readFileSync(filePath); - - // Assert - expect(packageData).toMatch(packageFixture.toString().trim()); -}); +// import {ConstantHelper, test} from '@umbraco/playwright-testhelpers'; +// import {expect} from '@playwright/test'; +// import * as fs from 'fs'; +// +// const packageName = 'TestPackage'; +// // UNCOMMENT WHEN FIXED +// test.beforeEach(async ({umbracoApi, umbracoUi}) => { +// await umbracoApi.package.ensureNameNotExists(packageName); +// await umbracoUi.goToBackOffice(); +// await umbracoUi.package.goToSection(ConstantHelper.sections.packages); +// await umbracoUi.package.clickCreatedTab(); +// }); +// +// test.afterEach(async ({umbracoApi}) => { +// await umbracoApi.package.ensureNameNotExists(packageName); +// }); +// +// test('can create a empty package', {tag: '@smoke'}, async ({ umbracoUi}) => { +// // Act +// await umbracoUi.package.clickCreatePackageButton(); +// await umbracoUi.package.enterPackageName(packageName); +// await umbracoUi.package.clickCreateButton(); +// +// // Assert +// await umbracoUi.package.isSuccessNotificationVisible(); +// await umbracoUi.package.clickCreatedTab(); +// await umbracoUi.package.isPackageNameVisible(packageName); +// }); +// +// test('can update package name', async ({umbracoApi, umbracoUi}) => { +// // Arrange +// const wrongPackageName = 'WrongPackageName'; +// await umbracoApi.package.ensureNameNotExists(wrongPackageName); +// await umbracoApi.package.createEmptyPackage(wrongPackageName); +// await umbracoUi.reloadPage(); +// await umbracoUi.package.goToSection(ConstantHelper.sections.packages); +// await umbracoUi.package.clickCreatedTab(); +// +// // Act +// await umbracoUi.package.clickExistingPackageName(wrongPackageName); +// await umbracoUi.package.enterPackageName(packageName); +// await umbracoUi.package.clickUpdateButton(); +// +// // Assert +// await umbracoUi.package.isSuccessNotificationVisible(); +// await umbracoUi.package.clickCreatedTab(); +// await umbracoUi.package.isPackageNameVisible(packageName); +// expect(umbracoApi.package.doesNameExist(packageName)).toBeTruthy(); +// }); +// +// test('can delete a package', async ({umbracoApi, umbracoUi}) => { +// // Arrange +// await umbracoApi.package.createEmptyPackage(packageName); +// await umbracoUi.reloadPage(); +// await umbracoUi.package.clickCreatedTab(); +// +// // Act +// await umbracoUi.package.clickDeleteButtonForPackageName(packageName); +// await umbracoUi.package.clickConfirmToDeleteButton(); +// +// // Assert +// await umbracoUi.package.clickCreatedTab(); +// await umbracoUi.package.isPackageNameVisible(packageName, false); +// expect(await umbracoApi.package.doesNameExist(packageName)).toBeFalsy(); +// }); +// +// test('can create a package with content', async ({umbracoApi, umbracoUi}) => { +// // Arrange +// const documentTypeName = 'TestDocumentType'; +// const documentName = 'TestDocument'; +// await umbracoApi.documentType.ensureNameNotExists(documentTypeName); +// const documentTypeId = await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(documentTypeName); +// const documentId = await umbracoApi.document.createDefaultDocument(documentName, documentTypeId); +// +// // Act +// await umbracoUi.package.clickCreatePackageButton(); +// await umbracoUi.package.enterPackageName(packageName); +// await umbracoUi.package.clickAddContentToPackageButton(); +// await umbracoUi.package.clickLabelWithName(documentName); +// await umbracoUi.package.clickChooseContainerButton(); +// await umbracoUi.package.clickCreateButton(); +// +// // Assert +// await umbracoUi.package.isSuccessNotificationVisible(); +// const packageData = await umbracoApi.package.getByName(packageName); +// expect(packageData.contentNodeId == documentId).toBeTruthy(); +// expect(umbracoUi.package.isButtonWithNameVisible(documentName)).toBeTruthy(); +// +// // Clean +// await umbracoApi.documentType.ensureNameNotExists(documentTypeName); +// }); +// +// test('can create a package with media', async ({umbracoApi, umbracoUi}) => { +// // Arrange +// const mediaName = 'TestMedia'; +// await umbracoApi.media.ensureNameNotExists(mediaName); +// const mediaId = await umbracoApi.media.createDefaultMediaFile(mediaName); +// +// // Act +// await umbracoUi.package.clickCreatePackageButton(); +// await umbracoUi.package.enterPackageName(packageName); +// await umbracoUi.package.clickAddMediaToPackageButton(); +// await umbracoUi.media.selectMediaByName(mediaName); +// await umbracoUi.package.clickSubmitButton(); +// await umbracoUi.package.clickCreateButton(); +// +// // Assert +// await umbracoUi.package.isSuccessNotificationVisible(); +// expect(umbracoUi.package.isTextWithExactNameVisible(mediaName)).toBeTruthy(); +// const packageData = await umbracoApi.package.getByName(packageName); +// expect(packageData.mediaIds[0] == mediaId).toBeTruthy(); +// +// // Clean +// await umbracoApi.media.ensureNameNotExists(mediaName); +// }); +// +// test('can create a package with document types', async ({umbracoApi, umbracoUi}) => { +// // Arrange +// const documentTypeName = 'TestDocumentType'; +// await umbracoApi.documentType.ensureNameNotExists(documentTypeName); +// const documentTypeId = await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(documentTypeName); +// +// // Act +// await umbracoUi.package.clickCreatePackageButton(); +// await umbracoUi.package.enterPackageName(packageName); +// await umbracoUi.package.clickAddDocumentTypeToPackageButton(); +// await umbracoUi.package.clickLabelWithName(documentTypeName); +// await umbracoUi.package.clickChooseContainerButton(); +// await umbracoUi.package.clickCreateButton(); +// +// // Assert +// await umbracoUi.package.isSuccessNotificationVisible(); +// expect(umbracoUi.package.isButtonWithNameVisible(documentTypeName)).toBeTruthy(); +// const packageData = await umbracoApi.package.getByName(packageName); +// expect(packageData.documentTypes[0] == documentTypeId).toBeTruthy(); +// +// // Clean +// await umbracoApi.documentType.ensureNameNotExists(documentTypeName); +// }); +// +// test('can create a package with media types', async ({umbracoApi, umbracoUi}) => { +// // Arrange +// const mediaTypeName = 'TestMediaType'; +// await umbracoApi.mediaType.ensureNameNotExists(mediaTypeName); +// const mediaTypeId = await umbracoApi.mediaType.createDefaultMediaType(mediaTypeName); +// +// // Act +// await umbracoUi.package.clickCreatePackageButton(); +// await umbracoUi.package.enterPackageName(packageName); +// await umbracoUi.package.clickAddMediaTypeToPackageButton(); +// await umbracoUi.package.clickButtonWithName(mediaTypeName, true); +// await umbracoUi.package.clickChooseContainerButton(); +// await umbracoUi.package.clickCreateButton(); +// +// // Assert +// await umbracoUi.package.isSuccessNotificationVisible(); +// expect(umbracoUi.package.isButtonWithNameVisible(mediaTypeName)).toBeTruthy(); +// const packageData = await umbracoApi.package.getByName(packageName); +// expect(packageData.mediaTypes[0] == mediaTypeId).toBeTruthy(); +// +// // Clean +// await umbracoApi.mediaType.ensureNameNotExists(mediaTypeName); +// }); +// +// test('can create a package with languages', async ({umbracoApi, umbracoUi}) => { +// // Arrange +// await umbracoApi.language.ensureNameNotExists('Danish'); +// const languageId = await umbracoApi.language.createDanishLanguage(); +// const languageData = await umbracoApi.language.get(languageId); +// const languageName = languageData.name; +// +// // Act +// await umbracoUi.package.clickCreatePackageButton(); +// await umbracoUi.package.enterPackageName(packageName); +// await umbracoUi.package.clickAddLanguageToPackageButton(); +// await umbracoUi.package.clickButtonWithName(languageName); +// await umbracoUi.package.clickSubmitButton(); +// await umbracoUi.package.clickCreateButton(); +// +// // Assert +// await umbracoUi.package.isSuccessNotificationVisible(); +// expect(umbracoUi.package.isButtonWithNameVisible(languageName + ' ' + languageId)).toBeTruthy(); +// const packageData = await umbracoApi.package.getByName(packageName); +// expect(packageData.languages[0] == languageId).toBeTruthy(); +// +// // Clean +// await umbracoApi.language.ensureNameNotExists(languageName); +// }); +// +// test('can create a package with dictionary', async ({umbracoApi, umbracoUi}) => { +// // Arrange +// const dictionaryName = 'TestDictionary'; +// const dictionaryId = await umbracoApi.dictionary.createDefaultDictionary(dictionaryName); +// +// // Act +// await umbracoUi.package.clickCreatePackageButton(); +// await umbracoUi.package.enterPackageName(packageName); +// await umbracoUi.package.clickAddDictionaryToPackageButton(); +// await umbracoUi.package.clickButtonWithName(dictionaryName); +// await umbracoUi.package.clickChooseContainerButton(); +// await umbracoUi.package.clickCreateButton(); +// +// // Assert +// await umbracoUi.package.isSuccessNotificationVisible(); +// expect(umbracoUi.package.isButtonWithNameVisible(dictionaryName)).toBeTruthy(); +// const packageData = await umbracoApi.package.getByName(packageName); +// expect(packageData.dictionaryItems[0] == dictionaryId).toBeTruthy(); +// +// // Clean +// await umbracoApi.dictionary.ensureNameNotExists(dictionaryName); +// }); +// +// test('can create a package with data types', async ({umbracoApi, umbracoUi}) => { +// // Arrange +// const dataTypeName = 'TestDataType'; +// await umbracoApi.dataType.ensureNameNotExists(dataTypeName); +// const dataTypeId = await umbracoApi.dataType.createDateTypeDataType(dataTypeName); +// +// // Act +// await umbracoUi.package.clickCreatePackageButton(); +// await umbracoUi.package.enterPackageName(packageName); +// await umbracoUi.package.clickAddDataTypesToPackageButton(); +// await umbracoUi.package.clickLabelWithName(dataTypeName); +// await umbracoUi.package.clickChooseContainerButton(); +// await umbracoUi.package.clickCreateButton(); +// +// // Assert +// await umbracoUi.package.isSuccessNotificationVisible(); +// expect(umbracoUi.package.isButtonWithNameVisible(dataTypeName)).toBeTruthy(); +// const packageData = await umbracoApi.package.getByName(packageName); +// expect(packageData.dataTypes[0] == dataTypeId).toBeTruthy(); +// +// // Clean +// await umbracoApi.dataType.ensureNameNotExists(dataTypeName); +// }); +// +// test('can create a package with templates', async ({umbracoApi, umbracoUi}) => { +// // Arrange +// const templateName = 'TestTemplate'; +// await umbracoApi.template.ensureNameNotExists(templateName); +// const templateId = await umbracoApi.template.createDefaultTemplate(templateName); +// +// // Act +// await umbracoUi.package.clickCreatePackageButton(); +// await umbracoUi.package.enterPackageName(packageName); +// await umbracoUi.package.clickAddTemplatesToPackageButton(); +// await umbracoUi.package.clickLabelWithName(templateName); +// await umbracoUi.package.clickChooseContainerButton(); +// await umbracoUi.package.clickCreateButton(); +// +// // Assert +// await umbracoUi.package.isSuccessNotificationVisible(); +// expect(umbracoUi.package.isButtonWithNameVisible(templateName)).toBeTruthy(); +// const packageData = await umbracoApi.package.getByName(packageName); +// expect(packageData.templates[0] == templateId).toBeTruthy(); +// +// // Clean +// await umbracoApi.template.ensureNameNotExists(templateName); +// }); +// +// test('can create a package with stylesheets', async ({umbracoApi, umbracoUi}) => { +// // Arrange +// const stylesheetName = 'TestStylesheet.css'; +// await umbracoApi.stylesheet.ensureNameNotExists(stylesheetName); +// const stylesheetId = await umbracoApi.stylesheet.createDefaultStylesheet(stylesheetName); +// +// // Act +// await umbracoUi.package.clickCreatePackageButton(); +// await umbracoUi.package.enterPackageName(packageName); +// await umbracoUi.package.clickAddStylesheetToPackageButton(); +// await umbracoUi.package.clickLabelWithName(stylesheetName); +// await umbracoUi.package.clickChooseContainerButton(); +// await umbracoUi.package.clickCreateButton(); +// +// // Assert +// await umbracoUi.package.isSuccessNotificationVisible(); +// expect(umbracoUi.package.isButtonWithNameVisible(stylesheetName)).toBeTruthy(); +// const packageData = await umbracoApi.package.getByName(packageName); +// expect(packageData.stylesheets[0] == stylesheetId).toBeTruthy(); +// +// // Clean +// await umbracoApi.stylesheet.ensureNameNotExists(stylesheetName); +// }); +// +// test('can create a package with scripts', async ({umbracoApi, umbracoUi}) => { +// // Arrange +// const scriptName = 'TestScripts.js'; +// await umbracoApi.script.ensureNameNotExists(scriptName); +// const scriptId = await umbracoApi.script.createDefaultScript(scriptName); +// +// // Act +// await umbracoUi.package.clickCreatePackageButton(); +// await umbracoUi.package.enterPackageName(packageName); +// await umbracoUi.package.clickAddScriptToPackageButton(); +// await umbracoUi.package.clickLabelWithName(scriptName); +// await umbracoUi.package.clickChooseContainerButton(); +// await umbracoUi.package.clickCreateButton(); +// +// // Assert +// await umbracoUi.package.isSuccessNotificationVisible(); +// expect(umbracoUi.package.isButtonWithNameVisible(scriptName)).toBeTruthy(); +// const packageData = await umbracoApi.package.getByName(packageName); +// expect(packageData.scripts[0] == scriptId).toBeTruthy(); +// +// // Clean +// await umbracoApi.script.ensureNameNotExists(scriptName); +// }); +// +// test('can create a package with partial views', async ({umbracoApi, umbracoUi}) => { +// // Arrange +// const partialViewName = 'TestPartialView.cshtml'; +// const partialViewId = await umbracoApi.partialView.createDefaultPartialView(partialViewName); +// +// // Act +// await umbracoUi.package.clickCreatePackageButton(); +// await umbracoUi.package.enterPackageName(packageName); +// await umbracoUi.package.clickAddPartialViewToPackageButton(); +// await umbracoUi.package.clickLabelWithName(partialViewName); +// await umbracoUi.package.clickChooseContainerButton(); +// await umbracoUi.package.clickCreateButton(); +// +// // Assert +// await umbracoUi.package.isSuccessNotificationVisible(); +// expect(umbracoUi.package.isButtonWithNameVisible(partialViewName)).toBeTruthy(); +// const packageData = await umbracoApi.package.getByName(packageName); +// expect(packageData.partialViews[0] == partialViewId).toBeTruthy(); +// +// // Clean +// await umbracoApi.partialView.ensureNameNotExists(partialViewName); +// }); +// +// test('can download a package', async ({umbracoApi, umbracoUi}) => { +// // Arrange +// const packageId = await umbracoApi.package.createEmptyPackage(packageName); +// await umbracoUi.reloadPage(); +// +// // Act +// await umbracoUi.package.clickExistingPackageName(packageName); +// const packageData = await umbracoUi.package.downloadPackage(packageId); +// // Reads the packageFixture we have in the fixture library +// const path = require('path'); +// const filePath = path.resolve('./fixtures/packageLibrary/package.xml'); +// const packageFixture = fs.readFileSync(filePath); +// +// // Assert +// expect(packageData).toMatch(packageFixture.toString().trim()); +// }); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Packages/InstalledPackages.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Packages/InstalledPackages.spec.ts index 603b52d1e7..fbd11c8cfd 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Packages/InstalledPackages.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Packages/InstalledPackages.spec.ts @@ -1,8 +1,6 @@ import {ConstantHelper, test} from '@umbraco/playwright-testhelpers'; -// We can't install any packages so we do not have any installed. -//TODO: Remove skip when the frontend is ready -test.skip('can see no package have been installed', async ({page, umbracoUi}) => { +test.skip('can see the umbraco package is installed', async ({umbracoUi}) => { // Arrange await umbracoUi.goToBackOffice(); await umbracoUi.package.goToSection(ConstantHelper.sections.packages); @@ -11,5 +9,5 @@ test.skip('can see no package have been installed', async ({page, umbracoUi}) => await umbracoUi.package.clickInstalledTab(); // Assert - await umbracoUi.package.isTextNoPackagesHaveBeenInstalledVisible(); + await umbracoUi.package.isUmbracoBackofficePackageVisible(); }); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Packages/PackagesPackages.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Packages/PackagesPackages.spec.ts index 4e7a0b3057..a1b4d192ad 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Packages/PackagesPackages.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Packages/PackagesPackages.spec.ts @@ -1,7 +1,8 @@ import {ConstantHelper, test} from '@umbraco/playwright-testhelpers'; +// TODO: There is currently an issue with playwright and the Iframe in the marketplace, look into this. // The MarketPlace is a iFrame we are using from the DXP team, so it is not something we should test. This test is just checking if we have the IFrame -test('can see the marketplace', async ({umbracoUi}) => { +test.skip('can see the marketplace', async ({umbracoUi}) => { // Arrange await umbracoUi.goToBackOffice(); await umbracoUi.package.goToSection(ConstantHelper.sections.packages); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithApprovedColor.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithApprovedColor.spec.ts new file mode 100644 index 0000000000..5daad8769b --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithApprovedColor.spec.ts @@ -0,0 +1,48 @@ +import {AliasHelper, test} from '@umbraco/playwright-testhelpers'; + +const contentName = 'Test Rendering Content'; +const documentTypeName = 'TestDocumentTypeForContent'; +const customDataTypeName = 'Custom Approved Color'; +const templateName = 'TestTemplateForContent'; +const propertyName = 'Test Approved Color'; +const colorValue = {label: "Test Label", value: "038c33"}; +let dataTypeId = null; + +test.beforeEach(async ({umbracoApi}) => { + dataTypeId = await umbracoApi.dataType.createApprovedColorDataTypeWithOneItem(customDataTypeName, colorValue.label, colorValue.value); +}); + +test.afterEach(async ({umbracoApi}) => { + await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + await umbracoApi.template.ensureNameNotExists(templateName); + await umbracoApi.dataType.ensureNameNotExists(customDataTypeName); +}); + +test('can render content with an approved color with label', async ({umbracoApi, umbracoUi}) => { + // Arrange + const templateId = await umbracoApi.template.createTemplateWithDisplayingApprovedColorValue(templateName, AliasHelper.toAlias(propertyName)); + await umbracoApi.document.createPublishedDocumentWithValue(contentName, colorValue, dataTypeId, templateId, propertyName, documentTypeName); + const contentData = await umbracoApi.document.getByName(contentName); + const contentURL = contentData.urls[0].url; + + // Act + await umbracoUi.contentRender.navigateToRenderedContentPage(contentURL); + + // Assert + await umbracoUi.contentRender.doesContentRenderValueContainText(colorValue.label); +}); + +test('can render content with an approved color without label', async ({umbracoApi, umbracoUi}) => { + // Arrange + const templateId = await umbracoApi.template.createTemplateWithDisplayingApprovedColorValue(templateName, AliasHelper.toAlias(propertyName), false); + await umbracoApi.document.createPublishedDocumentWithValue(contentName, colorValue, dataTypeId, templateId, propertyName, documentTypeName); + const contentData = await umbracoApi.document.getByName(contentName); + const contentURL = contentData.urls[0].url; + + // Act + await umbracoUi.contentRender.navigateToRenderedContentPage(contentURL); + + // Assert + await umbracoUi.contentRender.doesContentRenderValueContainText(colorValue.value); +}); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithCheckboxList.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithCheckboxList.spec.ts new file mode 100644 index 0000000000..83fe60e58b --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithCheckboxList.spec.ts @@ -0,0 +1,40 @@ +import {AliasHelper, test} from '@umbraco/playwright-testhelpers'; + +const contentName = 'Test Rendering Content'; +const documentTypeName = 'TestDocumentTypeForContent'; +const customDataTypeName = 'Custom Checkbox List'; +const templateName = 'TestTemplateForContent'; +const propertyName = 'Test Checkbox List'; + +test.afterEach(async ({umbracoApi}) => { + await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + await umbracoApi.template.ensureNameNotExists(templateName); + await umbracoApi.dataType.ensureNameNotExists(customDataTypeName); +}); + +const checkboxList = [ + {type: 'an empty list of checkboxes', value: []}, + {type: 'one checkbox', value: ['Test checkbox']}, + {type: 'multiple checkboxes', value: ['Test checkbox 1', 'Test checkbox 2', 'Test checkbox 3']}, +]; + +for (const checkbox of checkboxList) { + test(`can render content with ${checkbox.type}`, async ({umbracoApi, umbracoUi}) => { + // Arrange + const checkboxValue = checkbox.value; + const dataTypeId = await umbracoApi.dataType.createCheckboxListDataType(customDataTypeName, checkboxValue); + const templateId = await umbracoApi.template.createTemplateWithDisplayingMulitpleStringValue(templateName, AliasHelper.toAlias(propertyName)); + await umbracoApi.document.createPublishedDocumentWithValue(contentName, checkboxValue, dataTypeId, templateId, propertyName, documentTypeName); + const contentData = await umbracoApi.document.getByName(contentName); + const contentURL = contentData.urls[0].url; + + // Act + await umbracoUi.contentRender.navigateToRenderedContentPage(contentURL); + + // Assert + checkboxValue.forEach(async value => { + await umbracoUi.contentRender.doesContentRenderValueContainText(value); + }); + }); +} diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithContentPicker.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithContentPicker.spec.ts new file mode 100644 index 0000000000..a5246a04bd --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithContentPicker.spec.ts @@ -0,0 +1,41 @@ +import {AliasHelper, test} from '@umbraco/playwright-testhelpers'; + +const contentName = 'Test Rendering Content'; +const documentTypeName = 'TestDocumentTypeForContent'; +const dataTypeName = 'Content Picker'; +const templateName = 'TestTemplateForContent'; +const propertyName = 'Test Content Picker'; +const contentPickerDocumentTypeName = 'DocumentTypeForContentPicker'; +const contentPickerName = 'TestContentPickerName'; +let dataTypeData = null; +let contentPickerDocumentTypeId = ''; +let contentPickerId = ''; + +test.beforeEach(async ({umbracoApi}) => { + dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); + contentPickerDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(contentPickerDocumentTypeName); + contentPickerId = await umbracoApi.document.createDefaultDocument(contentPickerName, contentPickerDocumentTypeId); + await umbracoApi.document.publish(contentPickerId); +}); + +test.afterEach(async ({umbracoApi}) => { + await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + await umbracoApi.document.ensureNameNotExists(contentPickerName); + await umbracoApi.documentType.ensureNameNotExists(contentPickerDocumentTypeName); + await umbracoApi.template.ensureNameNotExists(templateName); +}); + +test('can render content with content picker value', async ({umbracoApi, umbracoUi}) => { + // Arrange + const templateId = await umbracoApi.template.createTemplateWithDisplayingContentPickerValue(templateName, AliasHelper.toAlias(propertyName)); + await umbracoApi.document.createPublishedDocumentWithValue(contentName, contentPickerId, dataTypeData.id, templateId, propertyName, documentTypeName); + const contentData = await umbracoApi.document.getByName(contentName); + const contentURL = contentData.urls[0].url; + + // Act + await umbracoUi.contentRender.navigateToRenderedContentPage(contentURL); + + // Assert + await umbracoUi.contentRender.doesContentRenderValueContainText(contentPickerName); +}); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithDatePicker.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithDatePicker.spec.ts new file mode 100644 index 0000000000..212ff8c35e --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithDatePicker.spec.ts @@ -0,0 +1,35 @@ +import {AliasHelper, test} from '@umbraco/playwright-testhelpers'; + +const contentName = 'Test Rendering Content'; +const documentTypeName = 'TestDocumentTypeForContent'; +const templateName = 'TestTemplateForContent'; +const propertyName = 'Test Date Picker'; + +test.afterEach(async ({umbracoApi}) => { + await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + await umbracoApi.template.ensureNameNotExists(templateName); +}); + +const dateTimes = [ + {type: 'with AM time', value: '2024-10-29 09:09:09', expectedValue: '10/29/2024 9:09:09 AM', dataTypeName: 'Date Picker with time'}, + {type: 'with PM time', value: '2024-10-29 21:09:09', expectedValue: '10/29/2024 9:09:09 PM', dataTypeName: 'Date Picker with time'}, + // TODO: Uncomment this when the front-end is ready. Currently the time still be rendered. + //{type: 'without time', value: '2024-10-29 00:00:00', expectedValue: '10/29/2024', dataTypeName: 'Date Picker'} +]; + +for (const dateTime of dateTimes) { + test(`can render content with a date ${dateTime.type}`, async ({umbracoApi, umbracoUi}) => { + const dataTypeData = await umbracoApi.dataType.getByName(dateTime.dataTypeName); + const templateId = await umbracoApi.template.createTemplateWithDisplayingStringValue(templateName, AliasHelper.toAlias(propertyName)); + await umbracoApi.document.createPublishedDocumentWithValue(contentName, dateTime.value, dataTypeData.id, templateId, propertyName, documentTypeName); + const contentData = await umbracoApi.document.getByName(contentName); + const contentURL = contentData.urls[0].url; + + // Act + await umbracoUi.contentRender.navigateToRenderedContentPage(contentURL); + + // Assert + await umbracoUi.contentRender.doesContentRenderValueContainText(dateTime.expectedValue, true); + }); +} diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithDropdown.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithDropdown.spec.ts new file mode 100644 index 0000000000..8cb3992554 --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithDropdown.spec.ts @@ -0,0 +1,44 @@ +import {AliasHelper, test} from '@umbraco/playwright-testhelpers'; + +const contentName = 'Test Rendering Content'; +const documentTypeName = 'TestDocumentTypeForContent'; +const customDataTypeName = 'Custom Dropdown'; +const templateName = 'TestTemplateForContent'; +const propertyName = 'Test Dropdown'; + +test.afterEach(async ({umbracoApi}) => { + await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + await umbracoApi.template.ensureNameNotExists(templateName); + await umbracoApi.dataType.ensureNameNotExists(customDataTypeName); +}); + +const dropdownValues = [ + {type: 'an empty dropdown list', value: [], isMultiple: false}, + {type: 'a single dropdown value', value: ['Test checkbox'], isMultiple: false}, + {type: 'multiple dropdown values', value: ['Test option 1', 'Test option 2'], isMultiple: true} +]; + +for (const dropdown of dropdownValues) { + test(`can render content with ${dropdown.type}`, async ({umbracoApi, umbracoUi}) => { + // Arrange + const dataTypeId = await umbracoApi.dataType.createDropdownDataType(customDataTypeName, dropdown.isMultiple, dropdown.value); + let templateId = ''; + if (dropdown.isMultiple) { + templateId = await umbracoApi.template.createTemplateWithDisplayingMulitpleStringValue(templateName, AliasHelper.toAlias(propertyName)); + } else { + templateId = await umbracoApi.template.createTemplateWithDisplayingStringValue(templateName, AliasHelper.toAlias(propertyName)); + } + await umbracoApi.document.createPublishedDocumentWithValue(contentName, dropdown.value, dataTypeId, templateId, propertyName, documentTypeName); + const contentData = await umbracoApi.document.getByName(contentName); + const contentURL = contentData.urls[0].url; + + // Act + await umbracoUi.contentRender.navigateToRenderedContentPage(contentURL); + + // Assert + dropdown.value.forEach(async value => { + await umbracoUi.contentRender.doesContentRenderValueContainText(value); + }); + }); +} \ No newline at end of file diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithImageCropper.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithImageCropper.spec.ts new file mode 100644 index 0000000000..de6c40da56 --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithImageCropper.spec.ts @@ -0,0 +1,36 @@ +import {AliasHelper, test} from '@umbraco/playwright-testhelpers'; + +const contentName = 'Test Rendering Content'; +const documentTypeName = 'TestDocumentTypeForContent'; +const customDataTypeName = 'Custom Image Cropper'; +const templateName = 'TestTemplateForContent'; +const propertyName = 'Test Image Cropper'; +const cropLabel = 'Test Crop'; +const cropValue = {label: cropLabel, alias: AliasHelper.toAlias(cropLabel), width: 500, height: 700}; +let dataTypeId = null; + +test.beforeEach(async ({umbracoApi}) => { + dataTypeId = await umbracoApi.dataType.createImageCropperDataTypeWithOneCrop(customDataTypeName, cropValue.label, cropValue.width, cropValue.height); +}); + +test.afterEach(async ({umbracoApi}) => { + await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + await umbracoApi.template.ensureNameNotExists(templateName); + await umbracoApi.dataType.ensureNameNotExists(customDataTypeName); +}); + +test('can render content with an image cropper', async ({umbracoApi, umbracoUi}) => { + // Arrange + const templateId = await umbracoApi.template.createTemplateWithDisplayingImageCropperValue(templateName, AliasHelper.toAlias(propertyName), AliasHelper.toAlias(cropValue.label)); + await umbracoApi.document.createPublishedDocumentWithImageCropper(contentName, cropValue, dataTypeId, templateId, propertyName, documentTypeName); + const contentData = await umbracoApi.document.getByName(contentName); + const contentURL = contentData.urls[0].url; + const imageSrc = contentData.values[0].value.src; + + // Act + await umbracoUi.contentRender.navigateToRenderedContentPage(contentURL); + + // Assert + await umbracoUi.contentRender.doesContentRenderValueHaveImage(imageSrc, cropValue.width, cropValue.height); +}); \ No newline at end of file diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithNumeric.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithNumeric.spec.ts new file mode 100644 index 0000000000..48985217b4 --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithNumeric.spec.ts @@ -0,0 +1,40 @@ +import {AliasHelper, test} from '@umbraco/playwright-testhelpers'; + +const contentName = 'Test Rendering Content'; +const documentTypeName = 'TestDocumentTypeForContent'; +const dataTypeName = 'Numeric'; +const templateName = 'TestTemplateForContent'; +const propertyName = 'Test Numeric'; +let dataTypeData = null; + +test.beforeEach(async ({umbracoApi}) => { + dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); +}); + +test.afterEach(async ({umbracoApi}) => { + await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + await umbracoApi.template.ensureNameNotExists(templateName); +}); + +const numerics = [ + {type: 'a positive integer', value: '1234567890'}, + {type: 'a negative integer', value: '-1234567890'}, +]; + +for (const numeric of numerics) { + test(`can render content with ${numeric.type}`, async ({umbracoApi, umbracoUi}) => { + // Arrange + const numericValue = numeric.value; + const templateId = await umbracoApi.template.createTemplateWithDisplayingStringValue(templateName, AliasHelper.toAlias(propertyName)); + await umbracoApi.document.createPublishedDocumentWithValue(contentName, numericValue, dataTypeData.id, templateId, propertyName, documentTypeName); + const contentData = await umbracoApi.document.getByName(contentName); + const contentURL = contentData.urls[0].url; + + // Act + await umbracoUi.contentRender.navigateToRenderedContentPage(contentURL); + + // Assert + await umbracoUi.contentRender.doesContentRenderValueContainText(numericValue); + }); +} diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithRadiobox.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithRadiobox.spec.ts new file mode 100644 index 0000000000..540f0c2b05 --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithRadiobox.spec.ts @@ -0,0 +1,36 @@ +import {AliasHelper, test} from '@umbraco/playwright-testhelpers'; + +const contentName = 'Test Rendering Content'; +const documentTypeName = 'TestDocumentTypeForContent'; +const customDataTypeName = 'Custom Radiobox'; +const templateName = 'TestTemplateForContent'; +const propertyName = 'Test Radiobox'; + +test.afterEach(async ({umbracoApi}) => { + await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + await umbracoApi.template.ensureNameNotExists(templateName); + await umbracoApi.dataType.ensureNameNotExists(customDataTypeName); +}); + +const radioboxValues = [ + {type: 'an empty radiobox', value: ''}, + {type: 'a radiobox value', value: 'Test radiobox option'} +]; + +for (const radiobox of radioboxValues) { + test(`can render content with ${radiobox.type}`, async ({umbracoApi, umbracoUi}) => { + // Arrange + const dataTypeId = await umbracoApi.dataType.createRadioboxDataType(customDataTypeName, [radiobox.value]); + const templateId = await umbracoApi.template.createTemplateWithDisplayingStringValue(templateName, AliasHelper.toAlias(propertyName)); + await umbracoApi.document.createPublishedDocumentWithValue(contentName, radiobox.value, dataTypeId, templateId, propertyName, documentTypeName); + const contentData = await umbracoApi.document.getByName(contentName); + const contentURL = contentData.urls[0].url; + + // Act + await umbracoUi.contentRender.navigateToRenderedContentPage(contentURL); + + // Assert + await umbracoUi.contentRender.doesContentRenderValueContainText(radiobox.value); + }); +} \ No newline at end of file diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithTags.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithTags.spec.ts new file mode 100644 index 0000000000..6b7e8423b6 --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithTags.spec.ts @@ -0,0 +1,43 @@ +import {AliasHelper, test} from '@umbraco/playwright-testhelpers'; + +const contentName = 'Test Rendering Content'; +const documentTypeName = 'TestDocumentTypeForContent'; +const dataTypeName = 'Tags'; +const templateName = 'TestTemplateForContent'; +const propertyName = 'Test Tags'; +let dataTypeData = null; + +test.beforeEach(async ({umbracoApi}) => { + dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); +}); + +test.afterEach(async ({umbracoApi}) => { + await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + await umbracoApi.template.ensureNameNotExists(templateName); +}); + +const tags = [ + {type: 'an empty tag', value: []}, + {type: 'a non-empty tag', value: ['test tag']}, + {type: 'multiple tags', value: ['test tag 1', 'test tag 2']}, +]; + +for (const tag of tags) { + test(`can render content with ${tag.type}`, async ({umbracoApi, umbracoUi}) => { + // Arrange + const tagValue = tag.value; + const templateId = await umbracoApi.template.createTemplateWithDisplayingMulitpleStringValue(templateName, AliasHelper.toAlias(propertyName)); + await umbracoApi.document.createPublishedDocumentWithValue(contentName, tagValue, dataTypeData.id, templateId, propertyName, documentTypeName); + const contentData = await umbracoApi.document.getByName(contentName); + const contentURL = contentData.urls[0].url; + + // Act + await umbracoUi.contentRender.navigateToRenderedContentPage(contentURL); + + // Assert + tagValue.forEach(async value => { + await umbracoUi.contentRender.doesContentRenderValueContainText(value); + }); + }); +} diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithTextarea.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithTextarea.spec.ts new file mode 100644 index 0000000000..251bf997e1 --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithTextarea.spec.ts @@ -0,0 +1,44 @@ +import {AliasHelper, test} from '@umbraco/playwright-testhelpers'; + +const contentName = 'Test Rendering Content'; +const documentTypeName = 'TestDocumentTypeForContent'; +const dataTypeName = 'Textarea'; +const templateName = 'TestTemplateForContent'; +const propertyName = 'Test Textarea'; +let dataTypeData = null; + +test.beforeEach(async ({umbracoApi}) => { + dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); +}); + +test.afterEach(async ({umbracoApi}) => { + await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + await umbracoApi.template.ensureNameNotExists(templateName); +}); + +const textareas = [ + {type: 'an empty textarea', value: ''}, + {type: 'a non-empty textarea', value: 'Welcome to Umbraco site'}, + {type: 'a textarea that contains special characters', value: '@#^&*()_+[]{};:"<>,./?'}, + {type: 'a textarea that contains multiple lines', value: 'First line\n Second line\n Third line'}, + {type: 'a textarea that contains an SQL injection', value: "' OR '1'='1'; --"}, + {type: 'a textarea that contains cross-site scripting', value: ""} +]; + +for (const textarea of textareas) { + test(`can render content with ${textarea.type}`, async ({umbracoApi, umbracoUi}) => { + // Arrange + const textareaValue = textarea.value; + const templateId = await umbracoApi.template.createTemplateWithDisplayingStringValue(templateName, AliasHelper.toAlias(propertyName)); + await umbracoApi.document.createPublishedDocumentWithValue(contentName, textareaValue, dataTypeData.id, templateId, propertyName, documentTypeName); + const contentData = await umbracoApi.document.getByName(contentName); + const contentURL = contentData.urls[0].url; + + // Act + await umbracoUi.contentRender.navigateToRenderedContentPage(contentURL); + + // Assert + await umbracoUi.contentRender.doesContentRenderValueContainText(textareaValue); + }); +} diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithTextstring.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithTextstring.spec.ts new file mode 100644 index 0000000000..36944e5f45 --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithTextstring.spec.ts @@ -0,0 +1,44 @@ +import {AliasHelper, test} from '@umbraco/playwright-testhelpers'; + +const contentName = 'Test Rendering Content'; +const documentTypeName = 'TestDocumentTypeForContent'; +const dataTypeName = 'Textstring'; +const templateName = 'TestTemplateForContent'; +const propertyName = 'Test Textstring'; +let dataTypeData = null; + +test.beforeEach(async ({umbracoApi}) => { + dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); +}); + +test.afterEach(async ({umbracoApi}) => { + await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + await umbracoApi.template.ensureNameNotExists(templateName); +}); + +const textstrings = [ + {type: 'an empty textstring', value: ''}, + {type: 'a non-empty textstring', value: 'Welcome to Umbraco site'}, + {type: 'a textstring contains special characters', value: '@#^&*()_+[]{};:"<>,./?'}, + {type: 'a numeric textstring', value: '0123456789'}, + {type: 'a textstring contains an SQL injection', value: "' OR '1'='1'; --"}, + {type: 'a textstring contains a cross-site scripting', value: ""} +]; + +for (const textstring of textstrings) { + test(`can render content with ${textstring.type}`, {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => { + // Arrange + const textstringValue = textstring.value; + const templateId = await umbracoApi.template.createTemplateWithDisplayingStringValue(templateName, AliasHelper.toAlias(propertyName)); + await umbracoApi.document.createPublishedDocumentWithValue(contentName, textstringValue, dataTypeData.id, templateId, propertyName, documentTypeName); + const contentData = await umbracoApi.document.getByName(contentName); + const contentURL = contentData.urls[0].url; + + // Act + await umbracoUi.contentRender.navigateToRenderedContentPage(contentURL); + + // Assert + await umbracoUi.contentRender.doesContentRenderValueContainText(textstringValue); + }); +} diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithTrueFalse.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithTrueFalse.spec.ts new file mode 100644 index 0000000000..9ef50db657 --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithTrueFalse.spec.ts @@ -0,0 +1,39 @@ +import {AliasHelper, test} from '@umbraco/playwright-testhelpers'; + +const contentName = 'Test Rendering Content'; +const documentTypeName = 'TestDocumentTypeForContent'; +const dataTypeName = 'True/false'; +const templateName = 'TestTemplateForContent'; +const propertyName = 'Test TrueFalse'; +let dataTypeData = null; + +test.beforeEach(async ({umbracoApi}) => { + dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); +}); + +test.afterEach(async ({umbracoApi}) => { + await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + await umbracoApi.template.ensureNameNotExists(templateName); +}); + +const trueFalseValues = [ + {type: 'true value ', value: true, expectedValue: 'True'}, + {type: 'false value', value: false, expectedValue: 'False'}, +]; + +for (const trueFalse of trueFalseValues) { + test(`can render content with ${trueFalse.type}`, async ({umbracoApi, umbracoUi}) => { + // Arrange + const templateId = await umbracoApi.template.createTemplateWithDisplayingStringValue(templateName, AliasHelper.toAlias(propertyName)); + await umbracoApi.document.createPublishedDocumentWithValue(contentName, trueFalse.value, dataTypeData.id, templateId, propertyName, documentTypeName); + const contentData = await umbracoApi.document.getByName(contentName); + const contentURL = contentData.urls[0].url; + + // Act + await umbracoUi.contentRender.navigateToRenderedContentPage(contentURL); + + // Assert + await umbracoUi.contentRender.doesContentRenderValueContainText(trueFalse.expectedValue); + }); +} diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Dashboard/ExamineManagement.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Dashboard/ExamineManagement.spec.ts index b8d0577243..b5b61a5faf 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Dashboard/ExamineManagement.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Dashboard/ExamineManagement.spec.ts @@ -36,7 +36,6 @@ test('can view the details of an index', async ({umbracoApi, umbracoUi}) => { await umbracoUi.examineManagement.doesIndexPropertyHaveValue('CommitCount', indexData.providerProperties.CommitCount.toString()); await umbracoUi.examineManagement.doesIndexPropertyHaveValue('DefaultAnalyzer', indexData.providerProperties.DefaultAnalyzer); await umbracoUi.examineManagement.doesIndexPropertyHaveValue('LuceneDirectory', indexData.providerProperties.LuceneDirectory); - //await umbracoUi.examineManagement.doesIndexPropertyHaveValue('LuceneIndexFolder', indexData.providerProperties.LuceneIndexFolder); await umbracoUi.examineManagement.doesIndexPropertyHaveValue('DirectoryFactory', indexData.providerProperties.DirectoryFactory); await umbracoUi.examineManagement.doesIndexPropertyHaveValue('EnableDefaultEventHandler', indexData.providerProperties.EnableDefaultEventHandler.toString()); await umbracoUi.examineManagement.doesIndexPropertyHaveValue('PublishedValuesOnly', indexData.providerProperties.PublishedValuesOnly.toString()); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Dashboard/PublishedStatus.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Dashboard/PublishedStatus.spec.ts index f9f8ca9a68..8840eeff54 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Dashboard/PublishedStatus.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Dashboard/PublishedStatus.spec.ts @@ -6,19 +6,6 @@ test.beforeEach(async ({umbracoUi}) => { await umbracoUi.publishedStatus.clickPublishedStatusTab(); }); -test('can refresh published cache status', async ({umbracoApi, umbracoUi}) => { - // Arrange - const expectedStatus = await umbracoApi.publishedCache.getStatus(); - - // Act - await umbracoUi.publishedStatus.clickRefreshStatusButton(); - // TODO: create a content item, and check if the ContentStore contains the content or not. - - // Assert - await umbracoUi.publishedStatus.isSuccessButtonWithTextVisible('Refresh Status'); - await umbracoUi.publishedStatus.isPublishedCacheStatusVisible(expectedStatus); -}); - test('can reload the memory cache', async ({umbracoUi}) => { // Act await umbracoUi.publishedStatus.clickReloadMemoryCacheButton(); @@ -36,12 +23,3 @@ test('can rebuild the database cache', async ({umbracoUi}) => { // Assert await umbracoUi.publishedStatus.isSuccessButtonWithTextVisible('Rebuild Database Cache'); }); - -test('can snapshot internal cache', async ({umbracoUi}) => { - // Act - await umbracoUi.publishedStatus.clickSnapshotInternalCacheButton(); - await umbracoUi.publishedStatus.clickContinueButton(); - - // Assert - await umbracoUi.publishedStatus.isSuccessButtonWithTextVisible('Snapshot Internal Cache'); -}); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/DocumentBlueprint/DocumentBlueprint.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/DocumentBlueprint/DocumentBlueprint.spec.ts index db71845ef1..67e5844fee 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/DocumentBlueprint/DocumentBlueprint.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/DocumentBlueprint/DocumentBlueprint.spec.ts @@ -1,4 +1,4 @@ -import {ConstantHelper, test} from '@umbraco/playwright-testhelpers'; +import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers'; import {expect} from "@playwright/test"; const documentBlueprintName = 'TestDocumentBlueprints'; @@ -29,7 +29,7 @@ test('can create a document blueprint from the settings menu', {tag: '@smoke'}, await umbracoUi.documentBlueprint.clickSaveButton(); // Assert - await umbracoUi.documentBlueprint.isSuccessNotificationVisible(); + await umbracoUi.documentBlueprint.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.documentBlueprint.doesNameExist(documentBlueprintName)).toBeTruthy(); await umbracoUi.documentBlueprint.isDocumentBlueprintRootTreeItemVisible(documentBlueprintName, true); }); @@ -48,6 +48,7 @@ test('can rename a document blueprint', async ({umbracoApi, umbracoUi}) => { await umbracoUi.documentBlueprint.clickSaveButton(); // Assert + await umbracoUi.documentBlueprint.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); expect(await umbracoApi.documentBlueprint.doesNameExist(documentBlueprintName)).toBeTruthy(); expect(await umbracoApi.documentBlueprint.doesNameExist(wrongDocumentBlueprintName)).toBeFalsy(); await umbracoUi.documentBlueprint.isDocumentBlueprintRootTreeItemVisible(documentBlueprintName, true, false); @@ -67,7 +68,7 @@ test('can delete a document blueprint', async ({umbracoApi, umbracoUi}) => { await umbracoUi.documentBlueprint.clickConfirmToDeleteButton(); // Assert - await umbracoUi.documentBlueprint.isSuccessNotificationVisible(); + await umbracoUi.documentBlueprint.doesSuccessNotificationHaveText(NotificationConstantHelper.success.deleted); expect(await umbracoApi.documentBlueprint.doesNameExist(documentBlueprintName)).toBeFalsy(); await umbracoUi.documentBlueprint.isDocumentBlueprintRootTreeItemVisible(documentBlueprintName, false, false); }); @@ -85,7 +86,7 @@ test('can create a document blueprint from the content menu', async ({umbracoApi await umbracoUi.content.clickSaveModalButton(); // Assert - await umbracoUi.content.isSuccessNotificationVisible(); + await umbracoUi.documentBlueprint.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.documentBlueprint.doesNameExist(documentBlueprintName)).toBeTruthy(); await umbracoUi.documentBlueprint.goToSettingsTreeItem('Document Blueprints'); await umbracoUi.documentBlueprint.isDocumentBlueprintRootTreeItemVisible(documentBlueprintName, true); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/DocumentType/DocumentType.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/DocumentType/DocumentType.spec.ts index 0794326445..045882fabf 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/DocumentType/DocumentType.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/DocumentType/DocumentType.spec.ts @@ -1,4 +1,4 @@ -import {AliasHelper, ConstantHelper, test} from '@umbraco/playwright-testhelpers'; +import {AliasHelper, ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers'; import {expect} from '@playwright/test'; const documentTypeName = 'TestDocumentType'; @@ -24,7 +24,7 @@ test('can create a document type', {tag: '@smoke'}, async ({umbracoApi, umbracoU await umbracoUi.documentType.clickSaveButton(); // Assert - await umbracoUi.documentType.isSuccessNotificationVisible(); + await umbracoUi.documentType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.documentType.doesNameExist(documentTypeName)).toBeTruthy(); await umbracoUi.documentType.reloadTree('Document Types'); await umbracoUi.documentType.isDocumentTreeItemVisible(documentTypeName); @@ -43,7 +43,7 @@ test('can create a document type with a template', {tag: '@smoke'}, async ({umbr await umbracoUi.documentType.clickSaveButton(); // Assert - // Checks if both the success notification for document Types and teh template are visible + // Checks if both the success notification for document Types and the template are visible await umbracoUi.documentType.doesSuccessNotificationsHaveCount(2); // Checks if the documentType contains the template const documentTypeData = await umbracoApi.documentType.getByName(documentTypeName); @@ -67,7 +67,7 @@ test('can create a element type', {tag: '@smoke'}, async ({umbracoApi, umbracoUi await umbracoUi.documentType.clickSaveButton(); // Assert - await umbracoUi.documentType.isSuccessNotificationVisible(); + await umbracoUi.documentType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.documentType.doesNameExist(documentTypeName)).toBeTruthy(); // Checks if the isElement is true const documentTypeData = await umbracoApi.documentType.getByName(documentTypeName); @@ -87,7 +87,7 @@ test('can rename a document type', {tag: '@smoke'}, async ({umbracoApi, umbracoU await umbracoUi.documentType.clickSaveButton(); // Assert - await umbracoUi.documentType.isSuccessNotificationVisible(); + await umbracoUi.documentType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); expect(await umbracoApi.documentType.doesNameExist(documentTypeName)).toBeTruthy(); await umbracoUi.documentType.isDocumentTreeItemVisible(wrongName, false); await umbracoUi.documentType.isDocumentTreeItemVisible(documentTypeName); @@ -108,7 +108,7 @@ test('can update the alias for a document type', async ({umbracoApi, umbracoUi}) await umbracoUi.documentType.clickSaveButton(); // Assert - await umbracoUi.documentType.isSuccessNotificationVisible(); + await umbracoUi.documentType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); await umbracoUi.documentType.isDocumentTreeItemVisible(documentTypeName, true); const documentTypeDataNew = await umbracoApi.documentType.getByName(documentTypeName); expect(documentTypeDataNew.alias).toBe(newAlias); @@ -126,7 +126,7 @@ test('can add an icon for a document type', {tag: '@smoke'}, async ({umbracoApi, await umbracoUi.documentType.clickSaveButton(); // Assert - await umbracoUi.documentType.isSuccessNotificationVisible(); + await umbracoUi.documentType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const documentTypeData = await umbracoApi.documentType.getByName(documentTypeName); expect(documentTypeData.icon).toBe(bugIcon); await umbracoUi.documentType.isDocumentTreeItemVisible(documentTypeName, true); @@ -144,6 +144,6 @@ test('can delete a document type', {tag: '@smoke'}, async ({umbracoApi, umbracoU await umbracoUi.documentType.clickDeleteAndConfirmButton(); // Assert - await umbracoUi.documentType.isSuccessNotificationVisible(); + await umbracoUi.documentType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.deleted); expect(await umbracoApi.documentType.doesNameExist(documentTypeName)).toBeFalsy(); }); \ No newline at end of file diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/DocumentType/DocumentTypeFolder.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/DocumentType/DocumentTypeFolder.spec.ts index a96999f441..dacd51f82a 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/DocumentType/DocumentTypeFolder.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/DocumentType/DocumentTypeFolder.spec.ts @@ -1,4 +1,4 @@ -import {ConstantHelper, test} from '@umbraco/playwright-testhelpers'; +import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers'; import {expect} from '@playwright/test'; const documentFolderName = 'TestFolder'; @@ -22,7 +22,7 @@ test('can create a empty document type folder', {tag: '@smoke'}, async ({umbraco await umbracoUi.documentType.clickCreateFolderButton(); // Assert - await umbracoUi.documentType.isSuccessNotificationVisible(); + await umbracoUi.documentType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); const folder = await umbracoApi.documentType.getByName(documentFolderName); expect(folder.name).toBe(documentFolderName); // Checks if the folder is in the root @@ -41,7 +41,7 @@ test('can delete a document type folder', {tag: '@smoke'}, async ({umbracoApi, u await umbracoUi.documentType.deleteFolder(); // Assert - await umbracoUi.documentType.isSuccessNotificationVisible(); + await umbracoUi.documentType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.deleted); await umbracoApi.documentType.doesNameExist(documentFolderName); await umbracoUi.documentType.isDocumentTreeItemVisible(documentFolderName, false); }); @@ -61,7 +61,7 @@ test('can rename a document type folder', async ({umbracoApi, umbracoUi}) => { await umbracoUi.documentType.clickConfirmRenameFolderButton(); // Assert - await umbracoUi.documentType.isSuccessNotificationVisible(); + await umbracoUi.documentType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const folder = await umbracoApi.documentType.getByName(documentFolderName); expect(folder.name).toBe(documentFolderName); await umbracoUi.documentType.isDocumentTreeItemVisible(oldFolderName, false); @@ -84,7 +84,7 @@ test('can create a document type folder in a folder', async ({umbracoApi, umbrac await umbracoUi.documentType.clickCreateFolderButton(); // Assert - await umbracoUi.documentType.isSuccessNotificationVisible(); + await umbracoUi.documentType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); const folder = await umbracoApi.documentType.getByName(childFolderName); expect(folder.name).toBe(childFolderName); // Checks if the parentFolder contains the ChildFolder as a child @@ -115,7 +115,7 @@ test('can create a folder in a folder in a folder', {tag: '@smoke'}, async ({umb await umbracoUi.documentType.clickCreateFolderButton(); // Assert - await umbracoUi.documentType.isSuccessNotificationVisible(); + await umbracoUi.documentType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); await umbracoUi.documentType.reloadTree(parentFolderName); await umbracoUi.documentType.isDocumentTreeItemVisible(documentFolderName); const grandParentChildren = await umbracoApi.documentType.getChildren(grandParentFolderId); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/DocumentType/DocumentTypeTemplatesTab.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/DocumentType/DocumentTypeTemplatesTab.spec.ts index 998843d9ca..e008523c2d 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/DocumentType/DocumentTypeTemplatesTab.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/DocumentType/DocumentTypeTemplatesTab.spec.ts @@ -73,4 +73,4 @@ test.skip('can remove an allowed template from a document type', async ({umbraco await umbracoUi.documentType.isSuccessNotificationVisible(); const documentTypeData = await umbracoApi.documentType.getByName(documentTypeName); expect(documentTypeData.allowedTemplates).toHaveLength(0); -}); \ No newline at end of file +}); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Language/Language.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Language/Language.spec.ts index 9d756daab3..fb1e9c7a7a 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Language/Language.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Language/Language.spec.ts @@ -1,4 +1,4 @@ -import {test} from '@umbraco/playwright-testhelpers'; +import {NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers'; import {expect} from "@playwright/test"; const languageName = 'Arabic'; @@ -25,7 +25,7 @@ test('can add language', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => { await umbracoUi.language.clickSaveButton(); // Assert - await umbracoUi.language.isSuccessNotificationVisible(); + await umbracoUi.language.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.language.doesExist(isoCode)).toBeTruthy(); // Verify the created language displays in the list await umbracoUi.language.clickLanguagesMenu(); @@ -44,7 +44,7 @@ test('can update default language option', {tag: '@smoke'}, async ({umbracoApi, await umbracoUi.language.clickSaveButton(); // Assert - await umbracoUi.language.isSuccessNotificationVisible(); + await umbracoUi.language.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const languageData = await umbracoApi.language.get(isoCode); expect(languageData.isDefault).toBe(true); @@ -67,7 +67,7 @@ test('can update mandatory language option', async ({umbracoApi, umbracoUi}) => await umbracoUi.language.clickSaveButton(); // Assert - await umbracoUi.language.isSuccessNotificationVisible(); + await umbracoUi.language.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const languageData = await umbracoApi.language.get(isoCode); expect(languageData.isMandatory).toBe(true); }); @@ -82,7 +82,7 @@ test('can delete language', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => await umbracoUi.language.removeLanguageByName(languageName); // Assert - await umbracoUi.language.isSuccessNotificationVisible(); + await umbracoUi.language.doesSuccessNotificationHaveText(NotificationConstantHelper.success.deleted); expect(await umbracoApi.language.doesExist(isoCode)).toBeFalsy(); await umbracoUi.language.isLanguageNameVisible(languageName, false); }); @@ -99,7 +99,7 @@ test('can remove fallback language', async ({umbracoApi, umbracoUi}) => { await umbracoUi.language.clickSaveButton(); // Act - await umbracoUi.language.isSuccessNotificationVisible(); + await umbracoUi.language.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const languageData = await umbracoApi.language.get(isoCode); expect(languageData.fallbackIsoCode).toBeFalsy(); }); @@ -117,7 +117,7 @@ test('can add fallback language', async ({umbracoApi, umbracoUi}) => { await umbracoUi.language.clickSaveButton(); // Act - await umbracoUi.language.isSuccessNotificationVisible(); + await umbracoUi.language.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const languageData = await umbracoApi.language.get(isoCode); expect(languageData.fallbackIsoCode).toBe(defaultLanguageIsoCode); }); @@ -134,5 +134,5 @@ test('cannot add a language with duplicate ISO code', async ({umbracoApi, umbrac await umbracoUi.language.clickSaveButton(); // Assert - await umbracoUi.language.isErrorNotificationVisible(); + await umbracoUi.language.doesErrorNotificationHaveText(NotificationConstantHelper.error.duplicateISOcode); }); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/MediaType/MediaType.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/MediaType/MediaType.spec.ts index 96d562206e..0690dac4ef 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/MediaType/MediaType.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/MediaType/MediaType.spec.ts @@ -1,5 +1,5 @@ import {expect} from "@playwright/test"; -import {AliasHelper, ConstantHelper, test} from '@umbraco/playwright-testhelpers'; +import {AliasHelper, ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers'; const mediaTypeName = 'TestMediaType'; @@ -22,7 +22,7 @@ test('can create a media type', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) await umbracoUi.mediaType.clickSaveButton(); // Assert - await umbracoUi.mediaType.isSuccessNotificationVisible(); + await umbracoUi.mediaType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.mediaType.doesNameExist(mediaTypeName)).toBeTruthy(); }); @@ -38,7 +38,7 @@ test('can rename a media type', async ({umbracoApi, umbracoUi}) => { await umbracoUi.mediaType.clickSaveButton(); // Assert - await umbracoUi.mediaType.isSuccessNotificationVisible(); + await umbracoUi.mediaType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); expect(await umbracoApi.mediaType.doesNameExist(mediaTypeName)).toBeTruthy(); }); @@ -56,7 +56,7 @@ test('can update the alias for a media type', async ({umbracoApi, umbracoUi}) => await umbracoUi.mediaType.clickSaveButton(); // Assert - await umbracoUi.mediaType.isSuccessNotificationVisible(); + await umbracoUi.mediaType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const mediaTypeData = await umbracoApi.mediaType.getByName(mediaTypeName); expect(mediaTypeData.alias).toBe(updatedAlias); }); @@ -72,7 +72,7 @@ test('can add an icon for a media type', {tag: '@smoke'}, async ({umbracoApi, um await umbracoUi.mediaType.clickSaveButton(); // Assert - await umbracoUi.mediaType.isSuccessNotificationVisible(); + await umbracoUi.mediaType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const mediaTypeData = await umbracoApi.mediaType.getByName(mediaTypeName); expect(mediaTypeData.icon).toBe(bugIcon); await umbracoUi.mediaType.isTreeItemVisible(mediaTypeName, true); @@ -89,6 +89,6 @@ test('can delete a media type', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) await umbracoUi.mediaType.clickConfirmToDeleteButton(); // Assert - await umbracoUi.mediaType.isSuccessNotificationVisible(); + await umbracoUi.mediaType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.deleted); expect(await umbracoApi.mediaType.doesNameExist(mediaTypeName)).toBeFalsy(); }); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/MediaType/MediaTypeFolder.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/MediaType/MediaTypeFolder.spec.ts index 83006c9e54..cea63f0f48 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/MediaType/MediaTypeFolder.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/MediaType/MediaTypeFolder.spec.ts @@ -1,4 +1,4 @@ -import {ConstantHelper, test} from '@umbraco/playwright-testhelpers'; +import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers'; import {expect} from "@playwright/test"; const mediaTypeFolderName = 'TestMediaTypeFolder'; @@ -19,7 +19,7 @@ test('can create a empty media type folder', async ({umbracoApi, umbracoUi}) => await umbracoUi.mediaType.createFolder(mediaTypeFolderName); // Assert - await umbracoUi.mediaType.isSuccessNotificationVisible(); + await umbracoUi.mediaType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); const folder = await umbracoApi.mediaType.getByName(mediaTypeFolderName); expect(folder.name).toBe(mediaTypeFolderName); // Checks if the folder is in the root @@ -37,7 +37,7 @@ test('can delete a media type folder', async ({umbracoApi, umbracoUi}) => { await umbracoUi.mediaType.deleteFolder(); // Assert - await umbracoUi.mediaType.isSuccessNotificationVisible(); + await umbracoUi.mediaType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.deleted); expect(await umbracoApi.mediaType.doesNameExist(mediaTypeFolderName)).toBeFalsy(); }); @@ -55,7 +55,7 @@ test('can rename a media type folder', async ({umbracoApi, umbracoUi}) => { await umbracoUi.mediaType.clickConfirmRenameFolderButton(); // Assert - await umbracoUi.mediaType.isSuccessNotificationVisible(); + await umbracoUi.mediaType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const folder = await umbracoApi.mediaType.getByName(mediaTypeFolderName); expect(folder.name).toBe(mediaTypeFolderName); }); @@ -72,6 +72,7 @@ test('can create a media type folder in a folder', async ({umbracoApi, umbracoUi await umbracoUi.mediaType.createFolder(childFolderName); // Assert + await umbracoUi.mediaType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); await umbracoUi.mediaType.clickCaretButtonForName(mediaTypeFolderName); await umbracoUi.mediaType.isTreeItemVisible(childFolderName, true); const parentFolderChildren = await umbracoApi.mediaType.getChildren(parentFolderId); @@ -97,6 +98,7 @@ test('can create a media type folder in a folder in a folder', async ({umbracoAp await umbracoUi.mediaType.createFolder(childFolderName); // Assert + await umbracoUi.mediaType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); await umbracoUi.mediaType.clickCaretButtonForName(mediaTypeFolderName); await umbracoUi.mediaType.isTreeItemVisible(childFolderName, true); const grandParentFolderChildren = await umbracoApi.mediaType.getChildren(grandParentFolderId); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/PartialView/PartialView.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/PartialView/PartialView.spec.ts index 71a2dcdb69..f1155332f8 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/PartialView/PartialView.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/PartialView/PartialView.spec.ts @@ -1,4 +1,4 @@ -import {ConstantHelper, test} from '@umbraco/playwright-testhelpers'; +import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers'; import {expect} from "@playwright/test"; const partialViewName = 'TestPartialView'; @@ -26,7 +26,7 @@ test('can create an empty partial view', {tag: '@smoke'}, async ({umbracoApi, um await umbracoUi.partialView.clickSaveButton(); // Assert - await umbracoUi.partialView.isSuccessNotificationVisible(); + await umbracoUi.partialView.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.partialView.doesNameExist(partialViewFileName)).toBeTruthy(); // Verify the new partial view is displayed under the Partial Views section await umbracoUi.partialView.isPartialViewRootTreeItemVisible(partialViewFileName); @@ -46,7 +46,7 @@ test('can create a partial view from snippet', async ({umbracoApi, umbracoUi}) = await umbracoUi.partialView.clickSaveButton(); // Assert - await umbracoUi.partialView.isSuccessNotificationVisible(); + await umbracoUi.partialView.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.partialView.doesExist(partialViewFileName)).toBeTruthy(); const partialViewData = await umbracoApi.partialView.getByName(partialViewFileName); @@ -80,7 +80,7 @@ test('can rename a partial view', {tag: '@smoke'}, async ({umbracoApi, umbracoUi await umbracoUi.partialView.rename(partialViewName); // Assert - await umbracoUi.partialView.isSuccessNotificationVisible(); + await umbracoUi.partialView.doesSuccessNotificationHaveText(NotificationConstantHelper.success.renamed); expect(await umbracoApi.partialView.doesNameExist(partialViewFileName)).toBeTruthy(); expect(await umbracoApi.partialView.doesNameExist(wrongPartialViewFileName)).toBeFalsy(); // Verify the old partial view is NOT displayed under the Partial Views section @@ -106,7 +106,7 @@ test('can update a partial view content', {tag: '@smoke'}, async ({umbracoApi, u await umbracoUi.partialView.clickSaveButton(); // Assert - await umbracoUi.partialView.isSuccessNotificationVisible(); + await umbracoUi.partialView.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const updatedPartialView = await umbracoApi.partialView.getByName(partialViewFileName); expect(updatedPartialView.content).toBe(updatedPartialViewContent); }); @@ -145,7 +145,7 @@ test('can use query builder with Order By statement for a partial view', async ( await umbracoUi.partialView.clickSaveButton(); // Assert - await umbracoUi.partialView.isSuccessNotificationVisible(); + await umbracoUi.partialView.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const updatedPartialView = await umbracoApi.partialView.getByName(partialViewFileName); expect(updatedPartialView.content).toBe(expectedTemplateContent); }); @@ -178,6 +178,7 @@ test('can use query builder with Where statement for a partial view', async ({um // Act await umbracoUi.partialView.openPartialViewAtRoot(partialViewFileName); + await umbracoUi.waitForTimeout(500); await umbracoUi.partialView.addQueryBuilderWithWhereStatement(propertyAliasValue, operatorValue, constrainValue); // Verify that the code is shown await umbracoUi.partialView.isQueryBuilderCodeShown(expectedCode); @@ -185,7 +186,7 @@ test('can use query builder with Where statement for a partial view', async ({um await umbracoUi.partialView.clickSaveButton(); // Assert - await umbracoUi.partialView.isSuccessNotificationVisible(); + await umbracoUi.partialView.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const updatedPartialView = await umbracoApi.partialView.getByName(partialViewFileName); expect(updatedPartialView.content).toBe(expectedTemplateContent); }); @@ -206,7 +207,7 @@ test('can insert dictionary item into a partial view', async ({umbracoApi, umbra await umbracoUi.partialView.clickSaveButton(); // Assert - await umbracoUi.partialView.isSuccessNotificationVisible(); + await umbracoUi.partialView.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const partialViewData = await umbracoApi.partialView.getByName(partialViewFileName); expect(partialViewData.content).toBe(partialViewContent); }); @@ -225,7 +226,7 @@ test('can insert value into a partial view', async ({umbracoApi, umbracoUi}) => await umbracoUi.template.clickSaveButton(); // Assert - await umbracoUi.partialView.isSuccessNotificationVisible(); + await umbracoUi.partialView.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const partialViewData = await umbracoApi.partialView.getByName(partialViewFileName); expect(partialViewData.content).toBe(partialViewContent); }); @@ -241,7 +242,7 @@ test('can delete a partial view', {tag: '@smoke'}, async ({umbracoApi, umbracoUi await umbracoUi.partialView.clickDeleteAndConfirmButton(); // Assert - await umbracoUi.partialView.isSuccessNotificationVisible(); + await umbracoUi.partialView.doesSuccessNotificationHaveText(NotificationConstantHelper.success.deleted); expect(await umbracoApi.partialView.doesExist(partialViewFileName)).toBeFalsy(); // Verify the partial view is NOT displayed under the Partial Views section await umbracoUi.partialView.clickRootFolderCaretButton(); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/PartialView/PartialViewFolder.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/PartialView/PartialViewFolder.spec.ts index 58741a3d7a..239c9e1f2c 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/PartialView/PartialViewFolder.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/PartialView/PartialViewFolder.spec.ts @@ -1,4 +1,4 @@ -import {ConstantHelper, test} from '@umbraco/playwright-testhelpers'; +import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers'; import {expect} from "@playwright/test"; const partialViewName = 'TestPartialView'; @@ -23,7 +23,7 @@ test('can create a folder', async ({umbracoApi, umbracoUi}) => { await umbracoUi.partialView.createFolder(folderName); // Assert - await umbracoUi.partialView.isSuccessNotificationVisible(); + await umbracoUi.partialView.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.partialView.doesFolderExist(folderName)).toBeTruthy(); // Verify the partial view folder is displayed under the Partial Views section await umbracoUi.partialView.clickRootFolderCaretButton(); @@ -65,7 +65,7 @@ test('can create a partial view in a folder', async ({umbracoApi, umbracoUi}) => await umbracoUi.partialView.clickSaveButton(); // Assert - await umbracoUi.partialView.isSuccessNotificationVisible(); + await umbracoUi.partialView.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); const childrenData = await umbracoApi.partialView.getChildren(folderPath); expect(childrenData[0].name).toEqual(partialViewFileName); // Verify the partial view is displayed in the folder under the Partial Views section @@ -94,7 +94,7 @@ test('can create a partial view in a folder in a folder', async ({umbracoApi, um await umbracoUi.partialView.clickSaveButton(); // Assert - await umbracoUi.partialView.isSuccessNotificationVisible(); + await umbracoUi.partialView.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); const childFolderChildrenData = await umbracoApi.partialView.getChildren(childFolderPath); expect(childFolderChildrenData[0].name).toEqual(partialViewFileName); @@ -114,7 +114,7 @@ test('can create a folder in a folder', async ({umbracoApi, umbracoUi}) => { await umbracoUi.partialView.createFolder(childFolderName); // Assert - await umbracoUi.partialView.isSuccessNotificationVisible(); + await umbracoUi.partialView.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.partialView.doesNameExist(childFolderName)).toBeTruthy(); const partialViewChildren = await umbracoApi.partialView.getChildren('/' + folderName); expect(partialViewChildren[0].path).toBe('/' + folderName + '/' + childFolderName); @@ -137,7 +137,7 @@ test('can create a folder in a folder in a folder', {tag: '@smoke'}, async ({umb await umbracoUi.partialView.createFolder(childOfChildFolderName); // Assert - await umbracoUi.partialView.isSuccessNotificationVisible(); + await umbracoUi.partialView.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.partialView.doesNameExist(childOfChildFolderName)).toBeTruthy(); const partialViewChildren = await umbracoApi.partialView.getChildren('/' + folderName + '/' + childFolderName); expect(partialViewChildren[0].path).toBe('/' + folderName + '/' + childFolderName + '/' + childOfChildFolderName); @@ -158,5 +158,5 @@ test('cannot delete non-empty folder', async ({umbracoApi, umbracoUi}) => { await umbracoUi.partialView.deleteFolder(); // Assert - await umbracoUi.script.isErrorNotificationVisible(); + await umbracoUi.partialView.doesErrorNotificationHaveText(NotificationConstantHelper.error.notEmpty); }); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Script/Script.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Script/Script.spec.ts index 282a503021..902082cf19 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Script/Script.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Script/Script.spec.ts @@ -1,4 +1,4 @@ -import {ConstantHelper, test} from '@umbraco/playwright-testhelpers'; +import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers'; import {expect} from '@playwright/test'; const scriptName = 'TestScript.js'; @@ -25,7 +25,7 @@ test('can create a empty script', {tag: '@smoke'}, async ({umbracoApi, umbracoUi await umbracoUi.script.clickSaveButton(); // Assert - await umbracoUi.script.isSuccessNotificationVisible(); + await umbracoUi.script.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.script.doesNameExist(scriptName)).toBeTruthy(); await umbracoUi.script.isScriptRootTreeItemVisible(scriptName); }); @@ -44,7 +44,7 @@ test('can create a script with content', async ({umbracoApi, umbracoUi}) => { await umbracoUi.script.clickSaveButton(); // Assert - await umbracoUi.script.isSuccessNotificationVisible(); + await umbracoUi.script.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.script.doesNameExist(scriptName)).toBeTruthy(); const scriptData = await umbracoApi.script.getByName(scriptName); expect(scriptData.content).toBe(scriptContent); @@ -63,7 +63,7 @@ test('can update a script', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => await umbracoUi.script.clickSaveButton(); // Assert - await umbracoUi.script.isSuccessNotificationVisible(); + await umbracoUi.script.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const updatedScript = await umbracoApi.script.get(scriptPath); expect(updatedScript.content).toBe(updatedScriptContent); }); @@ -79,7 +79,7 @@ test('can delete a script', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => await umbracoUi.script.clickDeleteAndConfirmButton(); // Assert - await umbracoUi.script.isSuccessNotificationVisible(); + await umbracoUi.script.doesSuccessNotificationHaveText(NotificationConstantHelper.success.deleted); expect(await umbracoApi.script.doesNameExist(scriptName)).toBeFalsy(); await umbracoUi.script.isScriptRootTreeItemVisible(scriptName, false, false); }); @@ -96,7 +96,7 @@ test('can rename a script', async ({umbracoApi, umbracoUi}) => { await umbracoUi.script.rename(scriptName); // Assert - await umbracoUi.script.isSuccessNotificationVisible(); + await umbracoUi.script.doesSuccessNotificationHaveText(NotificationConstantHelper.success.renamed); expect(await umbracoApi.script.doesNameExist(scriptName)).toBeTruthy(); expect(await umbracoApi.script.doesNameExist(wrongScriptName)).toBeFalsy(); }); @@ -104,7 +104,7 @@ test('can rename a script', async ({umbracoApi, umbracoUi}) => { test('cannot create a script with an empty name', async ({umbracoApi, umbracoUi}) => { // Arrange await umbracoUi.script.goToSection(ConstantHelper.sections.settings); - + // Act await umbracoUi.script.clickActionsMenuAtRoot(); await umbracoUi.script.clickCreateButton(); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Script/ScriptFolder.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Script/ScriptFolder.spec.ts index ef99ac0e41..2676911ec2 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Script/ScriptFolder.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Script/ScriptFolder.spec.ts @@ -1,4 +1,4 @@ -import {ConstantHelper, test} from '@umbraco/playwright-testhelpers'; +import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers'; import {expect} from '@playwright/test'; const scriptName = 'TestScript.js'; @@ -23,7 +23,7 @@ test('can create a folder', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => await umbracoUi.waitForTimeout(1000); // Assert - await umbracoUi.script.isSuccessNotificationVisible(); + await umbracoUi.script.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.script.doesFolderExist(scriptFolderName)).toBeTruthy(); await umbracoUi.script.isScriptRootTreeItemVisible(scriptFolderName); }); @@ -39,7 +39,7 @@ test('can delete a folder', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => await umbracoUi.script.deleteFolder(); // Assert - await umbracoUi.script.isSuccessNotificationVisible(); + await umbracoUi.script.doesSuccessNotificationHaveText(NotificationConstantHelper.success.deleted); expect(await umbracoApi.script.doesFolderExist(scriptFolderName)).toBeFalsy(); await umbracoUi.script.isScriptRootTreeItemVisible(scriptFolderName, false, false); }); @@ -60,7 +60,7 @@ test('can create a script in a folder', async ({umbracoApi, umbracoUi}) => { await umbracoUi.script.clickSaveButton(); // Assert - await umbracoUi.script.isSuccessNotificationVisible(); + await umbracoUi.script.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.script.doesNameExist(scriptName)).toBeTruthy(); const scriptChildren = await umbracoApi.script.getChildren('/' + scriptFolderName); expect(scriptChildren[0].path).toBe('/' + scriptFolderName + '/' + scriptName); @@ -82,7 +82,7 @@ test('can create a folder in a folder', async ({umbracoApi, umbracoUi}) => { await umbracoUi.script.createFolder(childFolderName); // Assert - await umbracoUi.script.isSuccessNotificationVisible(); + await umbracoUi.script.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.script.doesNameExist(childFolderName)).toBeTruthy(); const scriptChildren = await umbracoApi.script.getChildren('/' + scriptFolderName); expect(scriptChildren[0].path).toBe('/' + scriptFolderName + '/' + childFolderName); @@ -105,7 +105,7 @@ test('can create a folder in a folder in a folder', {tag: '@smoke'}, async ({umb await umbracoUi.script.createFolder(childOfChildFolderName); // Assert - await umbracoUi.script.isSuccessNotificationVisible(); + await umbracoUi.script.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.script.doesNameExist(childOfChildFolderName)).toBeTruthy(); const scriptChildren = await umbracoApi.script.getChildren('/' + scriptFolderName + '/' + childFolderName); expect(scriptChildren[0].path).toBe('/' + scriptFolderName + '/' + childFolderName + '/' + childOfChildFolderName); @@ -130,7 +130,7 @@ test('can create a script in a folder in a folder', async ({umbracoApi, umbracoU await umbracoUi.script.clickSaveButton(); // Assert - await umbracoUi.script.isSuccessNotificationVisible(); + await umbracoUi.script.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.script.doesNameExist(scriptName)).toBeTruthy(); const scriptChildren = await umbracoApi.script.getChildren('/' + scriptFolderName + '/' + childFolderName); expect(scriptChildren[0].path).toBe('/' + scriptFolderName + '/' + childFolderName + '/' + scriptName); @@ -151,5 +151,5 @@ test('cannot delete non-empty folder', async ({umbracoApi, umbracoUi}) => { await umbracoUi.script.deleteFolder(); // Assert - await umbracoUi.script.isErrorNotificationVisible(); + await umbracoUi.script.doesErrorNotificationHaveText(NotificationConstantHelper.error.notEmpty); }); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Stylesheet/Stylesheet.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Stylesheet/Stylesheet.spec.ts index 43ee3af2d7..bd6de28725 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Stylesheet/Stylesheet.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Stylesheet/Stylesheet.spec.ts @@ -1,4 +1,4 @@ -import {ConstantHelper, test} from '@umbraco/playwright-testhelpers'; +import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers'; import {expect} from '@playwright/test'; const stylesheetName = 'TestStyleSheetFile.css'; @@ -27,7 +27,7 @@ test('can create a empty stylesheet', {tag: '@smoke'}, async ({umbracoApi, umbra await umbracoUi.stylesheet.clickSaveButton(); // Assert - await umbracoUi.stylesheet.isSuccessNotificationVisible(); + await umbracoUi.stylesheet.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.stylesheet.doesNameExist(stylesheetName)).toBeTruthy(); await umbracoUi.stylesheet.isStylesheetRootTreeItemVisible(stylesheetName); }); @@ -46,7 +46,7 @@ test('can create a stylesheet with content', async ({umbracoApi, umbracoUi}) => await umbracoUi.stylesheet.clickSaveButton(); // Assert - await umbracoUi.stylesheet.isSuccessNotificationVisible(); + await umbracoUi.stylesheet.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.stylesheet.doesNameExist(stylesheetName)).toBeTruthy(); const stylesheetData = await umbracoApi.stylesheet.getByName(stylesheetName); expect(stylesheetData.content).toEqual(stylesheetContent); @@ -67,7 +67,7 @@ test.skip('can create a new Rich Text Editor stylesheet file', {tag: '@smoke'}, await umbracoUi.stylesheet.clickSaveButton(); // Assert - await umbracoUi.stylesheet.isSuccessNotificationVisible(); + await umbracoUi.stylesheet.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.stylesheet.doesExist(stylesheetName)).toBeTruthy(); const stylesheetData = await umbracoApi.stylesheet.getByName(stylesheetName); expect(stylesheetData.content).toEqual(stylesheetContent); @@ -87,7 +87,7 @@ test.skip('can update a stylesheet', {tag: '@smoke'}, async ({umbracoApi, umbrac await umbracoUi.stylesheet.clickSaveButton(); // Assert - await umbracoUi.stylesheet.isSuccessNotificationVisible(); + await umbracoUi.stylesheet.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const stylesheetData = await umbracoApi.stylesheet.getByName(stylesheetName); expect(stylesheetData.content).toEqual(stylesheetContent); }); @@ -103,7 +103,7 @@ test('can delete a stylesheet', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) await umbracoUi.stylesheet.clickDeleteAndConfirmButton(); // Assert - await umbracoUi.stylesheet.isSuccessNotificationVisible(); + await umbracoUi.stylesheet.doesSuccessNotificationHaveText(NotificationConstantHelper.success.deleted); expect(await umbracoApi.stylesheet.doesNameExist(stylesheetName)).toBeFalsy(); await umbracoUi.stylesheet.isStylesheetRootTreeItemVisible(stylesheetName, false, false); }); @@ -121,7 +121,7 @@ test('can rename a stylesheet', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) await umbracoUi.stylesheet.rename(stylesheetName); // Assert - await umbracoUi.stylesheet.isSuccessNotificationVisible(); + await umbracoUi.stylesheet.doesSuccessNotificationHaveText(NotificationConstantHelper.success.renamed); expect(await umbracoApi.stylesheet.doesNameExist(stylesheetName)).toBeTruthy(); expect(await umbracoApi.stylesheet.doesNameExist(wrongStylesheetName)).toBeFalsy(); }); @@ -143,7 +143,7 @@ test('can edit rich text editor styles', async ({umbracoApi, umbracoUi}) => { await umbracoUi.stylesheet.clickSaveButton(); // Assert - await umbracoUi.stylesheet.isSuccessNotificationVisible(); + await umbracoUi.stylesheet.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const stylesheetData = await umbracoApi.stylesheet.getByName(stylesheetName); expect(stylesheetData.content).toEqual(newStylesheetContent); }); @@ -161,7 +161,7 @@ test('can remove rich text editor styles', async ({umbracoApi, umbracoUi}) => { await umbracoUi.stylesheet.clickSaveButton(); // Assert - await umbracoUi.stylesheet.isSuccessNotificationVisible(); + await umbracoUi.stylesheet.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const stylesheetData = await umbracoApi.stylesheet.getByName(stylesheetName); expect(stylesheetData.content).toEqual(''); }); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Stylesheet/StylesheetFolder.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Stylesheet/StylesheetFolder.spec.ts index 30e01aebda..8871837fce 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Stylesheet/StylesheetFolder.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Stylesheet/StylesheetFolder.spec.ts @@ -1,4 +1,4 @@ -import {ConstantHelper, test} from '@umbraco/playwright-testhelpers'; +import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers'; import {expect} from '@playwright/test'; const stylesheetName = 'TestStyleSheetFile.css'; @@ -23,7 +23,7 @@ test('can create a folder', async ({umbracoApi, umbracoUi}) => { await umbracoUi.waitForTimeout(1000); // Assert - await umbracoUi.stylesheet.isSuccessNotificationVisible(); + await umbracoUi.stylesheet.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.stylesheet.doesFolderExist(stylesheetFolderName)).toBeTruthy(); await umbracoUi.stylesheet.isStylesheetRootTreeItemVisible(stylesheetFolderName); }); @@ -39,7 +39,7 @@ test('can delete a folder', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => await umbracoUi.stylesheet.deleteFolder(); // Assert - await umbracoUi.stylesheet.isSuccessNotificationVisible(); + await umbracoUi.stylesheet.doesSuccessNotificationHaveText(NotificationConstantHelper.success.deleted); expect(await umbracoApi.stylesheet.doesFolderExist(stylesheetFolderName)).toBeFalsy(); await umbracoUi.stylesheet.isStylesheetRootTreeItemVisible(stylesheetFolderName, false, false); }); @@ -56,7 +56,7 @@ test('can create a folder in a folder', async ({umbracoApi, umbracoUi}) => { await umbracoUi.stylesheet.createFolder(childFolderName); //Assert - await umbracoUi.stylesheet.isSuccessNotificationVisible(); + await umbracoUi.stylesheet.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.stylesheet.doesNameExist(childFolderName)).toBeTruthy(); const styleChildren = await umbracoApi.stylesheet.getChildren('/' + stylesheetFolderName); expect(styleChildren[0].path).toBe('/' + stylesheetFolderName + '/' + childFolderName); @@ -79,7 +79,7 @@ test('can create a folder in a folder in a folder', {tag: '@smoke'}, async ({umb await umbracoUi.stylesheet.createFolder(childOfChildFolderName); //Assert - await umbracoUi.stylesheet.isSuccessNotificationVisible(); + await umbracoUi.stylesheet.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.stylesheet.doesNameExist(childOfChildFolderName)).toBeTruthy(); const styleChildren = await umbracoApi.stylesheet.getChildren('/' + stylesheetFolderName + '/' + childFolderName); expect(styleChildren[0].path).toBe('/' + stylesheetFolderName + '/' + childFolderName + '/' + childOfChildFolderName); @@ -103,7 +103,7 @@ test('can create a stylesheet in a folder', async ({umbracoApi, umbracoUi}) => { await umbracoUi.stylesheet.clickSaveButton(); // Assert - await umbracoUi.stylesheet.isSuccessNotificationVisible(); + await umbracoUi.stylesheet.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.stylesheet.doesNameExist(stylesheetName)).toBeTruthy(); const stylesheetChildren = await umbracoApi.stylesheet.getChildren('/' + stylesheetFolderName); expect(stylesheetChildren[0].path).toBe('/' + stylesheetFolderName + '/' + stylesheetName); @@ -132,7 +132,7 @@ test('can create a stylesheet in a folder in a folder', async ({umbracoApi, umbr await umbracoUi.stylesheet.clickSaveButton(); // Assert - await umbracoUi.stylesheet.isSuccessNotificationVisible(); + await umbracoUi.stylesheet.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.stylesheet.doesNameExist(stylesheetName)).toBeTruthy(); const stylesheetChildren = await umbracoApi.stylesheet.getChildren('/' + stylesheetFolderName + '/' + childFolderName); expect(stylesheetChildren[0].path).toBe('/' + stylesheetFolderName + '/' + childFolderName + '/' + stylesheetName); @@ -155,5 +155,5 @@ test('cannot delete non-empty folder', async ({umbracoApi, umbracoUi}) => { await umbracoUi.stylesheet.deleteFolder(); //Assert - await umbracoUi.stylesheet.isErrorNotificationVisible(); -}); \ No newline at end of file + await umbracoUi.stylesheet.doesErrorNotificationHaveText(NotificationConstantHelper.error.notEmpty); +}); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Template/Templates.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Template/Templates.spec.ts index fcb89f59c9..106d2102f4 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Template/Templates.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Template/Templates.spec.ts @@ -1,4 +1,4 @@ -import {AliasHelper, ConstantHelper, test} from '@umbraco/playwright-testhelpers'; +import {AliasHelper, ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers'; import {expect} from "@playwright/test"; const templateName = 'TestTemplate'; @@ -24,7 +24,7 @@ test('can create a template', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) = await umbracoUi.template.clickSaveButton(); // Assert - await umbracoUi.template.isSuccessNotificationVisible(); + await umbracoUi.template.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.template.doesNameExist(templateName)).toBeTruthy(); await umbracoUi.template.isTemplateRootTreeItemVisible(templateName); }); @@ -38,11 +38,12 @@ test('can update content of a template', {tag: '@smoke'}, async ({umbracoApi, um // Act await umbracoUi.template.goToTemplate(templateName); + await umbracoUi.template.enterTemplateContent(''); await umbracoUi.template.enterTemplateContent(updatedTemplateContent); await umbracoUi.template.clickSaveButton(); // Assert - await umbracoUi.template.isSuccessNotificationVisible(); + await umbracoUi.template.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); // Checks if the template was updated const updatedTemplate = await umbracoApi.template.getByName(templateName); expect(updatedTemplate.content).toBe(updatedTemplateContent); @@ -62,7 +63,7 @@ test('can rename a template', async ({umbracoApi, umbracoUi}) => { await umbracoUi.template.clickSaveButton(); // Assert - await umbracoUi.template.isSuccessNotificationVisible(); + await umbracoUi.template.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const templateData = await umbracoApi.template.get(templateId); expect(templateData.name).toBe(templateName); }); @@ -78,7 +79,7 @@ test('can delete a template', async ({umbracoApi, umbracoUi}) => { await umbracoUi.template.clickDeleteAndConfirmButton(); // Assert - await umbracoUi.template.isSuccessNotificationVisible(); + await umbracoUi.template.doesSuccessNotificationHaveText(NotificationConstantHelper.success.deleted); expect(await umbracoApi.template.doesNameExist(templateName)).toBeFalsy(); await umbracoUi.template.isTemplateRootTreeItemVisible(templateName, false); }); @@ -98,7 +99,7 @@ test('can set a template as master template', async ({umbracoApi, umbracoUi}) => await umbracoUi.template.clickSaveButton(); // Assert - await umbracoUi.template.isSuccessNotificationVisible(); + await umbracoUi.template.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); await umbracoUi.template.isMasterTemplateNameVisible(templateName); // Checks if the childTemplate has the masterTemplate set const childTemplateData = await umbracoApi.template.getByName(childTemplateName); @@ -125,7 +126,7 @@ test('can remove a master template', async ({umbracoApi, umbracoUi}) => { await umbracoUi.template.clickSaveButton(); // Assert - await umbracoUi.template.isSuccessNotificationVisible(); + await umbracoUi.template.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); await umbracoUi.template.isMasterTemplateNameVisible('No master'); const childTemplate = await umbracoApi.template.getByName(childTemplateName); expect(childTemplate.masterTemplate).toBe(null); @@ -169,7 +170,7 @@ test.skip('can use query builder with Order By statement for a template', async await umbracoUi.template.clickSaveButton(); // Assert - await umbracoUi.template.isSuccessNotificationVisible(); + await umbracoUi.template.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const templateData = await umbracoApi.template.getByName(templateName); expect(templateData.content).toBe(expectedTemplateContent); }); @@ -201,6 +202,7 @@ test('can use query builder with Where statement for a template', async ({umbrac // Act await umbracoUi.template.goToTemplate(templateName); + await umbracoUi.waitForTimeout(500); await umbracoUi.template.addQueryBuilderWithWhereStatement(propertyAliasValue, operatorValue, constrainValue); // Verify that the code is shown await umbracoUi.template.isQueryBuilderCodeShown(expectedCode); @@ -208,7 +210,7 @@ test('can use query builder with Where statement for a template', async ({umbrac await umbracoUi.template.clickSaveButton(); // Assert - await umbracoUi.template.isSuccessNotificationVisible(); + await umbracoUi.template.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const templateData = await umbracoApi.template.getByName(templateName); expect(templateData.content).toBe(expectedTemplateContent); }); @@ -227,7 +229,7 @@ test('can insert sections - render child template into a template', async ({umbr await umbracoUi.template.clickSaveButton(); // Assert - await umbracoUi.template.isSuccessNotificationVisible(); + await umbracoUi.template.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const templateData = await umbracoApi.template.getByName(templateName); expect(templateData.content).toBe(templateContent); }); @@ -246,7 +248,7 @@ test('can insert sections - render a named section into a template', async ({umb await umbracoUi.template.clickSaveButton(); // Assert - await umbracoUi.template.isSuccessNotificationVisible(); + await umbracoUi.template.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const templateData = await umbracoApi.template.getByName(templateName); expect(templateData.content).toBe(templateContent); }); @@ -284,7 +286,7 @@ test('can insert dictionary item into a template', async ({umbracoApi, umbracoUi await umbracoUi.template.clickSaveButton(); // Assert - await umbracoUi.template.isSuccessNotificationVisible(); + await umbracoUi.template.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const templateData = await umbracoApi.template.getByName(templateName); expect(templateData.content).toBe(templateContent); @@ -307,7 +309,7 @@ test('can insert partial view into a template', async ({umbracoApi, umbracoUi}) await umbracoUi.template.clickSaveButton(); // Assert - await umbracoUi.template.isSuccessNotificationVisible(); + await umbracoUi.template.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const templateData = await umbracoApi.template.getByName(templateName); expect(templateData.content).toBe(templateContent); }); @@ -324,7 +326,7 @@ test('can insert value into a template', async ({umbracoApi, umbracoUi}) => { await umbracoUi.template.clickSaveButton(); // Assert - await umbracoUi.template.isSuccessNotificationVisible(); + await umbracoUi.template.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const templateData = await umbracoApi.template.getByName(templateName); expect(templateData.content).toBe(templateContent); }); @@ -368,5 +370,7 @@ test('cannot create a template with an empty name', {tag: '@smoke'}, async ({umb // Assert await umbracoUi.template.isErrorNotificationVisible(); + // TODO: Uncomment this when the front-end updates the error message + //await umbracoUi.template.doesErrorNotificationHaveText(NotificationConstantHelper.error.emptyName); expect(await umbracoApi.template.doesNameExist(templateName)).toBeFalsy(); }); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/User/ContentStartNodes.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/User/ContentStartNodes.spec.ts new file mode 100644 index 0000000000..f59ae83870 --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/User/ContentStartNodes.spec.ts @@ -0,0 +1,89 @@ +import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers'; + +const testUser = ConstantHelper.testUserCredentials; +let testUserCookieAndToken = {cookie: "", accessToken: "", refreshToken: ""}; + +const userGroupName = 'TestUserGroup'; +let userGroupId = null; + +const rootDocumentTypeName = 'RootDocumentType'; +const childDocumentTypeOneName = 'ChildDocumentTypeOne'; +const childDocumentTypeTwoName = 'ChildDocumentTypeTwo'; +let childDocumentTypeOneId = null; +let rootDocumentTypeId = null; +const rootDocumentName = 'RootDocument'; +const childDocumentOneName = 'ChildDocumentOne'; +const childDocumentTwoName = 'ChildDocumentTwo'; +let rootDocumentId = null; +let childDocumentOneId = null; + +test.beforeEach(async ({umbracoApi}) => { + await umbracoApi.documentType.ensureNameNotExists(rootDocumentTypeName); + await umbracoApi.documentType.ensureNameNotExists(childDocumentTypeOneName); + await umbracoApi.documentType.ensureNameNotExists(childDocumentTypeTwoName); + await umbracoApi.user.ensureNameNotExists(testUser.name); + await umbracoApi.userGroup.ensureNameNotExists(userGroupName); + childDocumentTypeOneId = await umbracoApi.documentType.createDefaultDocumentType(childDocumentTypeOneName); + const childDocumentTypeTwoId = await umbracoApi.documentType.createDefaultDocumentType(childDocumentTypeTwoName); + rootDocumentTypeId = await umbracoApi.documentType.createDocumentTypeWithAllowedTwoChildNodes(rootDocumentTypeName, childDocumentTypeOneId, childDocumentTypeTwoId); + rootDocumentId = await umbracoApi.document.createDefaultDocument(rootDocumentName, rootDocumentTypeId); + childDocumentOneId = await umbracoApi.document.createDefaultDocumentWithParent(childDocumentOneName, childDocumentTypeOneId, rootDocumentId); + await umbracoApi.document.createDefaultDocumentWithParent(childDocumentTwoName, childDocumentTypeTwoId, rootDocumentId); + userGroupId = await umbracoApi.userGroup.createSimpleUserGroupWithContentSection(userGroupName); +}); + +test.afterEach(async ({umbracoApi}) => { + // Ensure we are logged in to admin + await umbracoApi.loginToAdminUser(testUserCookieAndToken.cookie, testUserCookieAndToken.accessToken, testUserCookieAndToken.refreshToken); + await umbracoApi.documentType.ensureNameNotExists(rootDocumentTypeName); + await umbracoApi.documentType.ensureNameNotExists(childDocumentTypeOneName); + await umbracoApi.documentType.ensureNameNotExists(childDocumentTypeTwoName); + await umbracoApi.userGroup.ensureNameNotExists(userGroupName); +}); + +test('can see root start node and children', async ({umbracoApi, umbracoUi}) => { + // Arrange + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId, [rootDocumentId]); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + + // Act + await umbracoUi.user.goToSection(ConstantHelper.sections.content, false); + + // Assert + await umbracoUi.content.isContentInTreeVisible(rootDocumentName); + await umbracoUi.content.clickCaretButtonForContentName(rootDocumentName); + await umbracoUi.content.isChildContentInTreeVisible(rootDocumentName, childDocumentOneName); + await umbracoUi.content.isChildContentInTreeVisible(rootDocumentName, childDocumentTwoName); +}); + +test('can see parent of start node but not access it', async ({umbracoApi, umbracoUi}) => { + // Arrange + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId, [childDocumentOneId]); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + + // Act + await umbracoUi.user.goToSection(ConstantHelper.sections.content, false); + + // Assert + await umbracoUi.content.isContentInTreeVisible(rootDocumentName); + await umbracoUi.content.goToContentWithName(rootDocumentName); + await umbracoUi.content.doesErrorNotificationHaveText(NotificationConstantHelper.error.noAccessToResource); + await umbracoUi.content.clickCaretButtonForContentName(rootDocumentName); + await umbracoUi.content.isChildContentInTreeVisible(rootDocumentName, childDocumentOneName); + await umbracoUi.content.isChildContentInTreeVisible(rootDocumentName, childDocumentTwoName, false); +}); + +test('can not see any content when no start nodes specified', async ({umbracoApi, umbracoUi}) => { + // Arrange + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + + // Act + await umbracoUi.user.goToSection(ConstantHelper.sections.content, false); + + // Assert + await umbracoUi.content.isDocumentTreeEmpty(); +}); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/User/MediaStartNodes.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/User/MediaStartNodes.spec.ts new file mode 100644 index 0000000000..81cdeb84ed --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/User/MediaStartNodes.spec.ts @@ -0,0 +1,83 @@ +import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers'; + +const testUser = ConstantHelper.testUserCredentials; +let testUserCookieAndToken = {cookie: "", accessToken: "", refreshToken: ""}; + +const userGroupName = 'TestUserGroup'; +let userGroupId = null; + +let rootFolderId = null; +let childFolderOneId = null; +const rootFolderName = 'RootFolder'; +const childFolderOneName = 'ChildFolderOne'; +const childFolderTwoName = 'ChildFolderTwo'; + +test.beforeEach(async ({umbracoApi}) => { + await umbracoApi.user.ensureNameNotExists(testUser.name); + await umbracoApi.userGroup.ensureNameNotExists(userGroupName); + await umbracoApi.media.ensureNameNotExists(rootFolderName); + await umbracoApi.media.ensureNameNotExists(childFolderOneName); + await umbracoApi.media.ensureNameNotExists(childFolderTwoName); + rootFolderId = await umbracoApi.media.createDefaultMediaFolder(rootFolderName); + childFolderOneId = await umbracoApi.media.createDefaultMediaFolderAndParentId(childFolderOneName, rootFolderId); + await umbracoApi.media.createDefaultMediaFolderAndParentId(childFolderTwoName, rootFolderId); + userGroupId = await umbracoApi.userGroup.createSimpleUserGroupWithMediaSection(userGroupName); +}); + +test.afterEach(async ({umbracoApi}) => { + // Ensure we are logged in to admin + await umbracoApi.loginToAdminUser(testUserCookieAndToken.cookie, testUserCookieAndToken.accessToken, testUserCookieAndToken.refreshToken); + await umbracoApi.user.ensureNameNotExists(testUser.name); + await umbracoApi.userGroup.ensureNameNotExists(userGroupName); + await umbracoApi.media.ensureNameNotExists(rootFolderName); + await umbracoApi.media.ensureNameNotExists(childFolderOneName); + await umbracoApi.media.ensureNameNotExists(childFolderTwoName); +}); + +test('can see root media start node and children', async ({umbracoApi, umbracoUi}) => { + // Arrange + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId, [], false, [rootFolderId]); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + + // Act + await umbracoUi.user.goToSection(ConstantHelper.sections.media, false); + + // Assert + await umbracoUi.media.isMediaTreeItemVisible(rootFolderName); + await umbracoUi.media.clickCaretButtonForMediaName(rootFolderName); + await umbracoUi.media.isChildMediaVisible(rootFolderName, childFolderOneName); + await umbracoUi.media.isChildMediaVisible(rootFolderName, childFolderTwoName); +}); + +test('can see parent of start node but not access it', async ({umbracoApi, umbracoUi}) => { + // Arrange + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId, [], false, [childFolderOneId]); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + + // Act + await umbracoUi.user.goToSection(ConstantHelper.sections.media, false); + + // Assert + await umbracoUi.media.isMediaTreeItemVisible(rootFolderName); + await umbracoUi.waitForTimeout(500); + await umbracoUi.media.goToMediaWithName(rootFolderName); + await umbracoUi.media.doesErrorNotificationHaveText(NotificationConstantHelper.error.noAccessToResource); + await umbracoUi.media.clickCaretButtonForMediaName(rootFolderName); + await umbracoUi.media.isChildMediaVisible(rootFolderName, childFolderOneName); + await umbracoUi.media.isChildMediaVisible(rootFolderName, childFolderTwoName, false); +}); + +test('can not see any media when no media start nodes specified', async ({umbracoApi, umbracoUi}) => { + // Arrange + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + + // Act + await umbracoUi.user.goToSection(ConstantHelper.sections.media, false); + + // Assert + await umbracoUi.media.isMediaTreeItemVisible(rootFolderName, false); +}); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/User/UICulture.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/User/UICulture.spec.ts new file mode 100644 index 0000000000..ede78fc9e8 --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/User/UICulture.spec.ts @@ -0,0 +1,44 @@ +import {ConstantHelper, test} from '@umbraco/playwright-testhelpers'; + +const testUser = ConstantHelper.testUserCredentials; +let testUserCookieAndToken = {cookie: "", accessToken: "", refreshToken: ""}; + +const userGroupName = 'TestUserGroup'; +let userGroupId = null; + +test.beforeEach(async ({umbracoApi}) => { + await umbracoApi.user.ensureNameNotExists(testUser.name); + await umbracoApi.userGroup.ensureNameNotExists(userGroupName); + userGroupId = await umbracoApi.userGroup.createSimpleUserGroupWithContentSection(userGroupName); +}); + +test.afterEach(async ({umbracoApi}) => { + // Ensure we are logged in to admin + await umbracoApi.loginToAdminUser(testUserCookieAndToken.cookie, testUserCookieAndToken.accessToken, testUserCookieAndToken.refreshToken); + await umbracoApi.userGroup.ensureNameNotExists(userGroupName); +}); + +test('can see correct translation for content in english', async ({umbracoApi, umbracoUi}) => { + // Arrange + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId, [], true, [], false, 'en-us'); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + + // Act + await umbracoUi.goToBackOffice(); + + // Assert + await umbracoUi.user.isSectionWithNameVisible(ConstantHelper.sections.content, true); +}); + +test('can see correct translation for content in danish', async ({umbracoApi, umbracoUi}) => { + // Arrange + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId, [], true, [], false, 'da-dk'); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + + // Act + await umbracoUi.goToBackOffice(); + + // Assert + // Indhold is the Danish translation of Content + await umbracoUi.user.isSectionWithNameVisible('Indhold', true); +}); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/UserGroup/ContentStartNodes.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/UserGroup/ContentStartNodes.spec.ts new file mode 100644 index 0000000000..7c7c48d186 --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/UserGroup/ContentStartNodes.spec.ts @@ -0,0 +1,92 @@ +import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers'; + +const testUser = ConstantHelper.testUserCredentials; +let testUserCookieAndToken = {cookie: "", accessToken: "", refreshToken: ""}; + +const userGroupName = 'TestUserGroup'; +let userGroupId = null; + +const rootDocumentTypeName = 'RootDocumentType'; +const childDocumentTypeOneName = 'ChildDocumentTypeOne'; +const childDocumentTypeTwoName = 'ChildDocumentTypeTwo'; +let childDocumentTypeOneId = null; +let childDocumentTypeTwoId = null; +let rootDocumentTypeId = null; +const rootDocumentName = 'RootDocument'; +const childDocumentOneName = 'ChildDocumentOne'; +const childDocumentTwoName = 'ChildDocumentTwo'; +let rootDocumentId = null; +let childDocumentOneId = null; + +test.beforeEach(async ({umbracoApi}) => { + await umbracoApi.documentType.ensureNameNotExists(rootDocumentTypeName); + await umbracoApi.documentType.ensureNameNotExists(childDocumentTypeOneName); + await umbracoApi.documentType.ensureNameNotExists(childDocumentTypeTwoName); + await umbracoApi.user.ensureNameNotExists(testUser.name); + await umbracoApi.userGroup.ensureNameNotExists(userGroupName); + childDocumentTypeOneId = await umbracoApi.documentType.createDefaultDocumentType(childDocumentTypeOneName); + childDocumentTypeTwoId = await umbracoApi.documentType.createDefaultDocumentType(childDocumentTypeTwoName); + rootDocumentTypeId = await umbracoApi.documentType.createDocumentTypeWithAllowedTwoChildNodes(rootDocumentTypeName, childDocumentTypeOneId, childDocumentTypeTwoId); + rootDocumentId = await umbracoApi.document.createDefaultDocument(rootDocumentName, rootDocumentTypeId); + childDocumentOneId = await umbracoApi.document.createDefaultDocumentWithParent(childDocumentOneName, childDocumentTypeOneId, rootDocumentId); + await umbracoApi.document.createDefaultDocumentWithParent(childDocumentTwoName, childDocumentTypeTwoId, rootDocumentId); +}); + +test.afterEach(async ({umbracoApi}) => { + // Ensure we are logged in to admin + await umbracoApi.loginToAdminUser(testUserCookieAndToken.cookie, testUserCookieAndToken.accessToken, testUserCookieAndToken.refreshToken); + await umbracoApi.documentType.ensureNameNotExists(rootDocumentTypeName); + await umbracoApi.documentType.ensureNameNotExists(childDocumentTypeOneName); + await umbracoApi.documentType.ensureNameNotExists(childDocumentTypeTwoName); + await umbracoApi.userGroup.ensureNameNotExists(userGroupName); +}); + +test('can see root start node and children', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithDocumentStartNode(userGroupName, rootDocumentId); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + + // Act + await umbracoUi.userGroup.goToSection(ConstantHelper.sections.content, false); + + // Assert + await umbracoUi.content.isContentInTreeVisible(rootDocumentName); + await umbracoUi.content.clickCaretButtonForContentName(rootDocumentName); + await umbracoUi.content.isChildContentInTreeVisible(rootDocumentName, childDocumentOneName); + await umbracoUi.content.isChildContentInTreeVisible(rootDocumentName, childDocumentTwoName); +}); + +test('can see parent of start node but not access it', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithDocumentStartNode(userGroupName, childDocumentOneId); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + + // Act + await umbracoUi.userGroup.goToSection(ConstantHelper.sections.content, false); + + // Assert + await umbracoUi.content.isContentInTreeVisible(rootDocumentName); + await umbracoUi.content.goToContentWithName(rootDocumentName); + await umbracoUi.content.doesErrorNotificationHaveText(NotificationConstantHelper.error.noAccessToResource); + await umbracoUi.content.clickCaretButtonForContentName(rootDocumentName); + await umbracoUi.content.isChildContentInTreeVisible(rootDocumentName, childDocumentOneName); + await umbracoUi.content.isChildContentInTreeVisible(rootDocumentName, childDocumentTwoName, false); +}); + +test('can not see any content when no start nodes specified', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createSimpleUserGroupWithContentSection(userGroupName); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + + // Act + await umbracoUi.userGroup.goToSection(ConstantHelper.sections.content, false); + + // Assert + await umbracoUi.content.isDocumentTreeEmpty(); +}); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/UserGroup/ContentWithRichTextEditor.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/UserGroup/ContentWithRichTextEditor.spec.ts new file mode 100644 index 0000000000..df9655388a --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/UserGroup/ContentWithRichTextEditor.spec.ts @@ -0,0 +1,52 @@ +import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers'; +import {expect} from "@playwright/test"; + +const testUser = ConstantHelper.testUserCredentials; +let testUserCookieAndToken = {cookie: "", accessToken: "", refreshToken: ""}; + +let userGroupId = null; + +const documentTypeName = 'TestDocumentType'; +const documentName = 'TestDocument'; +const richTextEditorName = 'TestRichTextEditor'; +const stylesheetName = 'TestStylesheet.css'; + +test.beforeEach(async ({umbracoApi}) => { + await umbracoApi.user.ensureNameNotExists(testUser.name); + await umbracoApi.stylesheet.ensureNameNotExists(stylesheetName); + const stylesheetPath = await umbracoApi.stylesheet.createStylesheetWithHeaderContent(stylesheetName); + const dataTypeId = await umbracoApi.dataType.createRichTextEditorDataTypeWithStylesheet(richTextEditorName, stylesheetPath); + await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, richTextEditorName, dataTypeId); + const userGroup = await umbracoApi.userGroup.getByName('Editors'); + userGroupId = userGroup.id; +}); + +test.afterEach(async ({umbracoApi}) => { + // Ensure we are logged in to admin + await umbracoApi.loginToAdminUser(testUserCookieAndToken.cookie, testUserCookieAndToken.accessToken, testUserCookieAndToken.refreshToken); + await umbracoApi.stylesheet.ensureNameNotExists(stylesheetName); + await umbracoApi.dataType.ensureNameNotExists(richTextEditorName); + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); +}); + +test('can create content with a rich text editor that has a stylesheet', async ({umbracoApi, umbracoUi}) => { + // Arrange + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content, false); + + // Act + await umbracoUi.content.clickActionsMenuAtRoot(); + await umbracoUi.content.clickCreateButton(); + await umbracoUi.content.chooseDocumentType(documentTypeName); + await umbracoUi.content.enterContentName(documentName); + // Is needed to make sure that the rich text editor is loaded + await umbracoUi.waitForTimeout(500); + await umbracoUi.content.doesErrorNotificationHaveText(NotificationConstantHelper.error.noAccessToResource, false); + await umbracoUi.content.clickSaveButton(); + + // Assert + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); + expect(await umbracoApi.document.doesNameExist(documentName)).toBeTruthy(); +}); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/UserGroup/DefaultPermissionsInContent.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/UserGroup/DefaultPermissionsInContent.spec.ts new file mode 100644 index 0000000000..257ac70542 --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/UserGroup/DefaultPermissionsInContent.spec.ts @@ -0,0 +1,619 @@ +import {ConstantHelper, NotificationConstantHelper, test} from "@umbraco/playwright-testhelpers"; +import {expect} from "@playwright/test"; + +const rootDocumentTypeName = 'RootDocumentType'; +const childDocumentTypeOneName = 'ChildDocumentTypeOne'; +const childDocumentTypeTwoName = 'ChildDocumentTypeTwo'; +let childDocumentTypeId = null; +let rootDocumentTypeId = null; +const rootDocumentName = 'RootDocument'; +const childDocumentOneName = 'ChildDocumentOne'; +const childDocumentTwoName = 'SecondChildDocument'; +let rootDocumentId = null; + +const dataTypeName = 'Textstring'; +let dataTypeId = null; +const documentText = 'This is test document text'; + +const testDocumentName = 'TestDocument'; +const documentBlueprintName = 'TestBlueprintName'; + +const testUser = ConstantHelper.testUserCredentials; +let testUserCookieAndToken = {cookie: "", accessToken: "", refreshToken: ""}; + +const userGroupName = 'TestUserGroup'; +let userGroupId = null; + +test.beforeEach(async ({umbracoApi}) => { + await umbracoApi.documentType.ensureNameNotExists(rootDocumentTypeName); + await umbracoApi.documentType.ensureNameNotExists(childDocumentTypeOneName); + await umbracoApi.documentType.ensureNameNotExists(childDocumentTypeTwoName); + await umbracoApi.user.ensureNameNotExists(testUser.name); + await umbracoApi.userGroup.ensureNameNotExists(userGroupName); + await umbracoApi.documentBlueprint.ensureNameNotExists(documentBlueprintName); + const dataType = await umbracoApi.dataType.getByName(dataTypeName); + dataTypeId = dataType.id; + childDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentType(childDocumentTypeOneName); + rootDocumentTypeId = await umbracoApi.documentType.createDocumentTypeWithAllowedChildNodeAndDataType(rootDocumentTypeName, childDocumentTypeId, dataTypeName, dataTypeId); + rootDocumentId = await umbracoApi.document.createDocumentWithTextContent(rootDocumentName, rootDocumentTypeId, documentText, dataTypeName); + await umbracoApi.document.createDefaultDocumentWithParent(childDocumentOneName, childDocumentTypeId, rootDocumentId); +}); + +test.afterEach(async ({umbracoApi}) => { + // Ensure we are logged in to admin + await umbracoApi.loginToAdminUser(testUserCookieAndToken.cookie, testUserCookieAndToken.accessToken, testUserCookieAndToken.refreshToken); + await umbracoApi.documentType.ensureNameNotExists(rootDocumentTypeName); + await umbracoApi.documentType.ensureNameNotExists(childDocumentTypeOneName); + await umbracoApi.documentType.ensureNameNotExists(childDocumentTypeTwoName); + await umbracoApi.userGroup.ensureNameNotExists(userGroupName); + await umbracoApi.documentBlueprint.ensureNameNotExists(documentBlueprintName); +}); + +test('can browse content node with permission enabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithBrowseNodePermission(userGroupName); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + await umbracoUi.userGroup.goToSection(ConstantHelper.sections.content, false); + + // Act + await umbracoUi.content.goToContentWithName(rootDocumentName); + + // Assert + await umbracoUi.content.doesDocumentHaveName(rootDocumentName); +}); + +test('can not browse content node with permission disabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithBrowseNodePermission(userGroupName, false); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + await umbracoUi.userGroup.goToSection(ConstantHelper.sections.content, false); + + // Act + await umbracoUi.content.goToContentWithName(rootDocumentName); + + // Assert + await umbracoUi.content.doesErrorNotificationHaveText(NotificationConstantHelper.error.noAccessToResource); +}); + +test('can create document blueprint with permission enabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithCreateDocumentBlueprintPermission(userGroupName); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content, false); + + // Act + await umbracoUi.content.clickActionsMenuForContent(rootDocumentName); + await umbracoUi.content.clickCreateDocumentBlueprintButton(); + await umbracoUi.content.enterDocumentBlueprintName(documentBlueprintName); + await umbracoUi.content.clickSaveDocumentBlueprintButton(); + + // Assert + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.documentBlueprintCreated); +}); + +test('can not create document blueprint with permission disabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithCreateDocumentBlueprintPermission(userGroupName, false); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + + // Act + await umbracoUi.documentBlueprint.goToSection(ConstantHelper.sections.content, false); + + // Assert + await umbracoUi.content.isActionsMenuForNameVisible(rootDocumentName, false); +}); + +test('can delete content with delete permission enabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithDeleteDocumentPermission(userGroupName); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content, false); + + // Act + await umbracoUi.content.clickActionsMenuForContent(rootDocumentName); + await umbracoUi.content.clickTrashButton(); + await umbracoUi.content.clickConfirmTrashButton(); + + // Assert + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.movedToRecycleBin); +}); + +test('can not delete content with delete permission disabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithDeleteDocumentPermission(userGroupName, false); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + + // Act + await umbracoUi.content.goToSection(ConstantHelper.sections.content, false); + + // Assert + await umbracoUi.content.isActionsMenuForNameVisible(rootDocumentName, false); +}); + +test('can empty recycle bin with delete permission enabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + await umbracoApi.document.moveToRecycleBin(rootDocumentId); + userGroupId = await umbracoApi.userGroup.createUserGroupWithDeleteDocumentPermission(userGroupName); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content, false); + + // Act + await umbracoUi.content.clickRecycleBinButton(); + await umbracoUi.content.clickEmptyRecycleBinButton(); + await umbracoUi.content.clickConfirmEmptyRecycleBinButton(); + + // Assert + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.emptiedRecycleBin); +}); + +test('can not empty recycle bin with delete permission disabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + await umbracoApi.document.moveToRecycleBin(rootDocumentId); + userGroupId = await umbracoApi.userGroup.createUserGroupWithDeleteDocumentPermission(userGroupName, false); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + + // Act + await umbracoUi.content.goToSection(ConstantHelper.sections.content, false); + + // Assert + await umbracoUi.content.isActionsMenuForRecycleBinVisible(false); +}); + +test('can create content with create permission enabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithCreateDocumentPermission(userGroupName); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content, false); + + // Act + await umbracoUi.content.clickActionsMenuAtRoot(); + await umbracoUi.content.clickCreateButton(); + await umbracoUi.content.chooseDocumentType(rootDocumentTypeName); + await umbracoUi.content.enterContentName(testDocumentName); + await umbracoUi.content.clickSaveButton(); + + // Assert + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); +}); + +test('can not create content with create permission disabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithCreateDocumentPermission(userGroupName, false); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + + // Act + await umbracoUi.content.goToSection(ConstantHelper.sections.content, false); + + // Assert + await umbracoUi.content.isActionsMenuForNameVisible(rootDocumentName, false); +}); + +// TODO: Setup SMTP server to test notifications, do this when we test appsettings.json +test.skip('can create notifications with notification permission enabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithNotificationsPermission(userGroupName); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + + // Act + await umbracoUi.content.goToSection(ConstantHelper.sections.content, false); +}); + +test('can not create notifications with notification permission disabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithNotificationsPermission(userGroupName, false); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + + // Act + await umbracoUi.content.goToSection(ConstantHelper.sections.content, false); + + // Assert + await umbracoUi.content.isActionsMenuForNameVisible(rootDocumentName, false); +}); + +test('can publish content with publish permission enabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithPublishPermission(userGroupName); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content, false); + + // Act + await umbracoUi.content.clickActionsMenuForContent(rootDocumentName); + await umbracoUi.content.clickPublishButton(); + + // Assert + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.published); + expect(await umbracoApi.document.isDocumentPublished(rootDocumentId)).toBeTruthy(); +}); + +test('can not publish content with publish permission disabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithPublishPermission(userGroupName, false); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + + // Act + await umbracoUi.content.goToSection(ConstantHelper.sections.content, false); + + // Assert + await umbracoUi.content.isActionsMenuForNameVisible(rootDocumentName, false); +}); + +// Bug, does nothing in the frontend. +test.skip('can set permissions with set permissions permission enabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithSetPermissionsPermission(userGroupName); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content, false); + + // Act + await umbracoUi.content.clickActionsMenuForContent(rootDocumentName); + // await umbracoUi.content.clickSetPermissionsButton(); + // + // // Assert + // await umbracoUi.content.doesDocumentPermissionsDialogExist(); +}); + +test('can not set permissions with set permissions permission disabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithSetPermissionsPermission(userGroupName, false); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + + // Act + await umbracoUi.content.goToSection(ConstantHelper.sections.content, false); + + // Assert + await umbracoUi.content.isActionsMenuForNameVisible(rootDocumentName, false); +}); + +test('can unpublish content with unpublish permission enabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + await umbracoApi.document.publish(rootDocumentId); + expect(await umbracoApi.document.isDocumentPublished(rootDocumentId)).toBeTruthy(); + userGroupId = await umbracoApi.userGroup.createUserGroupWithUnpublishPermission(userGroupName); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content, false); + + // Act + await umbracoUi.content.clickActionsMenuForContent(rootDocumentName); + await umbracoUi.content.clickUnpublishButton(); + await umbracoUi.content.clickConfirmToUnpublishButton(); + + // Assert + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.unpublished); + expect(await umbracoApi.document.isDocumentPublished(rootDocumentId)).toBeFalsy(); +}); + +test('can not unpublish content with unpublish permission disabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + await umbracoApi.document.publish(rootDocumentId); + expect(await umbracoApi.document.isDocumentPublished(rootDocumentId)).toBeTruthy(); + userGroupId = await umbracoApi.userGroup.createUserGroupWithUnpublishPermission(userGroupName, false); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + + // Act + await umbracoUi.content.goToSection(ConstantHelper.sections.content, false); + + // Assert + await umbracoUi.content.isActionsMenuForNameVisible(rootDocumentName, false); +}); + +test('can update content with update permission enabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithUpdatePermission(userGroupName); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content, false); + + // Act + await umbracoUi.content.goToContentWithName(rootDocumentName); + await umbracoUi.content.isDocumentReadOnly(false); + await umbracoUi.content.enterContentName(testDocumentName); + await umbracoUi.content.clickSaveButton(); + + // Assert + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + expect(await umbracoApi.document.doesNameExist(testDocumentName)).toBeTruthy(); +}); + +// TODO: the permission for update is not working, it is always enabled. +test.skip('can not update content with update permission disabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithUpdatePermission(userGroupName, false); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + + // Act + await umbracoUi.content.goToSection(ConstantHelper.sections.content, false); + + // Assert + await umbracoUi.content.isActionsMenuForNameVisible(rootDocumentName, false); +}); + +test('can duplicate content with duplicate permission enabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + const duplicatedContentName = rootDocumentName + ' (1)'; + userGroupId = await umbracoApi.userGroup.createUserGroupWithDuplicatePermission(userGroupName); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content, false); + + // Act + await umbracoUi.content.clickActionsMenuForContent(rootDocumentName); + // Duplicate to root + await umbracoUi.content.clickDuplicateToButton(); + await umbracoUi.content.clickLabelWithName('Content'); + await umbracoUi.content.clickDuplicateButton(); + + // Assert + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.duplicated); + expect(await umbracoApi.document.doesNameExist(rootDocumentName)).toBeTruthy(); + expect(await umbracoApi.document.doesNameExist(duplicatedContentName)).toBeTruthy(); + await umbracoUi.content.isContentInTreeVisible(rootDocumentName); + await umbracoUi.content.isContentInTreeVisible(duplicatedContentName); + const rootContent = await umbracoApi.document.getByName(rootDocumentName); + const rootDuplicatedContent = await umbracoApi.document.getByName(duplicatedContentName); + expect(rootContent.values[0].value).toEqual(rootDuplicatedContent.values[0].value); +}); + +test('can not duplicate content with duplicate permission disabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithDuplicatePermission(userGroupName, false); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + + // Act + await umbracoUi.content.goToSection(ConstantHelper.sections.content, false); + + // Assert + await umbracoUi.content.isActionsMenuForNameVisible(rootDocumentName, false); +}); + +test('can move content with move to permission enabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + const moveToDocumentName = 'SecondRootDocument'; + const moveToDocumentId = await umbracoApi.document.createDocumentWithTextContent(moveToDocumentName, rootDocumentTypeId, documentText, dataTypeName); + userGroupId = await umbracoApi.userGroup.createUserGroupWithMoveToPermission(userGroupName); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content, false); + + // Act + await umbracoUi.content.clickCaretButtonForContentName(rootDocumentName); + await umbracoUi.content.clickActionsMenuForContent(childDocumentOneName); + await umbracoUi.content.clickMoveToButton(); + await umbracoUi.content.moveToContentWithName([], moveToDocumentName); + + // Assert + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.moved); + await umbracoUi.content.reloadContentTree(); + await umbracoUi.content.isCaretButtonVisibleForContentName(moveToDocumentName, true); + await umbracoUi.content.clickCaretButtonForContentName(moveToDocumentName); + await umbracoUi.content.isChildContentInTreeVisible(moveToDocumentName, childDocumentOneName, true); + await umbracoUi.content.isCaretButtonVisibleForContentName(rootDocumentName, false); + expect(await umbracoApi.document.getChildrenAmount(rootDocumentId)).toEqual(0); + expect(await umbracoApi.document.getChildrenAmount(moveToDocumentId)).toEqual(1); +}); + +test('can not move content with move to permission disabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + const moveToDocumentName = 'SecondRootDocument'; + await umbracoApi.document.createDocumentWithTextContent(moveToDocumentName, rootDocumentTypeId, documentText, dataTypeName); + userGroupId = await umbracoApi.userGroup.createUserGroupWithMoveToPermission(userGroupName, false); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + + // Act + await umbracoUi.content.goToSection(ConstantHelper.sections.content, false); + + // Assert + await umbracoUi.content.isActionsMenuForNameVisible(rootDocumentName, false); +}); + +test('can sort children with sort children permission enabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + await umbracoApi.document.createDefaultDocumentWithParent(childDocumentTwoName, childDocumentTypeId, rootDocumentId); + userGroupId = await umbracoApi.userGroup.createUserGroupWithSortChildrenPermission(userGroupName); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content, false); + + // Act + await umbracoUi.content.clickActionsMenuForContent(rootDocumentName); + await umbracoUi.content.clickSortChildrenButton(); + + // TODO: uncomment when it is not flaky + // const childDocumentOneLocator = await umbracoUi.content.getButtonWithName(childDocumentOneName); + // const childDocumentTwoLocator = await umbracoUi.content.getButtonWithName(childDocumentTwoName) + // await umbracoUi.content.sortChildrenDragAndDrop(childDocumentOneLocator, childDocumentTwoLocator, 10, 0, 10); + await umbracoUi.content.clickSortButton(); + + // Assert + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.itemsSorted); + // TODO: uncomment when it is not flaky + // await umbracoUi.content.clickCaretButtonForContentName(rootDocumentName); + // await umbracoUi.content.doesIndexDocumentInTreeContainName(rootDocumentName, childDocumentTwoName, 0); + // await umbracoUi.content.doesIndexDocumentInTreeContainName(rootDocumentName, childDocumentOneName, 1); +}); + +test('can not sort children with sort children permission disabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + await umbracoApi.document.createDefaultDocumentWithParent(childDocumentTwoName, childDocumentTypeId, rootDocumentId); + userGroupId = await umbracoApi.userGroup.createUserGroupWithSortChildrenPermission(userGroupName, false); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + + // Act + await umbracoUi.content.goToSection(ConstantHelper.sections.content, false); + + // Assert + await umbracoUi.content.isActionsMenuForNameVisible(rootDocumentName, false); +}); + +test('can set culture and hostnames with culture and hostnames permission enabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithCultureAndHostnamesPermission(userGroupName); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content, false); + + // Act + await umbracoUi.content.clickActionsMenuForContent(rootDocumentName); + await umbracoUi.content.clickCultureAndHostnamesButton(); + await umbracoUi.content.clickAddNewDomainButton(); + await umbracoUi.content.enterDomain('/en'); + await umbracoUi.content.clickSaveModalButton(); + + // Assert + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.culturesAndHostnamesSaved); +}); + +test('can not set culture and hostnames with culture and hostnames permission disabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithCultureAndHostnamesPermission(userGroupName, false); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + + // Act + await umbracoUi.content.goToSection(ConstantHelper.sections.content, false); + + // Assert + await umbracoUi.content.isActionsMenuForNameVisible(rootDocumentName, false); +}); + +// TODO: Notification is not correct 'Public acccess setting created' should be 'access' +test.skip('can set public access with public access permission enabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithPublicAccessPermission(userGroupName); + const testMemberGroup = 'TestMemberGroup'; + await umbracoApi.memberGroup.ensureNameNotExists(testMemberGroup); + await umbracoApi.memberGroup.create(testMemberGroup) + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content, false); + + // Act + await umbracoUi.content.clickActionsMenuForContent(rootDocumentName); + await umbracoUi.content.clickPublicAccessButton(); + await umbracoUi.content.addGroupBasedPublicAccess(testMemberGroup, rootDocumentName); + + // Assert + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.publicAccessSettingCreated); +}); + +test('can not set public access with public access permission disabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithPublicAccessPermission(userGroupName, false); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + + // Act + await umbracoUi.content.goToSection(ConstantHelper.sections.content, false); + + // Assert + await umbracoUi.content.isActionsMenuForNameVisible(rootDocumentName, false); +}); + +test('can rollback content with rollback permission enabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithRollbackPermission(userGroupName); + await umbracoApi.document.publish(rootDocumentId); + const updatedTextStringText = 'This is an updated textString text'; + const content = await umbracoApi.document.get(rootDocumentId); + content.values[0].value = updatedTextStringText; + await umbracoApi.document.update(rootDocumentId, content); + await umbracoApi.document.publish(rootDocumentId); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content, false); + + // Act + await umbracoUi.content.goToContentWithName(rootDocumentName); + await umbracoUi.content.doesDocumentPropertyHaveValue(dataTypeName, updatedTextStringText); + await umbracoUi.content.clickInfoTab(); + // Needs to wait for the rollback button to be visible + await umbracoUi.waitForTimeout(500); + await umbracoUi.content.clickRollbackButton(); + await umbracoUi.content.clickLatestRollBackItem(); + await umbracoUi.content.clickRollbackContainerButton(); + + // Assert + await umbracoUi.content.doesDocumentPropertyHaveValue(dataTypeName, documentText); +}); + +test('can not rollback content with rollback permission disabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithRollbackPermission(userGroupName, false); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + + // Act + await umbracoUi.content.goToSection(ConstantHelper.sections.content, false); + + // Assert + await umbracoUi.content.isActionsMenuForNameVisible(rootDocumentName, false); +}); + +test('can not see delete button in content for userGroup with delete permission disabled and create permission enabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithDeletePermissionAndCreatePermission(userGroupName, false, true); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + + // Act + await umbracoUi.content.goToSection(ConstantHelper.sections.content, false); + await umbracoUi.content.clickActionsMenuForContent(rootDocumentName); + + // Assert + await umbracoUi.content.isPermissionInActionsMenuVisible('Delete...', false); + await umbracoUi.content.isPermissionInActionsMenuVisible('Create...', true); +}); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/UserGroup/Languages.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/UserGroup/Languages.spec.ts new file mode 100644 index 0000000000..7b535fb067 --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/UserGroup/Languages.spec.ts @@ -0,0 +1,135 @@ +import {AliasHelper, ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers'; + +const testUser = ConstantHelper.testUserCredentials; +let testUserCookieAndToken = {cookie: "", accessToken: "", refreshToken: ""}; + +const userGroupName = 'TestUserGroup'; +let userGroupId = null; + +const documentTypeName = 'TestDocumentType'; +const documentName = 'TestDocument'; +const englishDocumentName = 'EnglishDocument'; +const danishDocumentName = 'DanishDocument'; +const vietnameseDocumentName = 'VietnameseDocument'; +let documentTypeId = null; + +const dataTypeName = 'Textstring'; +let dataTypeId = null; + +const englishIsoCode = 'en-US'; +const danishIsoCode = 'da'; +const vietnameseIsoCode = 'vi'; +const englishLanguageName = 'English (United States)'; +const danishLanguageName = 'Danish'; +const vietnameseLanguageName = 'Vietnamese'; +const cultureVariants = [ + { + isoCode: englishIsoCode, + name: englishDocumentName, + value: 'EnglishValue', + }, + { + isoCode: danishIsoCode, + name: danishDocumentName, + value: 'DanishValue', + }, + { + isoCode: vietnameseIsoCode, + name: vietnameseDocumentName, + value: 'VietnameseValue', + } +]; + +test.beforeEach(async ({umbracoApi}) => { + await umbracoApi.user.ensureNameNotExists(testUser.name); + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + await umbracoApi.language.ensureIsoCodeNotExists(danishIsoCode); + await umbracoApi.language.ensureIsoCodeNotExists(vietnameseIsoCode); + await umbracoApi.language.createDanishLanguage(); + await umbracoApi.language.createVietnameseLanguage(); + const dataType = await umbracoApi.dataType.getByName(dataTypeName); + dataTypeId = dataType.id; + documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeId, 'TestGroup', true); + await umbracoApi.document.createDocumentWithMultipleVariants(documentName, documentTypeId, AliasHelper.toAlias(dataTypeName), cultureVariants); +}); + +test.afterEach(async ({umbracoApi}) => { + // Ensure we are logged in to admin + await umbracoApi.loginToAdminUser(testUserCookieAndToken.cookie, testUserCookieAndToken.accessToken, testUserCookieAndToken.refreshToken); + await umbracoApi.userGroup.ensureNameNotExists(userGroupName); + await umbracoApi.language.ensureIsoCodeNotExists(danishIsoCode); + await umbracoApi.language.ensureIsoCodeNotExists(vietnameseIsoCode); + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); +}); + +test('can rename content with language set in userGroup', async ({umbracoApi, umbracoUi}) => { + // Arrange + const updatedContentName = 'UpdatedContentName'; + userGroupId = await umbracoApi.userGroup.createUserGroupWithLanguageAndContentSection(userGroupName, englishIsoCode); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId, [], false, [], false, englishIsoCode); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + await umbracoUi.userGroup.goToSection(ConstantHelper.sections.content, false); + await umbracoUi.content.goToContentWithName(englishDocumentName); + + // Act + await umbracoUi.content.isDocumentReadOnly(false); + await umbracoUi.content.enterContentName(updatedContentName); + await umbracoUi.content.clickSaveButton(); + await umbracoUi.content.clickSaveAndCloseButton(); + + // Assert + await umbracoUi.userGroup.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + await umbracoUi.content.isContentInTreeVisible(updatedContentName); +}); + +test('can not rename content with language not set in userGroup', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithLanguageAndContentSection(userGroupName, englishIsoCode); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId, [], false, [], false, englishIsoCode); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + await umbracoUi.userGroup.goToSection(ConstantHelper.sections.content, false); + await umbracoUi.content.doesDocumentSectionHaveLanguageSelected(englishLanguageName); + await umbracoUi.content.changeDocumentSectionLanguage(danishLanguageName); + + // Act + await umbracoUi.content.goToContentWithName(danishDocumentName); + + // Assert + await umbracoUi.content.isDocumentReadOnly(); + await umbracoUi.content.isDocumentNameInputEditable(false); +}); + +test('can update content property with language set in userGroup', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithLanguageAndContentSection(userGroupName, englishIsoCode); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + await umbracoUi.userGroup.goToSection(ConstantHelper.sections.content, false); + await umbracoUi.content.doesDocumentSectionHaveLanguageSelected(englishLanguageName); + + // Act + await umbracoUi.content.goToContentWithName(englishDocumentName); + + // Assert + await umbracoUi.content.isDocumentPropertyEditable(dataTypeName, true); +}); + +test('can not update content property with language not set in userGroup', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithLanguageAndContentSection(userGroupName, englishIsoCode); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + await umbracoUi.userGroup.goToSection(ConstantHelper.sections.content, false); + await umbracoUi.content.doesDocumentSectionHaveLanguageSelected(englishLanguageName); + await umbracoUi.content.changeDocumentSectionLanguage(vietnameseLanguageName); + + // Act + await umbracoUi.content.goToContentWithName(vietnameseDocumentName); + + // Assert + await umbracoUi.content.isDocumentPropertyEditable(dataTypeName, false); +}); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/UserGroup/MediaStartNodes.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/UserGroup/MediaStartNodes.spec.ts new file mode 100644 index 0000000000..b129c3979e --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/UserGroup/MediaStartNodes.spec.ts @@ -0,0 +1,85 @@ +import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers'; + +const testUser = ConstantHelper.testUserCredentials; +let testUserCookieAndToken = {cookie: "", accessToken: "", refreshToken: ""}; + +const userGroupName = 'TestUserGroup'; +let userGroupId = null; + +let rootFolderId = null; +let childFolderOneId = null; +const rootFolderName = 'RootFolder'; +const childFolderOneName = 'ChildFolderOne'; +const childFolderTwoName = 'ChildFolderTwo'; + +test.beforeEach(async ({umbracoApi}) => { + await umbracoApi.user.ensureNameNotExists(testUser.name); + await umbracoApi.userGroup.ensureNameNotExists(userGroupName); + await umbracoApi.media.ensureNameNotExists(rootFolderName); + await umbracoApi.media.ensureNameNotExists(childFolderOneName); + await umbracoApi.media.ensureNameNotExists(childFolderTwoName); + rootFolderId = await umbracoApi.media.createDefaultMediaFolder(rootFolderName); + childFolderOneId = await umbracoApi.media.createDefaultMediaFolderAndParentId(childFolderOneName, rootFolderId); + await umbracoApi.media.createDefaultMediaFolderAndParentId(childFolderTwoName, rootFolderId); +}); + +test.afterEach(async ({umbracoApi}) => { + // Ensure we are logged in to admin + await umbracoApi.loginToAdminUser(testUserCookieAndToken.cookie, testUserCookieAndToken.accessToken, testUserCookieAndToken.refreshToken); + await umbracoApi.user.ensureNameNotExists(testUser.name); + await umbracoApi.userGroup.ensureNameNotExists(userGroupName); + await umbracoApi.media.ensureNameNotExists(rootFolderName); + await umbracoApi.media.ensureNameNotExists(childFolderOneName); + await umbracoApi.media.ensureNameNotExists(childFolderTwoName); +}); + +test('can see root media start node and children', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithMediaStartNode(userGroupName, rootFolderId); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + + // Act + await umbracoUi.user.goToSection(ConstantHelper.sections.media, false); + + // Assert + await umbracoUi.media.isMediaTreeItemVisible(rootFolderName); + await umbracoUi.media.clickCaretButtonForMediaName(rootFolderName); + await umbracoUi.media.isChildMediaVisible(rootFolderName, childFolderOneName); + await umbracoUi.media.isChildMediaVisible(rootFolderName, childFolderTwoName); +}); + +test('can see parent of start node but not access it', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithMediaStartNode(userGroupName, childFolderOneId); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + + // Act + await umbracoUi.user.goToSection(ConstantHelper.sections.media, false); + + // Assert + await umbracoUi.media.isMediaTreeItemVisible(rootFolderName); + await umbracoUi.waitForTimeout(500); + await umbracoUi.media.goToMediaWithName(rootFolderName); + await umbracoUi.media.doesErrorNotificationHaveText(NotificationConstantHelper.error.noAccessToResource); + await umbracoUi.media.clickCaretButtonForMediaName(rootFolderName); + await umbracoUi.media.isChildMediaVisible(rootFolderName, childFolderOneName); + await umbracoUi.media.isChildMediaVisible(rootFolderName, childFolderTwoName, false); +}); + +test('can not see any media when no media start nodes specified', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createSimpleUserGroupWithMediaSection(userGroupName); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + + // Act + await umbracoUi.user.goToSection(ConstantHelper.sections.media, false); + + // Assert + await umbracoUi.media.isMediaTreeItemVisible(rootFolderName, false); +}); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/UserGroup/MemberSection.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/UserGroup/MemberSection.spec.ts new file mode 100644 index 0000000000..ebd1f60699 --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/UserGroup/MemberSection.spec.ts @@ -0,0 +1,99 @@ +import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers'; +import {expect} from "@playwright/test"; + +const testUser = ConstantHelper.testUserCredentials; +let testUserCookieAndToken = {cookie: "", accessToken: "", refreshToken: ""}; + +const userGroupName = 'TestUserGroup'; +let userGroupId = null; + +let memberId = ''; +let memberTypeId = ''; +const memberName = 'Test Member'; +const memberTypeName = 'Test Member Type'; +const comment = 'This is test comment'; +const username = 'testmember'; +const email = 'testmember@acceptance.test'; +const password = '0123456789'; + +test.beforeEach(async ({umbracoApi}) => { + await umbracoApi.memberType.ensureNameNotExists(memberTypeName); + await umbracoApi.member.ensureNameNotExists(memberName); + await umbracoApi.user.ensureNameNotExists(testUser.name); + await umbracoApi.userGroup.ensureNameNotExists(userGroupName); +}); + +test.afterEach(async ({umbracoApi}) => { + // Ensure we are logged in to admin + await umbracoApi.loginToAdminUser(testUserCookieAndToken.cookie, testUserCookieAndToken.accessToken, testUserCookieAndToken.refreshToken); + await umbracoApi.memberType.ensureNameNotExists(memberTypeName); + await umbracoApi.member.ensureNameNotExists(memberName); + await umbracoApi.userGroup.ensureNameNotExists(userGroupName); +}); + +test('can access members section with section enabled', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithMemberSection(userGroupName); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId, [], true, [], false, 'en-us'); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + + // Act + await umbracoUi.member.goToSection(ConstantHelper.sections.members, false); + + // Assert + await umbracoUi.user.isSectionWithNameVisible(ConstantHelper.sections.content, false); + await umbracoUi.member.doesErrorNotificationHaveText(NotificationConstantHelper.error.noAccessToResource, false); +}); + +// TODO: unskip when member creation is fixed +test.skip('can create member with members section set', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithMemberSection(userGroupName); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId, [], true, [], false, 'en-us'); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + await umbracoUi.member.goToSection(ConstantHelper.sections.members, false); + await umbracoUi.member.clickMembersMenu(); + + // Act + await umbracoUi.member.clickCreateButton(); + await umbracoUi.member.enterMemberName(memberName); + await umbracoUi.member.clickInfoTab(); + await umbracoUi.member.enterUsername(username); + await umbracoUi.member.enterEmail(email); + await umbracoUi.member.enterPassword(password); + await umbracoUi.member.enterConfirmPassword(password); + await umbracoUi.member.clickDetailsTab(); + await umbracoUi.member.enterComments(comment); + await umbracoUi.member.clickSaveButton(); + + // Assert + await umbracoUi.member.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); + await umbracoUi.member.doesErrorNotificationHaveText(NotificationConstantHelper.error.noAccessToResource, false); + expect(await umbracoApi.member.doesNameExist(memberName)).toBeTruthy(); +}); + +// TODO: unskip when member creation is fixed +test.skip('can update member with members section set', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createUserGroupWithMemberSection(userGroupName); + memberTypeId = await umbracoApi.memberType.createDefaultMemberType(memberTypeName); + memberId = await umbracoApi.member.createDefaultMember(memberName, memberTypeId, email, username, password); + const updatedUsername = 'updatedusername'; + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId, [], true, [], false, 'en-us'); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + await umbracoUi.goToBackOffice(); + await umbracoUi.member.goToSection(ConstantHelper.sections.members, false); + + // Act + await umbracoUi.member.clickMemberLinkByName(memberName); + await umbracoUi.member.enterUsername(updatedUsername); + await umbracoUi.member.clickSaveButton(); + + // Assert + await umbracoUi.member.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + await umbracoUi.member.doesErrorNotificationHaveText(NotificationConstantHelper.error.noAccessToResource, false); + const memberData = await umbracoApi.member.get(memberId); + expect(memberData.username).toBe(updatedUsername); +}); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/UserGroup/Sections.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/UserGroup/Sections.spec.ts new file mode 100644 index 0000000000..0932ab7f62 --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/UserGroup/Sections.spec.ts @@ -0,0 +1,51 @@ +import {ConstantHelper, test} from '@umbraco/playwright-testhelpers'; + +const testUser = ConstantHelper.testUserCredentials; +let testUserCookieAndToken = {cookie: "", accessToken: "", refreshToken: ""}; + +const userGroupName = 'TestUserGroup'; +let userGroupId = null; + +test.beforeEach(async ({umbracoApi}) => { + await umbracoApi.user.ensureNameNotExists(testUser.name); + await umbracoApi.userGroup.ensureNameNotExists(userGroupName); +}); + +test.afterEach(async ({umbracoApi}) => { + // Ensure we are logged in to admin + await umbracoApi.loginToAdminUser(testUserCookieAndToken.cookie, testUserCookieAndToken.accessToken, testUserCookieAndToken.refreshToken); + await umbracoApi.userGroup.ensureNameNotExists(userGroupName); +}); + +test('can go to section defined in userGroup', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createSimpleUserGroupWithContentSection(userGroupName); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + + // Act + await umbracoUi.goToBackOffice(); + + // Assert + await umbracoUi.content.isSectionWithNameVisible(ConstantHelper.sections.content); + await umbracoUi.content.goToSection(ConstantHelper.sections.content, false); +}); + +test('can not see section that is not defined in userGroup', async ({umbracoApi, umbracoUi}) => { + // Arrange + userGroupId = await umbracoApi.userGroup.createSimpleUserGroupWithContentSection(userGroupName); + await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId); + testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password); + + // Act + await umbracoUi.goToBackOffice(); + + // Assert + await umbracoUi.content.isSectionWithNameVisible(ConstantHelper.sections.content); + await umbracoUi.content.isSectionWithNameVisible(ConstantHelper.sections.media, false); + await umbracoUi.content.isSectionWithNameVisible(ConstantHelper.sections.settings, false); + await umbracoUi.content.isSectionWithNameVisible(ConstantHelper.sections.users, false); + await umbracoUi.content.isSectionWithNameVisible(ConstantHelper.sections.members, false); + await umbracoUi.content.isSectionWithNameVisible(ConstantHelper.sections.dictionary, false); + await umbracoUi.content.isSectionWithNameVisible(ConstantHelper.sections.packages, false); +}); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/User.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/User.spec.ts index a1b2494350..cee0518f9c 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/User.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/User.spec.ts @@ -1,16 +1,19 @@ -import {test} from '@umbraco/playwright-testhelpers'; +import {NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers'; import {expect} from '@playwright/test'; const nameOfTheUser = 'TestUser'; const userEmail = 'TestUser@EmailTest.test'; const defaultUserGroupName = 'Writers'; +let userCount = null; test.beforeEach(async ({umbracoUi, umbracoApi}) => { await umbracoUi.goToBackOffice(); await umbracoApi.user.ensureNameNotExists(nameOfTheUser); }); -test.afterEach(async ({umbracoApi}) => { +test.afterEach(async ({umbracoApi, umbracoUi}) => { + // Waits so we can try to avoid db locks + await umbracoUi.waitForTimeout(500); await umbracoApi.user.ensureNameNotExists(nameOfTheUser); }); @@ -29,7 +32,7 @@ test('can create a user', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => { await umbracoUi.user.clickCreateUserButton(); // Assert - await umbracoUi.user.isSuccessNotificationVisible(); + await umbracoUi.user.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); expect(await umbracoApi.user.doesNameExist(nameOfTheUser)).toBeTruthy(); }); @@ -47,7 +50,7 @@ test('can rename a user', async ({umbracoApi, umbracoUi}) => { await umbracoUi.user.clickSaveButton(); // Assert - await umbracoUi.user.isSuccessNotificationVisible(); + await umbracoUi.user.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); expect(await umbracoApi.user.doesNameExist(nameOfTheUser)).toBeTruthy(); }); @@ -64,7 +67,7 @@ test('can delete a user', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => { await umbracoUi.user.clickConfirmToDeleteButton(); // Assert - await umbracoUi.user.isSuccessNotificationVisible(); + await umbracoUi.user.doesSuccessNotificationHaveText(NotificationConstantHelper.success.deleted); expect(await umbracoApi.user.doesNameExist(nameOfTheUser)).toBeFalsy(); // Checks if the user is deleted from the list await umbracoUi.user.clickUsersMenu(); @@ -87,8 +90,7 @@ test('can add multiple user groups to a user', async ({umbracoApi, umbracoUi}) = await umbracoUi.user.clickSaveButton(); // Assert - await umbracoUi.user.isSuccessNotificationVisible(); - await umbracoApi.user.getByName(nameOfTheUser); + await umbracoUi.user.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); expect(await umbracoApi.user.doesUserContainUserGroupIds(nameOfTheUser, [userGroupWriters.id, userGroupTranslators.id])).toBeTruthy(); }); @@ -105,7 +107,7 @@ test('can remove a user group from a user', {tag: '@smoke'}, async ({umbracoApi, await umbracoUi.user.clickSaveButton(); // Assert - await umbracoUi.user.isSuccessNotificationVisible(); + await umbracoUi.user.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const userData = await umbracoApi.user.getByName(nameOfTheUser); expect(userData.userGroupIds).toEqual([]); }); @@ -123,7 +125,7 @@ test('can update culture for a user', async ({umbracoApi, umbracoUi}) => { await umbracoUi.user.clickSaveButton(); // Assert - await umbracoUi.user.isSuccessNotificationVisible(); + await umbracoUi.user.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const userData = await umbracoApi.user.getByName(nameOfTheUser); expect(userData.languageIsoCode).toEqual(danishIsoCode); }); @@ -148,7 +150,7 @@ test('can add a content start node to a user', {tag: '@smoke'}, async ({umbracoA await umbracoUi.user.clickSaveButton(); // Assert - await umbracoUi.user.isSuccessNotificationVisible(); + await umbracoUi.user.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); expect(await umbracoApi.user.doesUserContainContentStartNodeIds(nameOfTheUser, [documentId])).toBeTruthy(); // Clean @@ -183,7 +185,7 @@ test('can add multiple content start nodes for a user', async ({umbracoApi, umbr await umbracoUi.user.clickSaveButton(); // Assert - await umbracoUi.user.isSuccessNotificationVisible(); + await umbracoUi.user.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); expect(await umbracoApi.user.doesUserContainContentStartNodeIds(nameOfTheUser, [documentId, secondDocumentId])).toBeTruthy(); // Clean @@ -216,7 +218,7 @@ test('can remove a content start node from a user', {tag: '@smoke'}, async ({umb await umbracoUi.user.clickSaveButton(); // Assert - await umbracoUi.user.isSuccessNotificationVisible(); + await umbracoUi.user.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); expect(await umbracoApi.user.doesUserContainContentStartNodeIds(nameOfTheUser, [documentId])).toBeFalsy(); // Clean @@ -241,7 +243,7 @@ test('can add media start nodes for a user', {tag: '@smoke'}, async ({umbracoApi await umbracoUi.user.clickSaveButton(); // Assert - await umbracoUi.user.isSuccessNotificationVisible(); + await umbracoUi.user.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); expect(await umbracoApi.user.doesUserContainMediaStartNodeIds(nameOfTheUser, [mediaId])).toBeTruthy(); // Clean @@ -273,7 +275,7 @@ test('can add multiple media start nodes for a user', async ({umbracoApi, umbrac await umbracoUi.user.clickSaveButton(); // Assert - await umbracoUi.user.isSuccessNotificationVisible(); + await umbracoUi.user.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); expect(await umbracoApi.user.doesUserContainMediaStartNodeIds(nameOfTheUser, [firstMediaId, secondMediaId])).toBeTruthy(); // Clean @@ -302,7 +304,7 @@ test('can remove a media start node from a user', async ({umbracoApi, umbracoUi} await umbracoUi.user.clickSaveButton(); // Assert - await umbracoUi.user.isSuccessNotificationVisible(); + await umbracoUi.user.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); expect(await umbracoApi.user.doesUserContainMediaStartNodeIds(nameOfTheUser, [mediaId])).toBeFalsy(); // Clean @@ -321,7 +323,7 @@ test('can allow access to all documents for a user', async ({umbracoApi, umbraco await umbracoUi.user.clickSaveButton(); // Assert - await umbracoUi.user.isSuccessNotificationVisible(); + await umbracoUi.user.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const userData = await umbracoApi.user.getByName(nameOfTheUser); expect(userData.hasDocumentRootAccess).toBeTruthy() }); @@ -338,7 +340,7 @@ test('can allow access to all media for a user', async ({umbracoApi, umbracoUi}) await umbracoUi.user.clickSaveButton(); // Assert - await umbracoUi.user.isSuccessNotificationVisible(); + await umbracoUi.user.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); const userData = await umbracoApi.user.getByName(nameOfTheUser); expect(userData.hasMediaRootAccess).toBeTruthy(); }); @@ -415,43 +417,55 @@ test('can change password for a user', {tag: '@smoke'}, async ({umbracoApi, umbr test('can disable a user', async ({umbracoApi, umbracoUi}) => { // Arrange const disabledStatus = 'Disabled'; + // We need to create a new user because the "TestUser" is used in other tests, which can affect if the user is disabled or not + const newTestUser = 'TestUserNumberTwo'; + await umbracoApi.user.ensureNameNotExists(newTestUser); const userGroup = await umbracoApi.userGroup.getByName(defaultUserGroupName); - await umbracoApi.user.createDefaultUser(nameOfTheUser, userEmail, [userGroup.id]); + await umbracoApi.user.createDefaultUser(newTestUser, newTestUser + userEmail, [userGroup.id]); await umbracoUi.user.goToUsers(); // Act - await umbracoUi.user.clickUserWithName(nameOfTheUser); + await umbracoUi.user.clickUserWithName(newTestUser); await umbracoUi.user.clickActionButton(); await umbracoUi.user.clickDisableButton(); await umbracoUi.user.clickConfirmDisableButton(); // Assert - await umbracoUi.user.isSuccessNotificationVisible(); + await umbracoUi.user.doesSuccessNotificationHaveText(newTestUser + NotificationConstantHelper.success.userDisabled); expect(umbracoUi.user.isUserDisabledTextVisible()).toBeTruthy(); - const userData = await umbracoApi.user.getByName(nameOfTheUser); + const userData = await umbracoApi.user.getByName(newTestUser); expect(userData.state).toBe(disabledStatus); + + // Clean + await umbracoApi.user.ensureNameNotExists(newTestUser); }); test('can enable a user', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => { // Arrange const inactiveStatus = 'Inactive'; + const newTestUser = 'TestUserNumberTwo'; + await umbracoApi.user.ensureNameNotExists(newTestUser); const userGroup = await umbracoApi.userGroup.getByName(defaultUserGroupName); - const userId = await umbracoApi.user.createDefaultUser(nameOfTheUser, userEmail, [userGroup.id]); + const userId = await umbracoApi.user.createDefaultUser(newTestUser, newTestUser + userEmail, [userGroup.id]); await umbracoApi.user.disable([userId]); await umbracoUi.user.goToUsers(); // Act - await umbracoUi.user.clickUserWithName(nameOfTheUser); + await umbracoUi.user.clickUserWithName(newTestUser); await umbracoUi.user.clickActionButton(); await umbracoUi.user.clickEnableButton(); await umbracoUi.user.clickConfirmEnableButton(); // Assert - await umbracoUi.user.isSuccessNotificationVisible(); + // TODO: Unskip when it shows userEnabled/userInactive instead of userDisabled + // await umbracoUi.user.doesSuccessNotificationHaveText(NotificationConstantHelper.success.userEnabled); await umbracoUi.user.isUserActiveTextVisible(); // The state of the user is not enabled. The reason for this is that the user has not logged in, resulting in the state Inactive. - const userData = await umbracoApi.user.getByName(nameOfTheUser); + const userData = await umbracoApi.user.getByName(newTestUser); expect(userData.state).toBe(inactiveStatus); + + // Clean + await umbracoApi.user.ensureNameNotExists(newTestUser); }); test('can add an avatar to a user', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => { @@ -466,7 +480,7 @@ test('can add an avatar to a user', {tag: '@smoke'}, async ({umbracoApi, umbraco await umbracoUi.user.changePhotoWithFileChooser(filePath); // Assert - await umbracoUi.user.isSuccessNotificationVisible(); + await umbracoUi.user.doesSuccessNotificationHaveText(NotificationConstantHelper.success.avatarUploaded); const userData = await umbracoApi.user.getByName(nameOfTheUser); expect(userData.avatarUrls).not.toHaveLength(0); }); @@ -483,7 +497,7 @@ test('can remove an avatar from a user', async ({umbracoApi, umbracoUi}) => { await umbracoUi.user.clickRemovePhotoButton(); // Assert - await umbracoUi.user.isSuccessNotificationVisible(); + await umbracoUi.user.doesSuccessNotificationHaveText(NotificationConstantHelper.success.avatarDeleted); const userData = await umbracoApi.user.getByName(nameOfTheUser); expect(userData.avatarUrls).toHaveLength(0); }); @@ -507,11 +521,11 @@ test('can search for a user', async ({umbracoApi, umbracoUi}) => { // Arrange const userGroup = await umbracoApi.userGroup.getByName(defaultUserGroupName); await umbracoApi.user.createDefaultUser(nameOfTheUser, userEmail, [userGroup.id]); - const totalUsers = await umbracoApi.user.getUsersCount(); + userCount = await umbracoApi.user.getUsersCount(); await umbracoUi.user.goToUsers(); // Act - await umbracoUi.user.doesUserSectionContainUserAmount(totalUsers); + await umbracoUi.user.doesUserSectionContainUserAmount(userCount); await umbracoUi.user.searchInUserSection(nameOfTheUser); // Assert @@ -527,11 +541,11 @@ test('can filter by status', async ({umbracoApi, umbracoUi}) => { const inactiveStatus = 'Inactive'; const userGroup = await umbracoApi.userGroup.getByName(defaultUserGroupName); await umbracoApi.user.createDefaultUser(nameOfTheUser, userEmail, [userGroup.id]); - const totalUsers = await umbracoApi.user.getUsersCount(); + userCount = await umbracoApi.user.getUsersCount(); await umbracoUi.user.goToUsers(); // Act - await umbracoUi.user.doesUserSectionContainUserAmount(totalUsers); + await umbracoUi.user.doesUserSectionContainUserAmount(userCount); await umbracoUi.user.filterByStatusName(inactiveStatus); // Assert @@ -547,11 +561,11 @@ test('can filter by user groups', async ({umbracoApi, umbracoUi}) => { // Arrange const userGroup = await umbracoApi.userGroup.getByName(defaultUserGroupName); await umbracoApi.user.createDefaultUser(nameOfTheUser, userEmail, [userGroup.id]); - const totalUsers = await umbracoApi.user.getUsersCount(); + userCount = await umbracoApi.user.getUsersCount(); await umbracoUi.user.goToUsers(); // Act - await umbracoUi.user.doesUserSectionContainUserAmount(totalUsers); + await umbracoUi.user.doesUserSectionContainUserAmount(userCount); await umbracoUi.user.filterByGroupName(defaultUserGroupName); // Assert @@ -566,17 +580,18 @@ test('can order by newest user', async ({umbracoApi, umbracoUi}) => { // Arrange const userGroup = await umbracoApi.userGroup.getByName(defaultUserGroupName); await umbracoApi.user.createDefaultUser(nameOfTheUser, userEmail, [userGroup.id]); - const totalUsers = await umbracoApi.user.getUsersCount(); + userCount = await umbracoApi.user.getUsersCount(); await umbracoUi.user.goToUsers(); // Act - await umbracoUi.user.doesUserSectionContainUserAmount(totalUsers); + await umbracoUi.user.doesUserSectionContainUserAmount(userCount); await umbracoUi.user.orderByNewestUser(); // Assert // Wait for filtering to be done await umbracoUi.waitForTimeout(200); - await umbracoUi.user.doesUserSectionContainUserAmount(totalUsers); + + await umbracoUi.user.doesUserSectionContainUserAmount(userCount); await umbracoUi.user.isUserWithNameTheFirstUserInList(nameOfTheUser); }); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/UserGroups.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/UserGroups.spec.ts new file mode 100644 index 0000000000..59aeeffd73 --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/UserGroups.spec.ts @@ -0,0 +1,476 @@ +import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers'; +import {expect} from "@playwright/test"; + +const allPermissions = { + uiPermission: + ['Browse Node', + 'Create Document Blueprint', + 'Delete', + 'Create', + 'Notifications', + 'Publish', + 'Set permissions', + 'Unpublish', + 'Update', + 'Duplicate', + 'Move to', + 'Sort children', + 'Culture and Hostnames', + 'Public Access', + 'Rollback'], + verbPermission: [ + 'Umb.Document.Read', + 'Umb.Document.CreateBlueprint', + 'Umb.Document.Delete', + 'Umb.Document.Create', + 'Umb.Document.Notifications', + 'Umb.Document.Publish', + 'Umb.Document.Permissions', + 'Umb.Document.Unpublish', + 'Umb.Document.Update', + 'Umb.Document.Duplicate', + 'Umb.Document.Move', + 'Umb.Document.Sort', + 'Umb.Document.CultureAndHostnames', + 'Umb.Document.PublicAccess', + 'Umb.Document.Rollback' + ] +}; + +const englishLanguage = 'English (United States)'; + +const userGroupName = 'TestUserGroupName'; + +test.beforeEach(async ({umbracoUi, umbracoApi}) => { + await umbracoApi.userGroup.ensureNameNotExists(userGroupName); + await umbracoUi.goToBackOffice(); + await umbracoUi.userGroup.goToSection(ConstantHelper.sections.users); +}); + +test.afterEach(async ({umbracoApi}) => { + await umbracoApi.userGroup.ensureNameNotExists(userGroupName); +}); + +test('can create an empty user group', async ({page, umbracoApi, umbracoUi}) => { + // Act + await umbracoUi.userGroup.clickUserGroupsButton(); + await page.pause(); + await umbracoUi.userGroup.clickCreateButton(); + await umbracoUi.userGroup.enterUserGroupName(userGroupName); + await umbracoUi.userGroup.clickSaveButton(); + + // Assert + await umbracoUi.userGroup.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); + expect(await umbracoApi.userGroup.doesNameExist(userGroupName)).toBeTruthy(); + // Checks if the user group was created in the UI as well + await umbracoUi.userGroup.clickUserGroupsButton(); + await umbracoUi.userGroup.isUserGroupWithNameVisible(userGroupName); +}); + +test('can rename a user group', async ({umbracoApi, umbracoUi}) => { + // Arrange + const oldUserGroupName = 'OldUserGroupName'; + await umbracoApi.userGroup.ensureNameNotExists(oldUserGroupName); + await umbracoApi.userGroup.createEmptyUserGroup(oldUserGroupName); + await umbracoUi.userGroup.clickUserGroupsButton(); + await umbracoUi.userGroup.clickUserGroupWithName(oldUserGroupName); + + // Act + await umbracoUi.userGroup.enterUserGroupName(userGroupName); + await umbracoUi.userGroup.clickSaveButton(); + + // Assert + await umbracoUi.userGroup.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + expect(await umbracoApi.userGroup.doesNameExist(userGroupName)).toBeTruthy(); + // Checks if the user group was created in the UI as well + await umbracoUi.userGroup.clickUserGroupsButton(); + await umbracoUi.userGroup.isUserGroupWithNameVisible(userGroupName); + await umbracoUi.userGroup.isUserGroupWithNameVisible(oldUserGroupName, false); +}); + +test('can update a user group', async ({umbracoApi, umbracoUi}) => { + // Arrange + await umbracoApi.userGroup.createEmptyUserGroup(userGroupName); + await umbracoUi.userGroup.clickUserGroupsButton(); + await umbracoUi.userGroup.clickUserGroupWithName(userGroupName); + + // Act + await umbracoUi.userGroup.clickPermissionsByName([allPermissions.uiPermission[0]]); + await umbracoUi.userGroup.clickSaveButton(); + + // Assert + await umbracoUi.userGroup.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + await umbracoUi.reloadPage(); + await umbracoUi.userGroup.doesUserGroupHavePermission(allPermissions.uiPermission[0]); + const userGroupData = await umbracoApi.userGroup.getByName(userGroupName); + expect(userGroupData.fallbackPermissions).toContain(allPermissions.verbPermission[0]); +}); + +test('can delete a user group', async ({umbracoApi, umbracoUi}) => { + // Arrange + await umbracoApi.userGroup.createSimpleUserGroupWithContentSection(userGroupName); + await umbracoUi.userGroup.clickUserGroupsButton(); + await umbracoUi.userGroup.clickUserGroupWithName(userGroupName); + + // Act + await umbracoUi.userGroup.clickActionsButton(); + await umbracoUi.userGroup.clickDeleteThreeDotsButton(); + await umbracoUi.userGroup.clickConfirmToDeleteButton(); + + // Assert + await umbracoUi.userGroup.doesSuccessNotificationHaveText(NotificationConstantHelper.success.deleted); + expect(await umbracoApi.userGroup.doesNameExist(userGroupName)).toBeFalsy(); + await umbracoUi.userGroup.clickUserGroupsButton(); + await umbracoUi.userGroup.isUserGroupWithNameVisible(userGroupName, false); +}); + +test('can add a section to a user group', async ({umbracoApi, umbracoUi}) => { + // Arrange + await umbracoApi.userGroup.createEmptyUserGroup(userGroupName); + await umbracoUi.userGroup.clickUserGroupsButton(); + await umbracoUi.userGroup.clickUserGroupWithName(userGroupName); + + // Act + await umbracoUi.userGroup.addSectionWithNameToUserGroup('Content'); + await umbracoUi.userGroup.clickSaveButton(); + + // Assert + await umbracoUi.userGroup.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + await umbracoUi.userGroup.clickUserGroupsButton(); + await umbracoUi.userGroup.doesUserGroupHaveSection(userGroupName, 'Content'); +}) + +test('can add multiple sections to a user group', async ({umbracoApi, umbracoUi}) => { + // Arrange + await umbracoApi.userGroup.createSimpleUserGroupWithContentSection(userGroupName); + await umbracoUi.userGroup.clickUserGroupsButton(); + await umbracoUi.userGroup.clickUserGroupWithName(userGroupName); + + // Act + await umbracoUi.userGroup.addSectionWithNameToUserGroup('Media'); + await umbracoUi.userGroup.clickSaveButton(); + + // Assert + await umbracoUi.userGroup.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + await umbracoUi.userGroup.clickUserGroupsButton(); + await umbracoUi.userGroup.doesUserGroupHaveSection(userGroupName, 'Content'); + await umbracoUi.userGroup.doesUserGroupHaveSection(userGroupName, 'Media'); +}); + +test('can remove a section from a user group', async ({umbracoApi, umbracoUi}) => { + // Arrange + await umbracoApi.userGroup.createSimpleUserGroupWithContentSection(userGroupName); + await umbracoUi.userGroup.clickUserGroupsButton(); + await umbracoUi.userGroup.clickUserGroupWithName(userGroupName); + + // Act + await umbracoUi.userGroup.clickRemoveSectionFromUserGroup('Content'); + await umbracoUi.userGroup.clickConfirmRemoveButton(); + await umbracoUi.userGroup.clickSaveButton(); + + // Assert + await umbracoUi.userGroup.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + await umbracoUi.userGroup.clickUserGroupsButton(); + await umbracoUi.userGroup.doesUserGroupHaveSection(userGroupName, 'Content', false); + const userGroupData = await umbracoApi.userGroup.getByName(userGroupName); + expect(userGroupData.sections).toEqual([]); +}); + +test('can add a language to a user group', async ({umbracoApi, umbracoUi}) => { + // Arrange + await umbracoApi.userGroup.createEmptyUserGroup(userGroupName); + await umbracoUi.userGroup.clickUserGroupsButton(); + await umbracoUi.userGroup.clickUserGroupWithName(userGroupName); + + // Act + await umbracoUi.userGroup.addLanguageToUserGroup(englishLanguage); + await umbracoUi.userGroup.clickSaveButton(); + + // Assert + await umbracoUi.userGroup.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + await umbracoUi.reloadPage(); + await umbracoUi.userGroup.doesUserGroupContainLanguage(englishLanguage); + expect(await umbracoApi.userGroup.doesUserGroupContainLanguage(userGroupName, 'en-US')).toBeTruthy(); +}) + +test('can enable all languages for a user group', async ({umbracoApi, umbracoUi}) => { + // Arrange + await umbracoApi.userGroup.createEmptyUserGroup(userGroupName); + await umbracoUi.userGroup.clickUserGroupsButton(); + await umbracoUi.userGroup.clickUserGroupWithName(userGroupName); + + // Act + await umbracoUi.userGroup.clickAllowAccessToAllLanguages(); + await umbracoUi.userGroup.clickSaveButton(); + + // Assert + await umbracoUi.userGroup.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + expect(await umbracoApi.userGroup.doesUserGroupContainAccessToAllLanguages(userGroupName)).toBeTruthy(); +}) + +test('can add multiple languages to a user group', async ({umbracoApi, umbracoUi}) => { + // Arrange + await umbracoApi.userGroup.createUserGroupWithLanguage(userGroupName, 'en-US'); + const danishLanguage = 'Danish'; + await umbracoApi.language.ensureNameNotExists(danishLanguage); + await umbracoApi.language.createDanishLanguage(); + await umbracoUi.userGroup.clickUserGroupsButton(); + await umbracoUi.userGroup.clickUserGroupWithName(userGroupName); + + // Act + await umbracoUi.userGroup.addLanguageToUserGroup(danishLanguage); + await umbracoUi.userGroup.clickSaveButton(); + + // Assert + await umbracoUi.userGroup.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + await umbracoUi.reloadPage(); + await umbracoUi.userGroup.doesUserGroupContainLanguage(englishLanguage); + await umbracoUi.userGroup.doesUserGroupContainLanguage(danishLanguage); + expect(await umbracoApi.userGroup.doesUserGroupContainLanguage(userGroupName, 'en-US')).toBeTruthy(); + expect(await umbracoApi.userGroup.doesUserGroupContainLanguage(userGroupName, 'da')).toBeTruthy(); + + // Clean + await umbracoApi.language.ensureNameNotExists(danishLanguage); +}) + +test('can remove language from a user group', async ({umbracoApi, umbracoUi}) => { + // Arrange + await umbracoApi.userGroup.createUserGroupWithLanguage(userGroupName, 'en-US'); + expect(await umbracoApi.userGroup.doesUserGroupContainLanguage(userGroupName, 'en-US')).toBeTruthy(); + await umbracoUi.userGroup.clickUserGroupsButton(); + await umbracoUi.userGroup.clickUserGroupWithName(userGroupName); + + // Act + await umbracoUi.userGroup.clickRemoveLanguageFromUserGroup(englishLanguage); + await umbracoUi.userGroup.clickConfirmRemoveButton(); + await umbracoUi.userGroup.clickSaveButton(); + + // Assert + await umbracoUi.userGroup.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + await umbracoUi.reloadPage(); + await umbracoUi.userGroup.doesUserGroupContainLanguage(englishLanguage, false); + expect(await umbracoApi.userGroup.doesUserGroupContainLanguage(userGroupName, 'en-US')).toBeFalsy(); +}) + +test('can add a content start node to a user group', async ({umbracoApi, umbracoUi}) => { + // Arrange + await umbracoApi.userGroup.createEmptyUserGroup(userGroupName); + const documentTypeName = 'TestDocumentType'; + const documentName = 'TestDocument'; + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + const documentTypeId = await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(documentTypeName); + const documentId = await umbracoApi.document.createDefaultDocument(documentName, documentTypeId); + await umbracoUi.userGroup.clickUserGroupsButton(); + await umbracoUi.userGroup.clickUserGroupWithName(userGroupName); + + // Act + await umbracoUi.userGroup.clickChooseContentStartNodeButton(); + await umbracoUi.userGroup.clickLabelWithName(documentName); + await umbracoUi.userGroup.clickChooseContainerButton(); + await umbracoUi.userGroup.clickSaveButton(); + + // Assert + await umbracoUi.userGroup.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + expect(await umbracoApi.userGroup.doesUserGroupContainContentStartNodeId(userGroupName, documentId)).toBeTruthy(); + + // Clean + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); +}); + +test('can remove a content start node from a user group ', async ({umbracoApi, umbracoUi}) => { + // Arrange + const documentTypeName = 'TestDocumentType'; + const documentName = 'TestDocument'; + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + const documentTypeId = await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(documentTypeName); + const documentId = await umbracoApi.document.createDefaultDocument(documentName, documentTypeId); + await umbracoApi.userGroup.createUserGroupWithDocumentStartNode(userGroupName, documentId); + expect(await umbracoApi.userGroup.doesUserGroupContainContentStartNodeId(userGroupName, documentId)).toBeTruthy(); + await umbracoUi.userGroup.clickUserGroupsButton(); + await umbracoUi.userGroup.clickUserGroupWithName(userGroupName); + + // Act + await umbracoUi.userGroup.clickRemoveContentStartNodeFromUserGroup(documentName); + await umbracoUi.userGroup.clickConfirmRemoveButton(); + await umbracoUi.userGroup.clickSaveButton(); + + // Assert + await umbracoUi.userGroup.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + expect(await umbracoApi.userGroup.doesUserGroupContainContentStartNodeId(userGroupName, documentId)).toBeFalsy(); + + // Clean + await umbracoApi.document.ensureNameNotExists(documentTypeName); +}); + +test('can enable access to all content from a user group ', async ({umbracoApi, umbracoUi}) => { + // Arrange + await umbracoApi.userGroup.createEmptyUserGroup(userGroupName); + await umbracoUi.userGroup.clickUserGroupsButton(); + await umbracoUi.userGroup.clickUserGroupWithName(userGroupName); + + // Act + await umbracoUi.userGroup.clickAllowAccessToAllDocuments(); + await umbracoUi.userGroup.clickSaveButton(); + + // Assert + await umbracoUi.userGroup.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + expect(await umbracoApi.userGroup.doesUserGroupContainDocumentRootAccess(userGroupName)).toBeTruthy(); +}); + +test('can add a media start node to a user group', async ({umbracoApi, umbracoUi}) => { + // Arrange + await umbracoApi.userGroup.createEmptyUserGroup(userGroupName); + const mediaName = 'TestMedia'; + await umbracoApi.media.ensureNameNotExists(mediaName); + const mediaId = await umbracoApi.media.createDefaultMediaFile(mediaName); + await umbracoUi.userGroup.clickUserGroupsButton(); + await umbracoUi.userGroup.clickUserGroupWithName(userGroupName); + + // Act + await umbracoUi.userGroup.clickChooseMediaStartNodeButton(); + await umbracoUi.userGroup.clickMediaCardWithName(mediaName); + await umbracoUi.userGroup.clickSubmitButton(); + await umbracoUi.userGroup.clickSaveButton(); + + // Assert + await umbracoUi.userGroup.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + expect(await umbracoApi.userGroup.doesUserGroupContainMediaStartNodeId(userGroupName, mediaId)).toBeTruthy(); + + // Clean + await umbracoApi.media.ensureNameNotExists(mediaName); +}); + +test('can remove a media start node from a user group ', async ({umbracoApi, umbracoUi}) => { + // Arrange + const mediaName = 'TestMedia'; + await umbracoApi.media.ensureNameNotExists(mediaName); + const mediaId = await umbracoApi.media.createDefaultMediaFile(mediaName); + await umbracoApi.userGroup.createUserGroupWithMediaStartNode(userGroupName, mediaId); + expect(await umbracoApi.userGroup.doesUserGroupContainMediaStartNodeId(userGroupName, mediaId)).toBeTruthy(); + await umbracoUi.userGroup.clickUserGroupsButton(); + await umbracoUi.userGroup.clickUserGroupWithName(userGroupName); + + // Act + await umbracoUi.userGroup.clickRemoveMediaStartNodeFromUserGroup(mediaName); + await umbracoUi.userGroup.clickConfirmRemoveButton(); + await umbracoUi.userGroup.clickSaveButton(); + + // Assert + await umbracoUi.userGroup.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + expect(await umbracoApi.userGroup.doesUserGroupContainMediaStartNodeId(userGroupName, mediaId)).toBeFalsy(); + + // Clean + await umbracoApi.media.ensureNameNotExists(mediaName); +}); + +test('can enable access to all media in a user group ', async ({umbracoApi, umbracoUi}) => { + // Arrange + await umbracoApi.userGroup.createEmptyUserGroup(userGroupName); + await umbracoUi.userGroup.clickUserGroupsButton(); + await umbracoUi.userGroup.clickUserGroupWithName(userGroupName); + + // Act + await umbracoUi.userGroup.clickAllowAccessToAllMedia(); + await umbracoUi.userGroup.clickSaveButton(); + + // Assert + await umbracoUi.userGroup.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + expect(await umbracoApi.userGroup.doesUserGroupContainMediaRootAccess(userGroupName)).toBeTruthy(); +}); + +test('can enable all permissions for a user group', async ({umbracoApi, umbracoUi}) => { + // Arrange + await umbracoApi.userGroup.createEmptyUserGroup(userGroupName); + + // Act + await umbracoUi.userGroup.clickUserGroupsButton(); + await umbracoUi.userGroup.clickUserGroupWithName(userGroupName); + await umbracoUi.userGroup.clickPermissionsByName(allPermissions.uiPermission); + await umbracoUi.userGroup.clickSaveButton(); + + // Assert + await umbracoUi.userGroup.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + await umbracoUi.reloadPage(); + await umbracoUi.userGroup.doesUserGroupHavePermissionEnabled(allPermissions.uiPermission); + const userGroupData = await umbracoApi.userGroup.getByName(userGroupName); + expect(userGroupData.fallbackPermissions).toEqual(allPermissions.verbPermission); +}); + +test('can add granular permission to a specific document for a user group', async ({umbracoApi, umbracoUi}) => { + // Arrange + const documentTypeName = 'TestDocumentType'; + const documentName = 'TestDocument'; + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + const documentTypeId = await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(documentTypeName); + const documentId = await umbracoApi.document.createDefaultDocument(documentName, documentTypeId); + await umbracoApi.userGroup.createEmptyUserGroup(userGroupName); + await umbracoUi.userGroup.clickUserGroupsButton(); + await umbracoUi.userGroup.clickUserGroupWithName(userGroupName); + + // Act + await umbracoUi.userGroup.clickAddGranularPermission(); + await umbracoUi.userGroup.clickLabelWithName(documentName); + await umbracoUi.userGroup.clickGranularPermissionsByName([allPermissions.uiPermission[0]]); + await umbracoUi.userGroup.clickConfirmButton(); + await umbracoUi.userGroup.clickSaveButton(); + + // Assert + await umbracoUi.userGroup.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + expect(await umbracoApi.userGroup.doesUserGroupContainGranularPermissionsForDocument(userGroupName, documentId, [allPermissions.verbPermission[0]])).toBeTruthy(); + + // Clean + await umbracoApi.document.ensureNameNotExists(documentTypeName); +}); + +test('can add all granular permissions to a specific document for a user group', async ({umbracoApi, umbracoUi}) => { + // Arrange + const documentTypeName = 'TestDocumentType'; + const documentName = 'TestDocument'; + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + const documentTypeId = await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(documentTypeName); + const documentId = await umbracoApi.document.createDefaultDocument(documentName, documentTypeId); + await umbracoApi.userGroup.createEmptyUserGroup(userGroupName); + await umbracoUi.userGroup.clickUserGroupsButton(); + await umbracoUi.userGroup.clickUserGroupWithName(userGroupName); + + // Act + await umbracoUi.userGroup.clickAddGranularPermission(); + await umbracoUi.userGroup.clickLabelWithName(documentName); + await umbracoUi.userGroup.clickGranularPermissionsByName(allPermissions.uiPermission); + await umbracoUi.userGroup.clickConfirmButton(); + await umbracoUi.userGroup.clickSaveButton(); + + // Assert + await umbracoUi.userGroup.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + await umbracoUi.reloadPage(); + await umbracoUi.userGroup.clickGranularPermissionWithName(documentName); + await umbracoUi.userGroup.doesUserGroupHavePermissionEnabled(allPermissions.uiPermission); + expect(await umbracoApi.userGroup.doesUserGroupContainGranularPermissionsForDocument(userGroupName, documentId, allPermissions.verbPermission)).toBeTruthy(); + + // Clean + await umbracoApi.document.ensureNameNotExists(documentTypeName); +}); + +test('can remove granular permission to a specific document for a user group', async ({umbracoApi, umbracoUi}) => { + // Arrange + const documentTypeName = 'TestDocumentType'; + const documentName = 'TestDocument'; + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + const documentTypeId = await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(documentTypeName); + const documentId = await umbracoApi.document.createDefaultDocument(documentName, documentTypeId); + await umbracoApi.userGroup.createUserGroupWithPermissionsForSpecificDocumentWithBrowseNode(userGroupName, documentId); + expect(await umbracoApi.userGroup.doesUserGroupContainGranularPermissionsForDocument(userGroupName, documentId, [allPermissions.verbPermission[0]])).toBeTruthy(); + await umbracoUi.userGroup.clickUserGroupsButton(); + await umbracoUi.userGroup.clickUserGroupWithName(userGroupName); + + // Act + await umbracoUi.userGroup.clickRemoveGranularPermissionWithName(documentName); + await umbracoUi.userGroup.clickSaveButton(); + + // Assert + await umbracoUi.userGroup.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + expect(await umbracoApi.userGroup.doesUserGroupContainGranularPermissionsForDocument(userGroupName, documentId, [allPermissions.verbPermission[0]])).toBeFalsy(); + + // Clean + await umbracoApi.document.ensureNameNotExists(documentTypeName); +}); diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/auth.setup.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/auth.setup.ts index 93c8c20c43..3ab590503d 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/auth.setup.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/auth.setup.ts @@ -6,7 +6,7 @@ setup('authenticate', async ({page}) => { const umbracoUi = new UiHelpers(page); await umbracoUi.goToBackOffice(); - await page.waitForTimeout(10000); + await page.waitForTimeout(5000); await umbracoUi.login.enterEmail(process.env.UMBRACO_USER_LOGIN); await umbracoUi.login.enterPassword(process.env.UMBRACO_USER_PASSWORD); await umbracoUi.login.clickLoginButton();