Skip to content

Commit 5d9d94a

Browse files
authored
V16 QA Added acceptance tests for publishing with descendants (#19262)
1 parent a5d3233 commit 5d9d94a

File tree

1 file changed

+203
-0
lines changed

1 file changed

+203
-0
lines changed
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers';
2+
import {expect} from "@playwright/test";
3+
4+
let documentTypeId = '';
5+
let childDocumentTypeId = '';
6+
let contentId = '';
7+
let dataTypeId = '';
8+
const contentName = 'TestContent';
9+
const childContentName = 'ChildContent';
10+
const documentTypeName = 'DocumentTypeForContent';
11+
const childDocumentTypeName = 'ChildDocumentType';
12+
const dataTypeName = 'Textstring';
13+
const contentText = 'This is test content text';
14+
const defaultLanguage = 'English (United States)';
15+
const danishLanguage = 'Danish';
16+
17+
test.beforeEach(async ({umbracoApi}) => {
18+
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
19+
await umbracoApi.document.ensureNameNotExists(contentName);
20+
await umbracoApi.documentType.ensureNameNotExists(childDocumentTypeName);
21+
const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
22+
dataTypeId = dataTypeData.id;
23+
await umbracoApi.language.ensureIsoCodeNotExists('da');
24+
await umbracoApi.language.createDanishLanguage();
25+
});
26+
27+
test.afterEach(async ({umbracoApi}) => {
28+
await umbracoApi.language.ensureIsoCodeNotExists('da');
29+
await umbracoApi.document.ensureNameNotExists(contentName);
30+
await umbracoApi.documentType.ensureNameNotExists(childDocumentTypeName);
31+
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
32+
});
33+
34+
test('can publish invariant content with descendants without unpublished content items', async ({umbracoApi, umbracoUi}) => {
35+
// Arrange
36+
childDocumentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(childDocumentTypeName, dataTypeName, dataTypeId);
37+
documentTypeId = await umbracoApi.documentType.createDocumentTypeWithAllowedChildNodeAndDataType(documentTypeName, childDocumentTypeId, dataTypeName, dataTypeId);
38+
contentId = await umbracoApi.document.createDocumentWithTextContent(contentName, documentTypeId, contentText, dataTypeName);
39+
await umbracoApi.document.createDefaultDocumentWithParent(childContentName, childDocumentTypeId, contentId);
40+
await umbracoUi.goToBackOffice();
41+
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
42+
43+
// Act
44+
await umbracoUi.content.goToContentWithName(contentName);
45+
await umbracoUi.content.clickViewMoreOptionsButton();
46+
await umbracoUi.content.clickPublishWithDescendantsButton();
47+
// Verify variant language
48+
await umbracoUi.content.doesDocumentVariantLanguageItemHaveCount(1);
49+
await umbracoUi.content.doesDocumentVariantLanguageItemHaveName(defaultLanguage);
50+
await umbracoUi.content.clickPublishWithDescendantsModalButton();
51+
52+
// Assert
53+
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.publishWithDescendants);
54+
await umbracoUi.content.isErrorNotificationVisible(false);
55+
const contentData = await umbracoApi.document.getByName(contentName);
56+
expect(contentData.variants[0].state).toBe('Published');
57+
expect(contentData.values[0].value).toBe(contentText);
58+
const childContentData = await umbracoApi.document.getByName(childContentName);
59+
expect(childContentData.variants[0].state).toBe('Draft');
60+
});
61+
62+
test('can publish invariant content with descendants and include unpublished content items', async ({umbracoApi, umbracoUi}) => {
63+
// Arrange
64+
childDocumentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(childDocumentTypeName, dataTypeName, dataTypeId);
65+
documentTypeId = await umbracoApi.documentType.createDocumentTypeWithAllowedChildNodeAndDataType(documentTypeName, childDocumentTypeId, dataTypeName, dataTypeId);
66+
contentId = await umbracoApi.document.createDocumentWithTextContent(contentName, documentTypeId, contentText, dataTypeName);
67+
await umbracoApi.document.createDefaultDocumentWithParent(childContentName, childDocumentTypeId, contentId);
68+
await umbracoUi.goToBackOffice();
69+
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
70+
71+
// Act
72+
await umbracoUi.content.goToContentWithName(contentName);
73+
await umbracoUi.content.clickViewMoreOptionsButton();
74+
await umbracoUi.content.clickPublishWithDescendantsButton();
75+
// Verify variant language
76+
await umbracoUi.content.doesDocumentVariantLanguageItemHaveCount(1);
77+
await umbracoUi.content.doesDocumentVariantLanguageItemHaveName(defaultLanguage);
78+
await umbracoUi.content.clickIncludeUnpublishedDescendantsToggle();
79+
await umbracoUi.content.clickPublishWithDescendantsModalButton();
80+
81+
// Assert
82+
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.publishWithDescendants);
83+
await umbracoUi.content.isErrorNotificationVisible(false);
84+
const contentData = await umbracoApi.document.getByName(contentName);
85+
expect(contentData.variants[0].state).toBe('Published');
86+
expect(contentData.values[0].value).toBe(contentText);
87+
const childContentData = await umbracoApi.document.getByName(childContentName);
88+
expect(childContentData.variants[0].state).toBe('Published');
89+
});
90+
91+
test('can cancel to publish invariant content with descendants', async ({umbracoApi, umbracoUi}) => {
92+
// Arrange
93+
childDocumentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(childDocumentTypeName, dataTypeName, dataTypeId);
94+
documentTypeId = await umbracoApi.documentType.createDocumentTypeWithAllowedChildNodeAndDataType(documentTypeName, childDocumentTypeId, dataTypeName, dataTypeId);
95+
contentId = await umbracoApi.document.createDocumentWithTextContent(contentName, documentTypeId, contentText, dataTypeName);
96+
await umbracoApi.document.createDefaultDocumentWithParent(childContentName, childDocumentTypeId, contentId);
97+
await umbracoUi.goToBackOffice();
98+
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
99+
100+
// Act
101+
await umbracoUi.content.goToContentWithName(contentName);
102+
await umbracoUi.content.clickViewMoreOptionsButton();
103+
await umbracoUi.content.clickPublishWithDescendantsButton();
104+
// Verify variant language
105+
await umbracoUi.content.doesDocumentVariantLanguageItemHaveCount(1);
106+
await umbracoUi.content.doesDocumentVariantLanguageItemHaveName(defaultLanguage);
107+
await umbracoUi.content.clickCloseButton();
108+
109+
// Assert
110+
await umbracoUi.content.isErrorNotificationVisible(false);
111+
const contentData = await umbracoApi.document.getByName(contentName);
112+
expect(contentData.variants[0].state).toBe('Draft');
113+
expect(contentData.values[0].value).toBe(contentText);
114+
const childContentData = await umbracoApi.document.getByName(childContentName);
115+
expect(childContentData.variants[0].state).toBe('Draft');
116+
});
117+
118+
test('can publish variant content with descendants without unpublished content items', async ({umbracoApi, umbracoUi}) => {
119+
// Arrange
120+
childDocumentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(childDocumentTypeName, dataTypeName, dataTypeId);
121+
documentTypeId = await umbracoApi.documentType.createVariantDocumentTypeWithAllowedChildNodeAndInvariantPropertyEditor(documentTypeName, childDocumentTypeId, dataTypeName, dataTypeId);
122+
contentId = await umbracoApi.document.createDocumentWithEnglishCultureAndTextContent(contentName, documentTypeId, contentText, dataTypeName);
123+
await umbracoApi.document.createDefaultDocumentWithParent(childContentName, childDocumentTypeId, contentId);
124+
await umbracoUi.goToBackOffice();
125+
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
126+
127+
// Act
128+
await umbracoUi.content.goToContentWithName(contentName);
129+
await umbracoUi.content.clickViewMoreOptionsButton();
130+
await umbracoUi.content.clickPublishWithDescendantsButton();
131+
// Verify variant language
132+
await umbracoUi.content.doesDocumentVariantLanguageItemHaveCount(2);
133+
await umbracoUi.content.doesDocumentVariantLanguageItemHaveName(defaultLanguage);
134+
await umbracoUi.content.doesDocumentVariantLanguageItemHaveName(danishLanguage);
135+
await umbracoUi.content.clickPublishWithDescendantsModalButton();
136+
137+
// Assert
138+
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.publishWithDescendants);
139+
await umbracoUi.content.isErrorNotificationVisible(false);
140+
const contentData = await umbracoApi.document.getByName(contentName);
141+
expect(contentData.variants[0].state).toBe('Published');
142+
expect(contentData.values[0].value).toBe(contentText);
143+
const childContentData = await umbracoApi.document.getByName(childContentName);
144+
expect(childContentData.variants[0].state).toBe('Draft');
145+
});
146+
147+
test('can publish variant content with descendants and include unpublished content items', async ({umbracoApi, umbracoUi}) => {
148+
// Arrange
149+
childDocumentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(childDocumentTypeName, dataTypeName, dataTypeId);
150+
documentTypeId = await umbracoApi.documentType.createVariantDocumentTypeWithAllowedChildNodeAndInvariantPropertyEditor(documentTypeName, childDocumentTypeId, dataTypeName, dataTypeId);
151+
contentId = await umbracoApi.document.createDocumentWithEnglishCultureAndTextContent(contentName, documentTypeId, contentText, dataTypeName);
152+
await umbracoApi.document.createDefaultDocumentWithParent(childContentName, childDocumentTypeId, contentId);
153+
await umbracoUi.goToBackOffice();
154+
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
155+
156+
// Act
157+
await umbracoUi.content.goToContentWithName(contentName);
158+
await umbracoUi.content.clickViewMoreOptionsButton();
159+
await umbracoUi.content.clickPublishWithDescendantsButton();
160+
// Verify variant language
161+
await umbracoUi.content.doesDocumentVariantLanguageItemHaveCount(2);
162+
await umbracoUi.content.doesDocumentVariantLanguageItemHaveName(defaultLanguage);
163+
await umbracoUi.content.doesDocumentVariantLanguageItemHaveName(danishLanguage);
164+
await umbracoUi.content.clickIncludeUnpublishedDescendantsToggle();
165+
await umbracoUi.content.clickPublishWithDescendantsModalButton();
166+
167+
// Assert
168+
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.publishWithDescendants);
169+
await umbracoUi.content.isErrorNotificationVisible(false);
170+
const contentData = await umbracoApi.document.getByName(contentName);
171+
expect(contentData.variants[0].state).toBe('Published');
172+
expect(contentData.values[0].value).toBe(contentText);
173+
const childContentData = await umbracoApi.document.getByName(childContentName);
174+
expect(childContentData.variants[0].state).toBe('Published');
175+
});
176+
177+
test('can cancel to publish variant content with descendants', async ({umbracoApi, umbracoUi}) => {
178+
// Arrange
179+
childDocumentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(childDocumentTypeName, dataTypeName, dataTypeId);
180+
documentTypeId = await umbracoApi.documentType.createVariantDocumentTypeWithAllowedChildNodeAndInvariantPropertyEditor(documentTypeName, childDocumentTypeId, dataTypeName, dataTypeId);
181+
contentId = await umbracoApi.document.createDocumentWithEnglishCultureAndTextContent(contentName, documentTypeId, contentText, dataTypeName);
182+
await umbracoApi.document.createDefaultDocumentWithParent(childContentName, childDocumentTypeId, contentId);
183+
await umbracoUi.goToBackOffice();
184+
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
185+
186+
// Act
187+
await umbracoUi.content.goToContentWithName(contentName);
188+
await umbracoUi.content.clickViewMoreOptionsButton();
189+
await umbracoUi.content.clickPublishWithDescendantsButton();
190+
// Verify variant language
191+
await umbracoUi.content.doesDocumentVariantLanguageItemHaveCount(2);
192+
await umbracoUi.content.doesDocumentVariantLanguageItemHaveName(defaultLanguage);
193+
await umbracoUi.content.doesDocumentVariantLanguageItemHaveName(danishLanguage);
194+
await umbracoUi.content.clickCloseButton();
195+
196+
// Assert
197+
await umbracoUi.content.isErrorNotificationVisible(false);
198+
const contentData = await umbracoApi.document.getByName(contentName);
199+
expect(contentData.variants[0].state).toBe('Draft');
200+
expect(contentData.values[0].value).toBe(contentText);
201+
const childContentData = await umbracoApi.document.getByName(childContentName);
202+
expect(childContentData.variants[0].state).toBe('Draft');
203+
});

0 commit comments

Comments
 (0)