Skip to content

Commit 516d62a

Browse files
authored
V15 Added acceptance tests for the mandatory property editor in a content or a block (#18920)
* Added tests for mandatory checkboxlist in a content * Added tests for mandatory dropdown in a content * Added tests for mandatory media picker in a content * Added tests for mandatory radiobox in a content * Added tests for block grid with mandatory property editors * Added tests for block list with mandatory property editors * Bumped version * Cleaned up * Changed npm command * Fixed comments * Fixed comments * Reverted
1 parent ff30b4f commit 516d62a

File tree

7 files changed

+453
-108
lines changed

7 files changed

+453
-108
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers';
2+
3+
// Content Name
4+
const contentName = 'ContentName';
5+
6+
// Document Type
7+
const documentTypeName = 'DocumentTypeName';
8+
let documentTypeId = null;
9+
const documentTypeGroupName = 'DocumentGroup';
10+
11+
// Block Grid
12+
const blockGridName = 'BlockGridName';
13+
let blockGridId = null;
14+
15+
// Element Type
16+
const blockName = 'BlockName';
17+
let elementTypeId = null;
18+
const elementGroupName = 'ElementGroup';
19+
20+
// Property Editor
21+
const propertyEditorName = 'ProperyEditorInBlockName';
22+
let propertyEditorId = null;
23+
const optionValues = ['testOption1', 'testOption2'];
24+
25+
test.afterEach(async ({umbracoApi}) => {
26+
await umbracoApi.document.ensureNameNotExists(contentName);
27+
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
28+
await umbracoApi.documentType.ensureNameNotExists(blockName);
29+
await umbracoApi.dataType.ensureNameNotExists(blockGridName);
30+
});
31+
32+
test('can not publish a block grid with a mandatory radiobox without a value', async ({umbracoApi, umbracoUi}) => {
33+
// Arrange
34+
propertyEditorId = await umbracoApi.dataType.createRadioboxDataType(propertyEditorName, optionValues);
35+
elementTypeId = await umbracoApi.documentType.createDefaultElementType(blockName, elementGroupName, propertyEditorName, propertyEditorId, true);
36+
blockGridId = await umbracoApi.dataType.createBlockGridWithABlockAndAllowAtRoot(blockGridName, elementTypeId, true);
37+
documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, blockGridName, blockGridId, documentTypeGroupName);
38+
await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
39+
40+
await umbracoUi.goToBackOffice();
41+
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
42+
await umbracoUi.content.goToContentWithName(contentName);
43+
44+
// Act
45+
await umbracoUi.content.clickAddBlockElementButton();
46+
await umbracoUi.content.clickBlockElementWithName(blockName);
47+
// Do not select any radiobox values and the validation error appears
48+
await umbracoUi.content.clickCreateModalButton();
49+
await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue);
50+
// Select a radiobox value and the validation error disappears
51+
await umbracoUi.content.chooseRadioboxOption(optionValues[0]);
52+
await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue, false);
53+
await umbracoUi.content.clickCreateModalButton();
54+
await umbracoUi.content.clickSaveAndPublishButton();
55+
56+
// Assert
57+
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved);
58+
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.published);
59+
});
60+
61+
test('can not publish a block grid with a mandatory checkbox list without a value', async ({umbracoApi, umbracoUi}) => {
62+
// Arrange
63+
propertyEditorId = await umbracoApi.dataType.createCheckboxListDataType(propertyEditorName, optionValues);
64+
elementTypeId = await umbracoApi.documentType.createDefaultElementType(blockName, elementGroupName, propertyEditorName, propertyEditorId, true);
65+
blockGridId = await umbracoApi.dataType.createBlockGridWithABlockAndAllowAtRoot(blockGridName, elementTypeId, true);
66+
documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, blockGridName, blockGridId, documentTypeGroupName);
67+
await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
68+
69+
await umbracoUi.goToBackOffice();
70+
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
71+
await umbracoUi.content.goToContentWithName(contentName);
72+
73+
// Act
74+
await umbracoUi.content.clickAddBlockElementButton();
75+
await umbracoUi.content.clickBlockElementWithName(blockName);
76+
// Do not select any checkbox list values and the validation error appears
77+
await umbracoUi.content.clickCreateModalButton();
78+
await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue);
79+
// Select a checkbox list value and the validation error disappears
80+
await umbracoUi.content.chooseCheckboxListOption(optionValues[0]);
81+
await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue, false);
82+
await umbracoUi.content.clickCreateModalButton();
83+
await umbracoUi.content.clickSaveAndPublishButton();
84+
85+
// Assert
86+
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved);
87+
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.published);
88+
});
89+
90+
test('can not publish a block grid with a mandatory dropdown without a value', async ({umbracoApi, umbracoUi}) => {
91+
// Arrange
92+
propertyEditorId = await umbracoApi.dataType.createDropdownDataType(propertyEditorName, false, optionValues);
93+
elementTypeId = await umbracoApi.documentType.createDefaultElementType(blockName, elementGroupName, propertyEditorName, propertyEditorId, true);
94+
blockGridId = await umbracoApi.dataType.createBlockGridWithABlockAndAllowAtRoot(blockGridName, elementTypeId, true);
95+
documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, blockGridName, blockGridId, documentTypeGroupName);
96+
await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
97+
98+
await umbracoUi.goToBackOffice();
99+
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
100+
await umbracoUi.content.goToContentWithName(contentName);
101+
102+
// Act
103+
await umbracoUi.content.clickAddBlockElementButton();
104+
await umbracoUi.content.clickBlockElementWithName(blockName);
105+
// Do not select any dropdown values and the validation error appears
106+
await umbracoUi.content.clickCreateModalButton();
107+
await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue);
108+
// Select a dropdown value and the validation error disappears
109+
await umbracoUi.content.chooseDropdownOption([optionValues[0]]);
110+
await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue, false);
111+
await umbracoUi.content.clickCreateModalButton();
112+
await umbracoUi.content.clickSaveAndPublishButton();
113+
114+
// Assert
115+
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved);
116+
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.published);
117+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers';
2+
3+
// Content Name
4+
const contentName = 'ContentName';
5+
6+
// Document Type
7+
const documentTypeName = 'DocumentTypeName';
8+
let documentTypeId = null;
9+
const documentTypeGroupName = 'DocumentGroup';
10+
11+
// Block List
12+
const blockListName = 'BlockListName';
13+
let blockListId = null;
14+
15+
// Element Type
16+
const blockName = 'BlockName';
17+
let elementTypeId = null;
18+
const elementGroupName = 'ElementGroup';
19+
20+
// Property Editor
21+
const propertyEditorName = 'ProperyEditorInBlockName';
22+
let propertyEditorId = null;
23+
const optionValues = ['testOption1', 'testOption2'];
24+
25+
test.afterEach(async ({umbracoApi}) => {
26+
await umbracoApi.document.ensureNameNotExists(contentName);
27+
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
28+
await umbracoApi.documentType.ensureNameNotExists(blockName);
29+
await umbracoApi.dataType.ensureNameNotExists(blockListName);
30+
});
31+
32+
test('can not publish a block list with a mandatory radiobox without a value', async ({umbracoApi, umbracoUi}) => {
33+
// Arrange
34+
propertyEditorId = await umbracoApi.dataType.createRadioboxDataType(propertyEditorName, optionValues);
35+
elementTypeId = await umbracoApi.documentType.createDefaultElementType(blockName, elementGroupName, propertyEditorName, propertyEditorId, true);
36+
blockListId = await umbracoApi.dataType.createBlockListDataTypeWithABlock(blockListName, elementTypeId);
37+
documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, blockListName, blockListId, documentTypeGroupName);
38+
await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
39+
40+
await umbracoUi.goToBackOffice();
41+
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
42+
await umbracoUi.content.goToContentWithName(contentName);
43+
44+
// Act
45+
await umbracoUi.content.clickAddBlockElementButton();
46+
await umbracoUi.content.clickBlockElementWithName(blockName);
47+
// Do not select any radiobox values and the validation error appears
48+
await umbracoUi.content.clickCreateModalButton();
49+
await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue);
50+
// Select a radiobox value and the validation error disappears
51+
await umbracoUi.content.chooseRadioboxOption(optionValues[0]);
52+
await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue, false);
53+
await umbracoUi.content.clickCreateModalButton();
54+
await umbracoUi.content.clickSaveAndPublishButton();
55+
56+
// Assert
57+
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved);
58+
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.published);
59+
});
60+
61+
test('can not publish a block list with a mandatory checkbox list without a value', async ({umbracoApi, umbracoUi}) => {
62+
// Arrange
63+
propertyEditorId = await umbracoApi.dataType.createCheckboxListDataType(propertyEditorName, optionValues);
64+
elementTypeId = await umbracoApi.documentType.createDefaultElementType(blockName, elementGroupName, propertyEditorName, propertyEditorId, true);
65+
blockListId = await umbracoApi.dataType.createBlockListDataTypeWithABlock(blockListName, elementTypeId);
66+
documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, blockListName, blockListId, documentTypeGroupName);
67+
await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
68+
69+
await umbracoUi.goToBackOffice();
70+
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
71+
await umbracoUi.content.goToContentWithName(contentName);
72+
73+
// Act
74+
await umbracoUi.content.clickAddBlockElementButton();
75+
await umbracoUi.content.clickBlockElementWithName(blockName);
76+
// Do not select any checkbox list values and the validation error appears
77+
await umbracoUi.content.clickCreateModalButton();
78+
await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue);
79+
// Select a checkbox list value and the validation error disappears
80+
await umbracoUi.content.chooseCheckboxListOption(optionValues[0]);
81+
await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue, false);
82+
await umbracoUi.content.clickCreateModalButton();
83+
await umbracoUi.content.clickSaveAndPublishButton();
84+
85+
// Assert
86+
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved);
87+
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.published);
88+
});
89+
90+
test('can not publish a block list with a mandatory dropdown without a value', async ({umbracoApi, umbracoUi}) => {
91+
// Arrange
92+
propertyEditorId = await umbracoApi.dataType.createDropdownDataType(propertyEditorName, false, optionValues);
93+
elementTypeId = await umbracoApi.documentType.createDefaultElementType(blockName, elementGroupName, propertyEditorName, propertyEditorId, true);
94+
blockListId = await umbracoApi.dataType.createBlockListDataTypeWithABlock(blockListName, elementTypeId);
95+
documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, blockListName, blockListId, documentTypeGroupName);
96+
await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
97+
98+
await umbracoUi.goToBackOffice();
99+
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
100+
await umbracoUi.content.goToContentWithName(contentName);
101+
102+
// Act
103+
await umbracoUi.content.clickAddBlockElementButton();
104+
await umbracoUi.content.clickBlockElementWithName(blockName);
105+
// Do not select any dropdown values and the validation error appears
106+
await umbracoUi.content.clickCreateModalButton();
107+
await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue);
108+
// Select a dropdown value and the validation error disappears
109+
await umbracoUi.content.chooseDropdownOption([optionValues[0]]);
110+
await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue, false);
111+
await umbracoUi.content.clickCreateModalButton();
112+
await umbracoUi.content.clickSaveAndPublishButton();
113+
114+
// Assert
115+
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved);
116+
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.published);
117+
});

tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithCheckboxList.spec.ts

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1-
import {ConstantHelper, test, AliasHelper} from '@umbraco/playwright-testhelpers';
1+
import {ConstantHelper, test, AliasHelper, NotificationConstantHelper} from '@umbraco/playwright-testhelpers';
22
import {expect} from "@playwright/test";
33

44
const contentName = 'TestContent';
55
const documentTypeName = 'TestDocumentTypeForContent';
66
const dataTypeName = 'Checkbox list';
7+
const customDataTypeName = 'CustomCheckboxList';
78

89
test.beforeEach(async ({umbracoApi, umbracoUi}) => {
910
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
1011
await umbracoApi.document.ensureNameNotExists(contentName);
12+
await umbracoApi.dataType.ensureNameNotExists(customDataTypeName);
1113
await umbracoUi.goToBackOffice();
1214
});
1315

1416
test.afterEach(async ({umbracoApi}) => {
1517
await umbracoApi.document.ensureNameNotExists(contentName);
1618
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
19+
await umbracoApi.dataType.ensureNameNotExists(customDataTypeName);
1720
});
1821

1922
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,
3134
await umbracoUi.content.clickSaveButton();
3235

3336
// Assert
34-
await umbracoUi.content.isSuccessNotificationVisible();
37+
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created);
3538
expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy();
3639
const contentData = await umbracoApi.document.getByName(contentName);
3740
expect(contentData.variants[0].state).toBe(expectedState);
@@ -51,16 +54,15 @@ test('can publish content with the checkbox list data type', async ({umbracoApi,
5154
await umbracoUi.content.clickSaveAndPublishButton();
5255

5356
// Assert
54-
await umbracoUi.content.doesSuccessNotificationsHaveCount(2);
55-
expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy();
57+
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved);
58+
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.published);
5659
const contentData = await umbracoApi.document.getByName(contentName);
5760
expect(contentData.variants[0].state).toBe(expectedState);
5861
expect(contentData.values).toEqual([]);
5962
});
6063

