diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/BlockGrid/BlockGridWithPropertyEditor.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/BlockGrid/BlockGridWithPropertyEditor.spec.ts new file mode 100644 index 0000000000..84d82d419e --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/BlockGrid/BlockGridWithPropertyEditor.spec.ts @@ -0,0 +1,117 @@ +import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers'; + +// Content Name +const contentName = 'ContentName'; + +// Document Type +const documentTypeName = 'DocumentTypeName'; +let documentTypeId = null; +const documentTypeGroupName = 'DocumentGroup'; + +// Block Grid +const blockGridName = 'BlockGridName'; +let blockGridId = null; + +// Element Type +const blockName = 'BlockName'; +let elementTypeId = null; +const elementGroupName = 'ElementGroup'; + +// Property Editor +const propertyEditorName = 'ProperyEditorInBlockName'; +let propertyEditorId = null; +const optionValues = ['testOption1', 'testOption2']; + +test.afterEach(async ({umbracoApi}) => { + await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + await umbracoApi.documentType.ensureNameNotExists(blockName); + await umbracoApi.dataType.ensureNameNotExists(blockGridName); +}); + +test('can not publish a block grid with a mandatory radiobox without a value', async ({umbracoApi, umbracoUi}) => { + // Arrange + propertyEditorId = await umbracoApi.dataType.createRadioboxDataType(propertyEditorName, optionValues); + elementTypeId = await umbracoApi.documentType.createDefaultElementType(blockName, elementGroupName, propertyEditorName, propertyEditorId, true); + blockGridId = await umbracoApi.dataType.createBlockGridWithABlockAndAllowAtRoot(blockGridName, elementTypeId, true); + documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, blockGridName, blockGridId, documentTypeGroupName); + await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + await umbracoUi.content.goToContentWithName(contentName); + + // Act + await umbracoUi.content.clickAddBlockElementButton(); + await umbracoUi.content.clickBlockElementWithName(blockName); + // Do not select any radiobox values and the validation error appears + await umbracoUi.content.clickCreateModalButton(); + await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue); + // Select a radiobox value and the validation error disappears + await umbracoUi.content.chooseRadioboxOption(optionValues[0]); + await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue, false); + await umbracoUi.content.clickCreateModalButton(); + await umbracoUi.content.clickSaveAndPublishButton(); + + // Assert + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.published); +}); + +test('can not publish a block grid with a mandatory checkbox list without a value', async ({umbracoApi, umbracoUi}) => { + // Arrange + propertyEditorId = await umbracoApi.dataType.createCheckboxListDataType(propertyEditorName, optionValues); + elementTypeId = await umbracoApi.documentType.createDefaultElementType(blockName, elementGroupName, propertyEditorName, propertyEditorId, true); + blockGridId = await umbracoApi.dataType.createBlockGridWithABlockAndAllowAtRoot(blockGridName, elementTypeId, true); + documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, blockGridName, blockGridId, documentTypeGroupName); + await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + await umbracoUi.content.goToContentWithName(contentName); + + // Act + await umbracoUi.content.clickAddBlockElementButton(); + await umbracoUi.content.clickBlockElementWithName(blockName); + // Do not select any checkbox list values and the validation error appears + await umbracoUi.content.clickCreateModalButton(); + await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue); + // Select a checkbox list value and the validation error disappears + await umbracoUi.content.chooseCheckboxListOption(optionValues[0]); + await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue, false); + await umbracoUi.content.clickCreateModalButton(); + await umbracoUi.content.clickSaveAndPublishButton(); + + // Assert + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.published); +}); + +test('can not publish a block grid with a mandatory dropdown without a value', async ({umbracoApi, umbracoUi}) => { + // Arrange + propertyEditorId = await umbracoApi.dataType.createDropdownDataType(propertyEditorName, false, optionValues); + elementTypeId = await umbracoApi.documentType.createDefaultElementType(blockName, elementGroupName, propertyEditorName, propertyEditorId, true); + blockGridId = await umbracoApi.dataType.createBlockGridWithABlockAndAllowAtRoot(blockGridName, elementTypeId, true); + documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, blockGridName, blockGridId, documentTypeGroupName); + await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + await umbracoUi.content.goToContentWithName(contentName); + + // Act + await umbracoUi.content.clickAddBlockElementButton(); + await umbracoUi.content.clickBlockElementWithName(blockName); + // Do not select any dropdown values and the validation error appears + await umbracoUi.content.clickCreateModalButton(); + await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue); + // Select a dropdown value and the validation error disappears + await umbracoUi.content.chooseDropdownOption([optionValues[0]]); + await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue, false); + await umbracoUi.content.clickCreateModalButton(); + await umbracoUi.content.clickSaveAndPublishButton(); + + // Assert + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.published); +}); \ No newline at end of file diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/BlockList/BlockListWithPropertyEditor.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/BlockList/BlockListWithPropertyEditor.spec.ts new file mode 100644 index 0000000000..5821c00c2d --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/BlockList/BlockListWithPropertyEditor.spec.ts @@ -0,0 +1,117 @@ +import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers'; + +// Content Name +const contentName = 'ContentName'; + +// Document Type +const documentTypeName = 'DocumentTypeName'; +let documentTypeId = null; +const documentTypeGroupName = 'DocumentGroup'; + +// Block List +const blockListName = 'BlockListName'; +let blockListId = null; + +// Element Type +const blockName = 'BlockName'; +let elementTypeId = null; +const elementGroupName = 'ElementGroup'; + +// Property Editor +const propertyEditorName = 'ProperyEditorInBlockName'; +let propertyEditorId = null; +const optionValues = ['testOption1', 'testOption2']; + +test.afterEach(async ({umbracoApi}) => { + await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + await umbracoApi.documentType.ensureNameNotExists(blockName); + await umbracoApi.dataType.ensureNameNotExists(blockListName); +}); + +test('can not publish a block list with a mandatory radiobox without a value', async ({umbracoApi, umbracoUi}) => { + // Arrange + propertyEditorId = await umbracoApi.dataType.createRadioboxDataType(propertyEditorName, optionValues); + elementTypeId = await umbracoApi.documentType.createDefaultElementType(blockName, elementGroupName, propertyEditorName, propertyEditorId, true); + blockListId = await umbracoApi.dataType.createBlockListDataTypeWithABlock(blockListName, elementTypeId); + documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, blockListName, blockListId, documentTypeGroupName); + await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + await umbracoUi.content.goToContentWithName(contentName); + + // Act + await umbracoUi.content.clickAddBlockElementButton(); + await umbracoUi.content.clickBlockElementWithName(blockName); + // Do not select any radiobox values and the validation error appears + await umbracoUi.content.clickCreateModalButton(); + await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue); + // Select a radiobox value and the validation error disappears + await umbracoUi.content.chooseRadioboxOption(optionValues[0]); + await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue, false); + await umbracoUi.content.clickCreateModalButton(); + await umbracoUi.content.clickSaveAndPublishButton(); + + // Assert + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.published); +}); + +test('can not publish a block list with a mandatory checkbox list without a value', async ({umbracoApi, umbracoUi}) => { + // Arrange + propertyEditorId = await umbracoApi.dataType.createCheckboxListDataType(propertyEditorName, optionValues); + elementTypeId = await umbracoApi.documentType.createDefaultElementType(blockName, elementGroupName, propertyEditorName, propertyEditorId, true); + blockListId = await umbracoApi.dataType.createBlockListDataTypeWithABlock(blockListName, elementTypeId); + documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, blockListName, blockListId, documentTypeGroupName); + await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + await umbracoUi.content.goToContentWithName(contentName); + + // Act + await umbracoUi.content.clickAddBlockElementButton(); + await umbracoUi.content.clickBlockElementWithName(blockName); + // Do not select any checkbox list values and the validation error appears + await umbracoUi.content.clickCreateModalButton(); + await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue); + // Select a checkbox list value and the validation error disappears + await umbracoUi.content.chooseCheckboxListOption(optionValues[0]); + await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue, false); + await umbracoUi.content.clickCreateModalButton(); + await umbracoUi.content.clickSaveAndPublishButton(); + + // Assert + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.published); +}); + +test('can not publish a block list with a mandatory dropdown without a value', async ({umbracoApi, umbracoUi}) => { + // Arrange + propertyEditorId = await umbracoApi.dataType.createDropdownDataType(propertyEditorName, false, optionValues); + elementTypeId = await umbracoApi.documentType.createDefaultElementType(blockName, elementGroupName, propertyEditorName, propertyEditorId, true); + blockListId = await umbracoApi.dataType.createBlockListDataTypeWithABlock(blockListName, elementTypeId); + documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, blockListName, blockListId, documentTypeGroupName); + await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + await umbracoUi.content.goToContentWithName(contentName); + + // Act + await umbracoUi.content.clickAddBlockElementButton(); + await umbracoUi.content.clickBlockElementWithName(blockName); + // Do not select any dropdown values and the validation error appears + await umbracoUi.content.clickCreateModalButton(); + await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue); + // Select a dropdown value and the validation error disappears + await umbracoUi.content.chooseDropdownOption([optionValues[0]]); + await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue, false); + await umbracoUi.content.clickCreateModalButton(); + await umbracoUi.content.clickSaveAndPublishButton(); + + // Assert + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.published); +}); \ No newline at end of file diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithCheckboxList.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithCheckboxList.spec.ts index 1cfe2a419f..b4760a8c77 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithCheckboxList.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithCheckboxList.spec.ts @@ -1,19 +1,22 @@ -import {ConstantHelper, test, AliasHelper} from '@umbraco/playwright-testhelpers'; +import {ConstantHelper, test, AliasHelper, NotificationConstantHelper} from '@umbraco/playwright-testhelpers'; import {expect} from "@playwright/test"; const contentName = 'TestContent'; const documentTypeName = 'TestDocumentTypeForContent'; const dataTypeName = 'Checkbox list'; +const customDataTypeName = 'CustomCheckboxList'; test.beforeEach(async ({umbracoApi, umbracoUi}) => { await umbracoApi.documentType.ensureNameNotExists(documentTypeName); await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.dataType.ensureNameNotExists(customDataTypeName); await umbracoUi.goToBackOffice(); }); 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 checkbox list data type', async ({umbracoApi, umbracoUi}) => { @@ -31,7 +34,7 @@ test('can create content with the checkbox list data type', async ({umbracoApi, 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); @@ -51,8 +54,8 @@ test('can publish content with the checkbox list data type', async ({umbracoApi, await umbracoUi.content.clickSaveAndPublishButton(); // Assert - await umbracoUi.content.doesSuccessNotificationsHaveCount(2); - expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy(); + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.published); const contentData = await umbracoApi.document.getByName(contentName); expect(contentData.variants[0].state).toBe(expectedState); expect(contentData.values).toEqual([]); @@ -60,7 +63,6 @@ test('can publish content with the checkbox list data type', async ({umbracoApi, test('can create content with the custom checkbox list data type', async ({umbracoApi, umbracoUi}) => { // Arrange - const customDataTypeName = 'CustomCheckboxList'; const optionValues = ['testOption1', 'testOption2']; const customDataTypeId = await umbracoApi.dataType.createCheckboxListDataType(customDataTypeName, optionValues); const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId); @@ -73,13 +75,38 @@ test('can create content with the custom checkbox list data type', async ({umbra await umbracoUi.content.clickSaveAndPublishButton(); // Assert - await umbracoUi.content.doesSuccessNotificationsHaveCount(2); - expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy(); + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.published); const contentData = await umbracoApi.document.getByName(contentName); expect(contentData.values[0].alias).toEqual(AliasHelper.toAlias(customDataTypeName)); expect(contentData.values[0].value).toEqual([optionValues[0]]); - - // Clean - await umbracoApi.dataType.ensureNameNotExists(customDataTypeName); }); +test('can not publish a mandatory checkbox list with an empty value', async ({umbracoApi, umbracoUi}) => { + // Arrange + const optionValues = ['testOption1', 'testOption2']; + const customDataTypeId = await umbracoApi.dataType.createCheckboxListDataType(customDataTypeName, optionValues); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId, 'Test Group', false, false, true); + await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + + // Act + await umbracoUi.content.goToContentWithName(contentName); + // Do not select any checkbox list values and the validation error appears + await umbracoUi.content.clickSaveAndPublishButton(); + await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue); + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + await umbracoUi.content.doesErrorNotificationHaveText(NotificationConstantHelper.error.documentCouldNotBePublished); + // Select a checkbox list value and the validation error disappears + await umbracoUi.content.chooseCheckboxListOption(optionValues[0]); + await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue, false); + await umbracoUi.content.clickSaveAndPublishButton(); + + // Assert + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.published); + const contentData = await umbracoApi.document.getByName(contentName); + expect(contentData.values[0].alias).toEqual(AliasHelper.toAlias(customDataTypeName)); + expect(contentData.values[0].value).toEqual([optionValues[0]]); +}); \ No newline at end of file diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDropdown.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDropdown.spec.ts index 7a4c246b01..98743009d4 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDropdown.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDropdown.spec.ts @@ -1,90 +1,116 @@ -import {ConstantHelper, test, AliasHelper} from '@umbraco/playwright-testhelpers'; +import {ConstantHelper, test, AliasHelper, NotificationConstantHelper} from '@umbraco/playwright-testhelpers'; import {expect} from "@playwright/test"; const contentName = 'TestContent'; const documentTypeName = 'TestDocumentTypeForContent'; - const dataTypeNames = ['Dropdown', 'Dropdown multiple']; +const customDataTypeName = 'CustomDropdown'; + +test.beforeEach(async ({umbracoApi, umbracoUi}) => { + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.dataType.ensureNameNotExists(customDataTypeName); + await umbracoUi.goToBackOffice(); +}); + +test.afterEach(async ({umbracoApi}) => { + await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + await umbracoApi.dataType.ensureNameNotExists(customDataTypeName); +}); + for (const dataTypeName of dataTypeNames) { - test.describe(`${dataTypeName} tests`, () => { - test.beforeEach(async ({umbracoApi, umbracoUi}) => { - await umbracoApi.documentType.ensureNameNotExists(documentTypeName); - await umbracoApi.document.ensureNameNotExists(contentName); - await umbracoUi.goToBackOffice(); - }); - - test.afterEach(async ({umbracoApi}) => { - await umbracoApi.document.ensureNameNotExists(contentName); - await umbracoApi.documentType.ensureNameNotExists(documentTypeName); - }); - - test(`can create content with the ${dataTypeName} data type`, async ({umbracoApi, umbracoUi}) => { - // Arrange - const expectedState = 'Draft'; - const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); - await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id); - await umbracoUi.content.goToSection(ConstantHelper.sections.content); - - // Act - await umbracoUi.content.clickActionsMenuAtRoot(); - await umbracoUi.content.clickCreateButton(); - await umbracoUi.content.chooseDocumentType(documentTypeName); - await umbracoUi.content.enterContentName(contentName); - await umbracoUi.content.clickSaveButton(); - - // Assert - await umbracoUi.content.isSuccessNotificationVisible(); - expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy(); - const contentData = await umbracoApi.document.getByName(contentName); - expect(contentData.variants[0].state).toBe(expectedState); - expect(contentData.values).toEqual([]); - }); - - test(`can publish content with the ${dataTypeName} data type`, async ({umbracoApi, umbracoUi}) => { - // Arrange - const expectedState = 'Published'; - const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); - const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id); - 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(contentData.values).toEqual([]); - }); - - test(`can create content with the custom ${dataTypeName} data type`, async ({umbracoApi, umbracoUi}) => { - // Arrange - const customDataTypeName = 'CustomDropdown'; - const optionValues = ['testOption1', 'testOption2', 'testOption3']; - const selectedOptions = dataTypeName === 'Dropdown' ? [optionValues[0]] : optionValues; - const isMultiple = dataTypeName === 'Dropdown' ? false : true; - const customDataTypeId = await umbracoApi.dataType.createDropdownDataType(customDataTypeName, isMultiple, optionValues); - const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId); - await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); - await umbracoUi.content.goToSection(ConstantHelper.sections.content); - - // Act - await umbracoUi.content.goToContentWithName(contentName); - await umbracoUi.content.chooseDropdownOption(selectedOptions); - await umbracoUi.content.clickSaveAndPublishButton(); - - // Assert - await umbracoUi.content.doesSuccessNotificationsHaveCount(2); - expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy(); - const contentData = await umbracoApi.document.getByName(contentName); - expect(contentData.values[0].alias).toEqual(AliasHelper.toAlias(customDataTypeName)); - expect(contentData.values[0].value).toEqual(selectedOptions); - - // Clean - await umbracoApi.dataType.ensureNameNotExists(customDataTypeName); - }); + test(`can create content with the ${dataTypeName} data type`, async ({umbracoApi, umbracoUi}) => { + // Arrange + const expectedState = 'Draft'; + const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); + await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + + // Act + await umbracoUi.content.clickActionsMenuAtRoot(); + await umbracoUi.content.clickCreateButton(); + await umbracoUi.content.chooseDocumentType(documentTypeName); + await umbracoUi.content.enterContentName(contentName); + await umbracoUi.content.clickSaveButton(); + + // Assert + await umbracoUi.content.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); + expect(contentData.values).toEqual([]); + }); + + test(`can publish content with the ${dataTypeName} data type`, async ({umbracoApi, umbracoUi}) => { + // Arrange + const expectedState = 'Published'; + const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id); + 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.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.published); + const contentData = await umbracoApi.document.getByName(contentName); + expect(contentData.variants[0].state).toBe(expectedState); + expect(contentData.values).toEqual([]); + }); + + test(`can create content with the custom ${dataTypeName} data type`, async ({umbracoApi, umbracoUi}) => { + // Arrange + const optionValues = ['testOption1', 'testOption2', 'testOption3']; + const selectedOptions = dataTypeName === 'Dropdown' ? [optionValues[0]] : optionValues; + const isMultiple = dataTypeName === 'Dropdown' ? false : true; + const customDataTypeId = await umbracoApi.dataType.createDropdownDataType(customDataTypeName, isMultiple, optionValues); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId); + await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + + // Act + await umbracoUi.content.goToContentWithName(contentName); + await umbracoUi.content.chooseDropdownOption(selectedOptions); + await umbracoUi.content.clickSaveAndPublishButton(); + + // Assert + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.published); + const contentData = await umbracoApi.document.getByName(contentName); + expect(contentData.values[0].alias).toEqual(AliasHelper.toAlias(customDataTypeName)); + expect(contentData.values[0].value).toEqual(selectedOptions); }); } + +test('can not publish a mandatory dropdown with an empty value', async ({umbracoApi, umbracoUi}) => { + // Arrange + const optionValues = ['testOption1', 'testOption2', 'testOption3']; + const customDataTypeId = await umbracoApi.dataType.createDropdownDataType(customDataTypeName, false, optionValues); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId, 'Test Group', false, false, true); + await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + + // Act + await umbracoUi.content.goToContentWithName(contentName); + // Do not select any dropdown values and the validation error appears + await umbracoUi.content.clickSaveAndPublishButton(); + await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue); + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + await umbracoUi.content.doesErrorNotificationHaveText(NotificationConstantHelper.error.documentCouldNotBePublished); + // Select a dropdown value and the validation error disappears + await umbracoUi.content.chooseDropdownOption([optionValues[0]]); + await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue, false); + await umbracoUi.content.clickSaveAndPublishButton(); + + // Assert + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.published); + const contentData = await umbracoApi.document.getByName(contentName); + expect(contentData.values[0].alias).toEqual(AliasHelper.toAlias(customDataTypeName)); + expect(contentData.values[0].value).toEqual([optionValues[0]]); +}); \ No newline at end of file diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithMediaPicker.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithMediaPicker.spec.ts index e060a48257..939b94c2f0 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithMediaPicker.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithMediaPicker.spec.ts @@ -1,4 +1,4 @@ -import {ConstantHelper, test, AliasHelper} from '@umbraco/playwright-testhelpers'; +import {ConstantHelper, test, AliasHelper, NotificationConstantHelper} from '@umbraco/playwright-testhelpers'; import {expect} from "@playwright/test"; const dataTypeName = 'Media Picker'; @@ -8,7 +8,7 @@ const mediaFileName = 'TestMediaFileForContent'; const mediaTypeName = 'File'; let mediaFileId = ''; -test.beforeEach(async ({umbracoApi, umbracoUi}) => { +test.beforeEach(async ({umbracoApi}) => { await umbracoApi.documentType.ensureNameNotExists(documentTypeName); await umbracoApi.document.ensureNameNotExists(contentName); await umbracoApi.media.ensureNameNotExists(mediaFileName); @@ -39,7 +39,7 @@ test('can create content with the media picker data type', {tag: '@smoke'}, asyn 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); @@ -68,7 +68,8 @@ test('can publish content with the media picker data type', async ({umbracoApi, await umbracoUi.content.clickSaveAndPublishButton(); // Assert - await umbracoUi.content.doesSuccessNotificationsHaveCount(2); + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + 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); @@ -93,7 +94,7 @@ test('can remove a media picker in the content', async ({umbracoApi, umbracoUi}) await umbracoUi.content.clickSaveButton(); // Assert - await umbracoUi.content.isSuccessNotificationVisible(); + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy(); const contentData = await umbracoApi.document.getByName(contentName); expect(contentData.values).toEqual([]); @@ -128,3 +129,34 @@ test('can limit the media picker in the content by setting the start node', asyn await umbracoApi.dataType.ensureNameNotExists(customDataTypeName); }); +test('can not publish a mandatory media picker with an empty value', async ({umbracoApi, umbracoUi}) => { + // Arrange + const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id, 'Test Group', false, false, true); + await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + + // Act + await umbracoUi.content.goToContentWithName(contentName); + // Do not pick any media and the validation error appears + await umbracoUi.content.clickSaveAndPublishButton(); + await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue); + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + await umbracoUi.content.doesErrorNotificationHaveText(NotificationConstantHelper.error.documentCouldNotBePublished); + // Pick a media value and the validation error disappears + await umbracoUi.content.clickChooseButtonAndSelectMediaWithName(mediaFileName); + await umbracoUi.content.clickChooseModalButton(); + await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue, false); + await umbracoUi.content.clickSaveAndPublishButton(); + + // Assert + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.published); + const contentData = await umbracoApi.document.getByName(contentName); + expect(contentData.values[0].alias).toEqual(AliasHelper.toAlias(dataTypeName)); + expect(contentData.values[0].value[0].mediaKey).toEqual(mediaFileId); + expect(contentData.values[0].value[0].mediaTypeAlias).toEqual(mediaTypeName); + expect(contentData.values[0].value[0].focalPoint).toBeNull(); + expect(contentData.values[0].value[0].crops).toEqual([]); +}); \ No newline at end of file diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithRadiobox.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithRadiobox.spec.ts index 195483125b..19dba0f78f 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithRadiobox.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithRadiobox.spec.ts @@ -1,18 +1,22 @@ -import {ConstantHelper, test, AliasHelper} from '@umbraco/playwright-testhelpers'; +import {ConstantHelper, test, AliasHelper, NotificationConstantHelper} from '@umbraco/playwright-testhelpers'; import {expect} from "@playwright/test"; const contentName = 'TestContent'; const documentTypeName = 'TestDocumentTypeForContent'; const dataTypeName = 'Radiobox'; +const customDataTypeName = 'CustomRadiobox'; +const optionValues = ['testOption1', 'testOption2']; test.beforeEach(async ({umbracoApi}) => { await umbracoApi.documentType.ensureNameNotExists(documentTypeName); await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.dataType.ensureNameNotExists(customDataTypeName); }); 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 radiobox data type', async ({umbracoApi, umbracoUi}) => { @@ -31,7 +35,7 @@ test('can create content with the radiobox data type', async ({umbracoApi, umbra 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); @@ -52,7 +56,8 @@ test('can publish content with the radiobox data type', async ({umbracoApi, umbr await umbracoUi.content.clickSaveAndPublishButton(); // Assert - await umbracoUi.content.doesSuccessNotificationsHaveCount(2); + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + 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); @@ -61,8 +66,6 @@ test('can publish content with the radiobox data type', async ({umbracoApi, umbr test('can create content with the custom radiobox data type', async ({umbracoApi, umbracoUi}) => { // Arrange - const customDataTypeName = 'CustomRadiobox'; - const optionValues = ['testOption1', 'testOption2']; const customDataTypeId = await umbracoApi.dataType.createRadioboxDataType(customDataTypeName, optionValues); const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId); await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); @@ -75,13 +78,37 @@ test('can create content with the custom radiobox data type', async ({umbracoApi await umbracoUi.content.clickSaveButton(); // Assert - await umbracoUi.content.isSuccessNotificationVisible(); + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); 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(optionValues[0]); - - // Clean - await umbracoApi.dataType.ensureNameNotExists(customDataTypeName); }); +test('can not publish mandatory radiobox with an empty value', async ({umbracoApi, umbracoUi}) => { + // Arrange + const customDataTypeId = await umbracoApi.dataType.createRadioboxDataType(customDataTypeName, optionValues); + const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId, 'Test Group', false, false, true); + await umbracoApi.document.createDefaultDocument(contentName, documentTypeId); + await umbracoUi.goToBackOffice(); + await umbracoUi.content.goToSection(ConstantHelper.sections.content); + + // Act + await umbracoUi.content.goToContentWithName(contentName); + // Do not select any radiobox values and the validation error appears + await umbracoUi.content.clickSaveAndPublishButton(); + await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue); + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + await umbracoUi.content.doesErrorNotificationHaveText(NotificationConstantHelper.error.documentCouldNotBePublished); + // Select a radiobox value and the validation error disappears + await umbracoUi.content.chooseRadioboxOption(optionValues[0]); + await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue, false); + await umbracoUi.content.clickSaveAndPublishButton(); + + // Assert + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved); + await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.published); + const contentData = await umbracoApi.document.getByName(contentName); + expect(contentData.values[0].alias).toEqual(AliasHelper.toAlias(customDataTypeName)); + expect(contentData.values[0].value).toEqual(optionValues[0]); +}); \ No newline at end of file diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithTags.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithTags.spec.ts index 33856a5b35..551830489f 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithTags.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithTags.spec.ts @@ -81,5 +81,4 @@ test('can remove a tag 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