Skip to content

Commit 2754780

Browse files
authored
V15 QA complex block grid test (#18347)
1 parent b01def0 commit 2754780

File tree

1 file changed

+134
-0
lines changed

1 file changed

+134
-0
lines changed
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
import {expect} from '@playwright/test';
2+
import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers';
3+
4+
// DocumentType
5+
const documentTypeName = 'TestDocumentType';
6+
let documentTypeId = '';
7+
const groupName = 'TestGroup';
8+
9+
// Content
10+
const contentName = 'TestContent';
11+
let contentId = '';
12+
13+
// Property Value
14+
const wrongPropertyValue = 'This is a test with wrong value**';
15+
const correctPropertyValue = 'Test';
16+
17+
// ElementTypes
18+
// TextString Element Type (for Block List)
19+
const textStringElementGroupName = 'TextStringElementGroup';
20+
const textStringElementTypeName = 'TestElementWithTextString';
21+
const textStringElementRegex = '^[a-zA-Z0-9]*$';
22+
let textStringElementTypeId = '';
23+
// Area Element Type (for Block Grid)
24+
const areaElementTypeName = 'TestElementArea';
25+
const areaAlias = 'testArea';
26+
let areaElementTypeId = '';
27+
// Rich Text Editor Element Type (for Block Grid)
28+
const richTextEditorElementGroupName = 'RichTextEditorElementGroup';
29+
const richTextEditorElementTypeName = 'RichTextEditorTestElement';
30+
let richTextEditorElementTypeId = '';
31+
// Block List Element Type
32+
const blockListElementTypeName = 'BlockListElement';
33+
const blockListGroupName = 'BlockListGroup';
34+
let blockListElementTypeId = '';
35+
36+
// DataTypes
37+
const blockGridDataTypeName = 'TestBlockGridEditor';
38+
const blockListDataTypeName = 'TestBlockListEditor';
39+
const textStringElementDataTypeName = 'Textstring';
40+
const richTextDataTypeName = 'Rich Text Editor';
41+
let blockListDataTypeId = '';
42+
let blockGridDataTypeId = '';
43+
44+
test.beforeEach(async ({umbracoApi}) => {
45+
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
46+
await umbracoApi.documentType.ensureNameNotExists(textStringElementTypeName);
47+
await umbracoApi.documentType.ensureNameNotExists(areaElementTypeName);
48+
await umbracoApi.documentType.ensureNameNotExists(richTextEditorElementTypeName);
49+
await umbracoApi.document.ensureNameNotExists(contentName);
50+
await umbracoApi.dataType.ensureNameNotExists(blockListDataTypeName);
51+
await umbracoApi.dataType.ensureNameNotExists(blockGridDataTypeName);
52+
await umbracoApi.dataType.ensureNameNotExists(richTextDataTypeName);
53+
});
54+
55+
test.afterEach(async ({umbracoApi}) => {
56+
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
57+
await umbracoApi.documentType.ensureNameNotExists(textStringElementTypeName);
58+
await umbracoApi.documentType.ensureNameNotExists(areaElementTypeName);
59+
await umbracoApi.documentType.ensureNameNotExists(richTextEditorElementTypeName);
60+
await umbracoApi.documentType.ensureNameNotExists(blockListElementTypeName);
61+
await umbracoApi.document.ensureNameNotExists(contentName);
62+
await umbracoApi.dataType.ensureNameNotExists(blockListDataTypeName);
63+
await umbracoApi.dataType.ensureNameNotExists(blockGridDataTypeName);
64+
await umbracoApi.dataType.ensureNameNotExists(richTextDataTypeName);
65+
});
66+
67+
test('can update property value nested in a block grid area with an RTE with a block list editor', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => {
68+
test.slow();
69+
// Arrange
70+
// ElementType with Textstring And REGEX only accept letters and numbers
71+
const textStringElementDataType = await umbracoApi.dataType.getByName(textStringElementDataTypeName);
72+
textStringElementTypeId = await umbracoApi.documentType.createElementTypeWithRegexValidation(textStringElementTypeName, textStringElementGroupName, textStringElementDataTypeName, textStringElementDataType.id, textStringElementRegex);
73+
// Block List Editor with Textstring
74+
blockListDataTypeId = await umbracoApi.dataType.createBlockListDataTypeWithABlock(blockListDataTypeName, textStringElementTypeId);
75+
// ElementType with Block List Editor
76+
blockListElementTypeId = await umbracoApi.documentType.createDefaultElementType(blockListElementTypeName, blockListGroupName, blockListDataTypeName, blockListDataTypeId);
77+
// Rich Text Editor in an ElementType, with a Block(Element Type), the block contains a Block List Editor
78+
const richTextEditorId = await umbracoApi.dataType.createRichTextEditorWithABlock(richTextDataTypeName, blockListElementTypeId);
79+
richTextEditorElementTypeId = await umbracoApi.documentType.createDefaultElementType(richTextEditorElementTypeName, richTextEditorElementGroupName, richTextDataTypeName, richTextEditorId);
80+
// ElementType Area that is Empty
81+
areaElementTypeId = await umbracoApi.documentType.createEmptyElementType(areaElementTypeName);
82+
// Block Grid with 2 blocks, one with RTE and Inline, and one with areas
83+
blockGridDataTypeId = await umbracoApi.dataType.createBlockGridWithABlockWithInlineEditingModeAndABlockWithAnArea(blockGridDataTypeName, richTextEditorElementTypeId, true, areaElementTypeId, areaAlias);
84+
// Document Type with the following
85+
documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, blockGridDataTypeName, blockGridDataTypeId, groupName);
86+
// Creates Content
87+
contentId = await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
88+
await umbracoUi.goToBackOffice();
89+
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
90+
91+
// Act
92+
await umbracoUi.content.goToContentWithName(contentName);
93+
await umbracoUi.content.clickAddBlockGridElementWithName(areaElementTypeName);
94+
await umbracoUi.content.clickSelectBlockElementWithName(areaElementTypeName);
95+
await umbracoUi.content.clickAddBlockGridElementWithName(richTextEditorElementTypeName);
96+
await umbracoUi.content.clickExactLinkWithName(richTextEditorElementTypeName);
97+
await umbracoUi.content.clickInsertBlockButton();
98+
await umbracoUi.content.clickExactLinkWithName(blockListElementTypeName);
99+
await umbracoUi.content.clickAddBlockGridElementWithName(textStringElementTypeName);
100+
await umbracoUi.content.clickExactLinkWithName(textStringElementTypeName);
101+
// Enter text in the textstring block that won't match regex
102+
await umbracoUi.content.enterPropertyValue(textStringElementDataTypeName, wrongPropertyValue);
103+
await umbracoUi.content.clickCreateButtonForModalWithElementTypeNameAndGroupName(textStringElementTypeName, textStringElementGroupName);
104+
await umbracoUi.content.clickCreateButtonForModalWithElementTypeNameAndGroupName(blockListElementTypeName, blockListGroupName);
105+
await umbracoUi.content.clickCreateButtonForModalWithElementTypeNameAndGroupName(richTextEditorElementTypeName, richTextEditorElementGroupName);
106+
await umbracoUi.content.clickSaveAndPublishButton();
107+
// Checks that the error notification is shown since the textstring block has the wrong value
108+
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved, true, true);
109+
await umbracoUi.content.doesErrorNotificationHaveText(NotificationConstantHelper.error.documentCouldNotBePublished, true, true);
110+
// Updates the textstring block with the correct value
111+
await umbracoUi.waitForTimeout(1000);
112+
await umbracoUi.content.clickBlockElementWithName(blockListElementTypeName);
113+
await umbracoUi.content.clickEditBlockListEntryWithName(textStringElementTypeName);
114+
await umbracoUi.content.enterPropertyValue(textStringElementDataTypeName, correctPropertyValue);
115+
await umbracoUi.content.clickUpdateButtonForModalWithElementTypeNameAndGroupName(textStringElementTypeName, textStringElementGroupName);
116+
await umbracoUi.content.clickUpdateButtonForModalWithElementTypeNameAndGroupName(blockListElementTypeName, blockListGroupName);
117+
await umbracoUi.content.clickSaveAndPublishButton();
118+
119+
// Assert
120+
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved, true, true);
121+
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.published, true, true);
122+
// Checks if published
123+
const contentData = await umbracoApi.document.getByName(contentName);
124+
expect(contentData.variants[0].state).toBe('Published');
125+
// Checks if the textstring block has the correct value after reloading the page
126+
await umbracoUi.reloadPage();
127+
// Waits to make sure the page has loaded
128+
await umbracoUi.waitForTimeout(2000);
129+
await umbracoUi.content.clickBlockElementWithName(blockListElementTypeName);
130+
// Needs to wait to make sure it has loaded
131+
await umbracoUi.waitForTimeout(2000);
132+
await umbracoUi.content.clickEditBlockListEntryWithName(textStringElementTypeName);
133+
await umbracoUi.content.doesPropertyContainValue(textStringElementDataTypeName, correctPropertyValue);
134+
});

0 commit comments

Comments
 (0)