6164
test('can create content with the custom checkbox list data type', async ({umbracoApi, umbracoUi}) => {
6265
// Arrange
63-
const customDataTypeName = 'CustomCheckboxList';
6466
const optionValues = ['testOption1', 'testOption2'];
6567
const customDataTypeId = await umbracoApi.dataType.createCheckboxListDataType(customDataTypeName, optionValues);
6668
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
7375
await umbracoUi.content.clickSaveAndPublishButton();
7476

7577
// Assert
76-
await umbracoUi.content.doesSuccessNotificationsHaveCount(2);
77-
expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy();
78+
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved);
79+
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.published);
7880
const contentData = await umbracoApi.document.getByName(contentName);
7981
expect(contentData.values[0].alias).toEqual(AliasHelper.toAlias(customDataTypeName));
8082
expect(contentData.values[0].value).toEqual([optionValues[0]]);
81-
82-
// Clean
83-
await umbracoApi.dataType.ensureNameNotExists(customDataTypeName);
8483
});
8584

85+
test('can not publish a mandatory checkbox list with an empty value', async ({umbracoApi, umbracoUi}) => {
86+
// Arrange
87+
const optionValues = ['testOption1', 'testOption2'];
88+
const customDataTypeId = await umbracoApi.dataType.createCheckboxListDataType(customDataTypeName, optionValues);
89+
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId, 'Test Group', false, false, true);
90+
await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
91+
await umbracoUi.goToBackOffice();
92+
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
93+
94+
// Act
95+
await umbracoUi.content.goToContentWithName(contentName);
96+
// Do not select any checkbox list values and the validation error appears
97+
await umbracoUi.content.clickSaveAndPublishButton();
98+
await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue);
99+
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved);
100+
await umbracoUi.content.doesErrorNotificationHaveText(NotificationConstantHelper.error.documentCouldNotBePublished);
101+
// Select a checkbox list value and the validation error disappears
102+
await umbracoUi.content.chooseCheckboxListOption(optionValues[0]);
103+
await umbracoUi.content.isValidationMessageVisible(ConstantHelper.validationMessages.emptyValue, false);
104+
await umbracoUi.content.clickSaveAndPublishButton();
105+
106+
// Assert
107+
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved);
108+
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.published);
109+
const contentData = await umbracoApi.document.getByName(contentName);
110+
expect(contentData.values[0].alias).toEqual(AliasHelper.toAlias(customDataTypeName));
111+
expect(contentData.values[0].value).toEqual([optionValues[0]]);
112+
});

0 commit comments

Comments
 (0)