Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions tests/Umbraco.Tests.AcceptanceTest/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tests/Umbraco.Tests.AcceptanceTest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"testSqlite": "npx playwright test DefaultConfig --grep-invert \"Users\"",
"all": "npx playwright test",
"createTest": "node createTest.js",
"smokeTest": "npx playwright test DefaultConfig --grep \"@smoke\"",
"smokeTest": "npx playwright test DefaultConfig/Content/PublishWithDescendants",
"smokeTestSqlite": "npx playwright test DefaultConfig --grep \"@smoke\" --grep-invert \"Users\""
},
"devDependencies": {
Expand All @@ -21,7 +21,7 @@
},
"dependencies": {
"@umbraco/json-models-builders": "^2.0.33",
"@umbraco/playwright-testhelpers": "^16.0.9",
"@umbraco/playwright-testhelpers": "^16.0.10",
"camelize": "^1.0.0",
"dotenv": "^16.3.1",
"node-fetch": "^2.6.7"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers';
import {expect} from "@playwright/test";

let documentTypeId = '';
let childDocumentTypeId = '';
let contentId = '';
let dataTypeId = '';
const contentName = 'TestContent';
const childContentName = 'ChildContent';
const documentTypeName = 'DocumentTypeForContent';
const childDocumentTypeName = 'ChildDocumentType';
const dataTypeName = 'Textstring';
const contentText = 'This is test content text';
const defaultLanguage = 'English (United States)';
const danishLanguage = 'Danish';

test.beforeEach(async ({umbracoApi}) => {
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
await umbracoApi.document.ensureNameNotExists(contentName);
await umbracoApi.documentType.ensureNameNotExists(childDocumentTypeName);
const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
dataTypeId = dataTypeData.id;
await umbracoApi.language.ensureIsoCodeNotExists('da');
await umbracoApi.language.createDanishLanguage();
});

test.afterEach(async ({umbracoApi}) => {
await umbracoApi.language.ensureIsoCodeNotExists('da');
await umbracoApi.document.ensureNameNotExists(contentName);
await umbracoApi.documentType.ensureNameNotExists(childDocumentTypeName);
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
});

test('can publish invariant content with descendants', async ({umbracoApi, umbracoUi}) => {
Comment thread
nhudinh0309 marked this conversation as resolved.
Outdated
// Arrange
childDocumentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(childDocumentTypeName, dataTypeName, dataTypeId);
documentTypeId = await umbracoApi.documentType.createDocumentTypeWithAllowedChildNodeAndDataType(documentTypeName, childDocumentTypeId, dataTypeName, dataTypeId);
contentId = await umbracoApi.document.createDocumentWithTextContent(contentName, documentTypeId, contentText, dataTypeName);
await umbracoApi.document.createDefaultDocumentWithParent(childContentName, childDocumentTypeId, contentId);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);

// Act
await umbracoUi.content.goToContentWithName(contentName);
await umbracoUi.content.clickViewMoreOptionsButton();
await umbracoUi.content.clickPublishWithDescendantsButton();
// verify variant language
Comment thread
nhudinh0309 marked this conversation as resolved.
Outdated
await umbracoUi.content.doesDocumentVariantLanguageItemHaveCount(1);
await umbracoUi.content.doesDocumentVariantLanguageItemHaveName(defaultLanguage);
await umbracoUi.content.clickPublishWithDescendantsModalButton();

// Assert
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.publishWithDescendants);
await umbracoUi.content.isErrorNotificationVisible(false);
const contentData = await umbracoApi.document.getByName(contentName);
expect(contentData.variants[0].state).toBe('Published');
expect(contentData.values[0].value).toBe(contentText);
const childContentData = await umbracoApi.document.getByName(childContentName);
expect(childContentData.variants[0].state).toBe('Draft');
});

test('can publish invariant content with descendants and include unpublished content items.', async ({umbracoApi, umbracoUi}) => {
Comment thread
nhudinh0309 marked this conversation as resolved.
Outdated
// Arrange
childDocumentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(childDocumentTypeName, dataTypeName, dataTypeId);
documentTypeId = await umbracoApi.documentType.createDocumentTypeWithAllowedChildNodeAndDataType(documentTypeName, childDocumentTypeId, dataTypeName, dataTypeId);
contentId = await umbracoApi.document.createDocumentWithTextContent(contentName, documentTypeId, contentText, dataTypeName);
await umbracoApi.document.createDefaultDocumentWithParent(childContentName, childDocumentTypeId, contentId);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);

// Act
await umbracoUi.content.goToContentWithName(contentName);
await umbracoUi.content.clickViewMoreOptionsButton();
await umbracoUi.content.clickPublishWithDescendantsButton();
// verify variant language
Comment thread
nhudinh0309 marked this conversation as resolved.
Outdated
await umbracoUi.content.doesDocumentVariantLanguageItemHaveCount(1);
await umbracoUi.content.doesDocumentVariantLanguageItemHaveName(defaultLanguage);
await umbracoUi.content.clickIncludeUnpublishedDescendantsToggle();
await umbracoUi.content.clickPublishWithDescendantsModalButton();

// Assert
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.publishWithDescendants);
await umbracoUi.content.isErrorNotificationVisible(false);
const contentData = await umbracoApi.document.getByName(contentName);
expect(contentData.variants[0].state).toBe('Published');
expect(contentData.values[0].value).toBe(contentText);
const childContentData = await umbracoApi.document.getByName(childContentName);
expect(childContentData.variants[0].state).toBe('Published');
});

test('can cancel to publish invariant content with descendants', async ({umbracoApi, umbracoUi}) => {
// Arrange
childDocumentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(childDocumentTypeName, dataTypeName, dataTypeId);
documentTypeId = await umbracoApi.documentType.createDocumentTypeWithAllowedChildNodeAndDataType(documentTypeName, childDocumentTypeId, dataTypeName, dataTypeId);
contentId = await umbracoApi.document.createDocumentWithTextContent(contentName, documentTypeId, contentText, dataTypeName);
await umbracoApi.document.createDefaultDocumentWithParent(childContentName, childDocumentTypeId, contentId);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);

// Act
await umbracoUi.content.goToContentWithName(contentName);
await umbracoUi.content.clickViewMoreOptionsButton();
await umbracoUi.content.clickPublishWithDescendantsButton();
// verify variant language
Comment thread
nhudinh0309 marked this conversation as resolved.
Outdated
await umbracoUi.content.doesDocumentVariantLanguageItemHaveCount(1);
await umbracoUi.content.doesDocumentVariantLanguageItemHaveName(defaultLanguage);
await umbracoUi.content.clickCloseButton();

// Assert
await umbracoUi.content.isErrorNotificationVisible(false);
const contentData = await umbracoApi.document.getByName(contentName);
expect(contentData.variants[0].state).toBe('Draft');
expect(contentData.values[0].value).toBe(contentText);
const childContentData = await umbracoApi.document.getByName(childContentName);
expect(childContentData.variants[0].state).toBe('Draft');
});

test('can publish variant content with descendants', async ({umbracoApi, umbracoUi}) => {
Comment thread
nhudinh0309 marked this conversation as resolved.
Outdated
// Arrange
childDocumentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(childDocumentTypeName, dataTypeName, dataTypeId);
documentTypeId = await umbracoApi.documentType.createVariantDocumentTypeWithAllowedChildNodeAndInvariantPropertyEditor(documentTypeName, childDocumentTypeId, dataTypeName, dataTypeId);
contentId = await umbracoApi.document.createDocumentWithEnglishCultureAndTextContent(contentName, documentTypeId, contentText, dataTypeName);
await umbracoApi.document.createDefaultDocumentWithParent(childContentName, childDocumentTypeId, contentId);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);

// Act
await umbracoUi.content.goToContentWithName(contentName);
await umbracoUi.content.clickViewMoreOptionsButton();
await umbracoUi.content.clickPublishWithDescendantsButton();
// verify variant language
Comment thread
nhudinh0309 marked this conversation as resolved.
Outdated
await umbracoUi.content.doesDocumentVariantLanguageItemHaveCount(2);
await umbracoUi.content.doesDocumentVariantLanguageItemHaveName(defaultLanguage);
await umbracoUi.content.doesDocumentVariantLanguageItemHaveName(danishLanguage);
await umbracoUi.content.clickPublishWithDescendantsModalButton();

// Assert
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.publishWithDescendants);
await umbracoUi.content.isErrorNotificationVisible(false);
const contentData = await umbracoApi.document.getByName(contentName);
expect(contentData.variants[0].state).toBe('Published');
expect(contentData.values[0].value).toBe(contentText);
const childContentData = await umbracoApi.document.getByName(childContentName);
expect(childContentData.variants[0].state).toBe('Draft');
});

test('can publish variant content with descendants and include unpublished content items.', async ({umbracoApi, umbracoUi}) => {
Comment thread
nhudinh0309 marked this conversation as resolved.
Outdated
// Arrange
childDocumentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(childDocumentTypeName, dataTypeName, dataTypeId);
documentTypeId = await umbracoApi.documentType.createVariantDocumentTypeWithAllowedChildNodeAndInvariantPropertyEditor(documentTypeName, childDocumentTypeId, dataTypeName, dataTypeId);
contentId = await umbracoApi.document.createDocumentWithEnglishCultureAndTextContent(contentName, documentTypeId, contentText, dataTypeName);
await umbracoApi.document.createDefaultDocumentWithParent(childContentName, childDocumentTypeId, contentId);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);

// Act
await umbracoUi.content.goToContentWithName(contentName);
await umbracoUi.content.clickViewMoreOptionsButton();
await umbracoUi.content.clickPublishWithDescendantsButton();
// verify variant language
Comment thread
nhudinh0309 marked this conversation as resolved.
Outdated
await umbracoUi.content.doesDocumentVariantLanguageItemHaveCount(2);
await umbracoUi.content.doesDocumentVariantLanguageItemHaveName(defaultLanguage);
await umbracoUi.content.doesDocumentVariantLanguageItemHaveName(danishLanguage);
await umbracoUi.content.clickIncludeUnpublishedDescendantsToggle();
await umbracoUi.content.clickPublishWithDescendantsModalButton();

// Assert
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.publishWithDescendants);
await umbracoUi.content.isErrorNotificationVisible(false);
const contentData = await umbracoApi.document.getByName(contentName);
expect(contentData.variants[0].state).toBe('Published');
expect(contentData.values[0].value).toBe(contentText);
const childContentData = await umbracoApi.document.getByName(childContentName);
expect(childContentData.variants[0].state).toBe('Published');
});

test('can cancel to publish variant content with descendants', async ({umbracoApi, umbracoUi}) => {
// Arrange
childDocumentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(childDocumentTypeName, dataTypeName, dataTypeId);
documentTypeId = await umbracoApi.documentType.createVariantDocumentTypeWithAllowedChildNodeAndInvariantPropertyEditor(documentTypeName, childDocumentTypeId, dataTypeName, dataTypeId);
contentId = await umbracoApi.document.createDocumentWithEnglishCultureAndTextContent(contentName, documentTypeId, contentText, dataTypeName);
await umbracoApi.document.createDefaultDocumentWithParent(childContentName, childDocumentTypeId, contentId);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);

// Act
await umbracoUi.content.goToContentWithName(contentName);
await umbracoUi.content.clickViewMoreOptionsButton();
await umbracoUi.content.clickPublishWithDescendantsButton();
// verify variant language
Comment thread
nhudinh0309 marked this conversation as resolved.
Outdated
await umbracoUi.content.doesDocumentVariantLanguageItemHaveCount(2);
await umbracoUi.content.doesDocumentVariantLanguageItemHaveName(defaultLanguage);
await umbracoUi.content.doesDocumentVariantLanguageItemHaveName(danishLanguage);
await umbracoUi.content.clickCloseButton();

// Assert
await umbracoUi.content.isErrorNotificationVisible(false);
const contentData = await umbracoApi.document.getByName(contentName);
expect(contentData.variants[0].state).toBe('Draft');
expect(contentData.values[0].value).toBe(contentText);
const childContentData = await umbracoApi.document.getByName(childContentName);
expect(childContentData.variants[0].state).toBe('Draft');
});

Check warning on line 203 in tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/PublishWithDescendants.spec.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Code Duplication

The module contains 6 functions with similar structure: 'can cancel to publish invariant content with descendants','can cancel to publish variant content with descendants','can publish invariant content with descendants and include unpublished content items.','can publish invariant content with descendants' and 2 more functions. Avoid duplicated, aka copy-pasted, code inside the module. More duplication lowers the code health.
Loading