Skip to content

Commit

Permalink
V14 Added Content tests with various data types (#16809)
Browse files Browse the repository at this point in the history
* Added Content tests with content picker

* Removed the test for content picker

* Added Content tests with the default content picker

* Added more Content tests with Content Picker data type

* Added the Content tests with Dropdown

* Added Content tests with Image Cropper

* Updated upload file method due to test helper changes

* Added Content tests with Image Cropper

* Added Content tests with Image Cropper data type

* Added Content tests with Media Picker data type

* Updated Media tests due to ui helper changes

* Bumped version of test helper and json builder

* Make all Content tests run in pipeline - should remove it before merging

* Fixed the name of tests

* Updated the tests for Media Picker in Content section

* Added the Content tests with Multiple Media Picker

* Updated the Content test with Content Picker due to the test helper changes

* Bumped version of test helper

* Fixed the failing tests for Content

* Removed Image Cropper test in this branch

* Added more waits

* Added smoke tags

* Make smoke tests run in the pipeline
  • Loading branch information
nhudinh0309 authored Jul 25, 2024
1 parent b61b71e commit 4f62746
Show file tree
Hide file tree
Showing 11 changed files with 528 additions and 63 deletions.
24 changes: 10 additions & 14 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 @@ -21,8 +21,8 @@
"wait-on": "^7.2.0"
},
"dependencies": {
"@umbraco/json-models-builders": "^2.0.9",
"@umbraco/playwright-testhelpers": "^2.0.0-beta.65",
"@umbraco/json-models-builders": "^2.0.13",
"@umbraco/playwright-testhelpers": "^2.0.0-beta.68",
"camelize": "^1.0.0",
"dotenv": "^16.3.1",
"faker": "^4.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let contentId = '';
const contentName = 'TestContent';
const childContentName = 'ChildContent';
const documentTypeName = 'DocumentTypeForContent';
const childDocumentTypeName = 'ChildDocumentTypeForContent';
const childDocumentTypeName = 'ChildDocumentType';

test.beforeEach(async ({umbracoApi}) => {
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
Expand All @@ -32,7 +32,9 @@ test('can create child node', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) =
// Act
await umbracoUi.content.clickActionsMenuForContent(contentName);
await umbracoUi.content.clickCreateButton();
await umbracoUi.content.chooseDocumentType(documentTypeName);
await umbracoUi.content.chooseDocumentType(childDocumentTypeName);
// This wait is needed
await umbracoUi.waitForTimeout(500);
await umbracoUi.content.enterContentName(childContentName);
await umbracoUi.content.clickSaveButton();

Expand All @@ -51,8 +53,7 @@ test('can create child node', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) =
await umbracoApi.document.ensureNameNotExists(childContentName);
});

// TODO: Remove skip when the front-end is ready.
test.skip('can create child node in child node', async ({umbracoApi, umbracoUi}) => {
test('can create child node in child node', async ({umbracoApi, umbracoUi}) => {
// Arrange
const childOfChildContentName = 'ChildOfChildContent';
const childOfChildDocumentTypeName = 'ChildOfChildDocumentType';
Expand All @@ -71,7 +72,7 @@ test.skip('can create child node in child node', async ({umbracoApi, umbracoUi})
await umbracoUi.content.clickCaretButtonForContentName(contentName);
await umbracoUi.content.clickActionsMenuForContent(childContentName);
await umbracoUi.content.clickCreateButton();
await umbracoUi.content.clickLabelWithName(childOfChildDocumentTypeName);
await umbracoUi.content.chooseDocumentType(childOfChildDocumentTypeName);
// This wait is needed
await umbracoUi.waitForTimeout(500);
await umbracoUi.content.enterContentName(childOfChildContentName);
Expand All @@ -81,9 +82,7 @@ test.skip('can create child node in child node', async ({umbracoApi, umbracoUi})
await umbracoUi.content.isSuccessNotificationVisible();
const childOfChildData = await umbracoApi.document.getChildren(childContentId);
expect(childOfChildData[0].variants[0].name).toBe(childOfChildContentName);
// verify that the child content displays in the tree after reloading children
await umbracoUi.content.clickActionsMenuForContent(contentName);
await umbracoUi.content.clickReloadButton();
// verify that the child content displays in the tree
await umbracoUi.content.clickCaretButtonForContentName(childContentName);
await umbracoUi.content.doesContentTreeHaveName(childOfChildContentName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ test.afterEach(async ({umbracoApi}) => {
test('can see correct information when published', async ({umbracoApi, umbracoUi}) => {
// Arrange
const notPublishContentLink = 'This document is published but is not in the cache';
documentTypeId = await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(documentTypeName);
contentId = await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
const dataTypeName = 'Textstring';
const contentText = 'This is test content text';
const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id);
contentId = await umbracoApi.document.createDocumentWithTextContent(contentName, documentTypeId, contentText, dataTypeName);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);

Expand Down Expand Up @@ -47,8 +50,7 @@ test('can see correct information when published', async ({umbracoApi, umbracoUi
await umbracoUi.content.doesCreatedDateHaveText(expectedCreatedDate);
});

// TODO: Remove skip when the frond-end is ready. Currently the document type is not opened after clicking to the button
test.skip('can open document type', async ({umbracoApi, umbracoUi}) => {
test('can open document type', async ({umbracoApi, umbracoUi}) => {
// Arrange
documentTypeId = await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(documentTypeName);
contentId = await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
Expand All @@ -57,7 +59,6 @@ test.skip('can open document type', async ({umbracoApi, umbracoUi}) => {

// Act
await umbracoUi.content.openContent(contentName);
await umbracoUi.content.clickInfoTab();
await umbracoUi.content.clickDocumentTypeByName(documentTypeName);

// Assert
Expand All @@ -76,7 +77,6 @@ test('can open template', async ({umbracoApi, umbracoUi}) => {

// Act
await umbracoUi.content.openContent(contentName);
await umbracoUi.content.clickInfoTab();
await umbracoUi.content.clickTemplateByName(templateName);

// Assert
Expand All @@ -101,7 +101,6 @@ test('can change template', async ({umbracoApi, umbracoUi}) => {

// Act
await umbracoUi.content.openContent(contentName);
await umbracoUi.content.clickInfoTab();
await umbracoUi.content.changeTemplate(firstTemplateName, secondTemplateName);
await umbracoUi.content.clickSaveButton();

Expand Down Expand Up @@ -129,7 +128,6 @@ test('cannot change to a template that is not allowed in the document type', asy

// Act
await umbracoUi.content.openContent(contentName);
await umbracoUi.content.clickInfoTab();
await umbracoUi.content.clickEditTemplateByName(firstTemplateName);

// Assert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ test('can publish content with the checkbox list data type', async ({umbracoApi,
expect(contentData.values).toEqual([]);
});

test('can create content with the custom approved color data type', async ({umbracoApi, umbracoUi}) => {
test('can create content with the custom checkbox list data type', async ({umbracoApi, umbracoUi}) => {
// Arrange
const customDataTypeName = 'CustomCheckboxList';
const optionValues = ['testOption1', 'testOption2'];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
import {ConstantHelper, test} from '@umbraco/playwright-testhelpers';
import {expect} from "@playwright/test";

const contentName = 'TestContent';
const documentTypeName = 'TestDocumentTypeForContent';
const dataTypeName = 'Content Picker';
const contentPickerDocumentTypeName = 'DocumentTypeForContentPicker';
const contentPickerName = 'TestContentPicker';
let contentPickerDocumentTypeId = '';

test.beforeEach(async ({umbracoApi, umbracoUi}) => {
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
await umbracoApi.document.ensureNameNotExists(contentName);
contentPickerDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(contentPickerDocumentTypeName);
await umbracoUi.goToBackOffice();
});

test.afterEach(async ({umbracoApi}) => {
await umbracoApi.document.ensureNameNotExists(contentPickerName);
await umbracoApi.document.ensureNameNotExists(contentName);
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
await umbracoApi.documentType.ensureNameNotExists(contentPickerDocumentTypeName);
});

test('can create content with the content picker datatype', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => {
// Arrange
const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id);
const contentPickerId = await umbracoApi.document.createDefaultDocument(contentPickerName, contentPickerDocumentTypeId);
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.addContentPicker(contentPickerName);
await umbracoUi.content.clickSaveButton();

// Assert
await umbracoUi.content.doesSuccessNotificationsHaveCount(1);
expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy();
const contentData = await umbracoApi.document.getByName(contentName);
expect(contentData.values[0].value).toEqual(contentPickerId);
});

test('can publish content with the content picker data type', async ({umbracoApi, umbracoUi}) => {
// Arrange
const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id);
const contentPickerId = await umbracoApi.document.createDefaultDocument(contentPickerName, contentPickerDocumentTypeId);
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.addContentPicker(contentPickerName);
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].value).toEqual(contentPickerId);
});

test('can open content picker in the content', async ({umbracoApi, umbracoUi}) => {
// Arrange
const customDataTypeName = 'CustomContentPicker';
const customDataTypeId = await umbracoApi.dataType.createContentPickerDataTypeWithShowOpenButton(customDataTypeName);
await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId);
await umbracoApi.document.createDefaultDocument(contentPickerName, contentPickerDocumentTypeId);
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.addContentPicker(contentPickerName);

// Assert
await umbracoUi.content.isOpenButtonVisibleInContentPicker(contentPickerName);
await umbracoUi.content.clickContentPickerOpenButton(contentPickerName);
await umbracoUi.content.isNodeOpenForContentPicker(contentPickerName);

// Clean
await umbracoApi.dataType.ensureNameNotExists(customDataTypeName);
});

test('can choose start node for the content picker in the content', async ({umbracoApi, umbracoUi}) => {
// Arrange
const customDataTypeName = 'CustomContentPicker';
const childContentPickerDocumentTypeName = 'ChildDocumentTypeForContentPicker';
const childContentPickerName = 'TestChildContentPicker';
await umbracoApi.documentType.ensureNameNotExists(childContentPickerDocumentTypeName);
const childContentPickerDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentType(childContentPickerDocumentTypeName);
const contentPickerDocumentTypeId = await umbracoApi.documentType.createDocumentTypeWithAllowedChildNode(contentPickerName, childContentPickerDocumentTypeId);
const contentPickerId = await umbracoApi.document.createDefaultDocument(contentPickerName, contentPickerDocumentTypeId);
await umbracoApi.document.createDefaultDocumentWithParent(childContentPickerName, childContentPickerDocumentTypeId, contentPickerId);
// Create a custom content picker with start node
const customDataTypeId = await umbracoApi.dataType.createContentPickerDataTypeWithStartNode(customDataTypeName, contentPickerId);
await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId);
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.clickChooseButton();

// Assert
await umbracoUi.content.isContentNameVisible(childContentPickerName);
await umbracoUi.content.isContentNameVisible(contentPickerName, false);

// Clean
await umbracoApi.dataType.ensureNameNotExists(customDataTypeName);
await umbracoApi.document.ensureNameNotExists(childContentPickerName);
});

test.skip('can ignore user start node for the content picker in the content', async ({umbracoApi, umbracoUi}) => {
// Arrange
const customDataTypeName = 'CustomContentPicker';
const childContentPickerDocumentTypeName = 'ChildDocumentTypeForContentPicker';
const childContentPickerName = 'TestChildContentPicker';
await umbracoApi.documentType.ensureNameNotExists(childContentPickerDocumentTypeName);
const childContentPickerDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentType(childContentPickerDocumentTypeName);
const contentPickerDocumentTypeId = await umbracoApi.documentType.createDocumentTypeWithAllowedChildNode(contentPickerName, childContentPickerDocumentTypeId);
const contentPickerId = await umbracoApi.document.createDefaultDocument(contentPickerName, contentPickerDocumentTypeId);
await umbracoApi.document.createDefaultDocumentWithParent(childContentPickerName, childContentPickerDocumentTypeId, contentPickerId);
// Create a custom content picker with the setting "ignore user start node" is enable
const customDataTypeId = await umbracoApi.dataType.createContentPickerDataTypeWithIgnoreUserStartNodes(customDataTypeName, contentPickerId);
await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId);
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.clickChooseButton();

// Assert
await umbracoUi.content.isContentNameVisible(childContentPickerName);
await umbracoUi.content.isContentNameVisible(contentPickerName);

// Clean
await umbracoApi.dataType.ensureNameNotExists(customDataTypeName);
await umbracoApi.document.ensureNameNotExists(childContentPickerName);
});

test('can remove content picker in the content', async ({umbracoApi, umbracoUi}) => {
// Arrange
const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id);
const contentPickerId = await umbracoApi.document.createDefaultDocument(contentPickerName, contentPickerDocumentTypeId);
await umbracoApi.document.createDocumentWithContentPicker(contentName, documentTypeId, contentPickerId);
await umbracoUi.content.goToSection(ConstantHelper.sections.content);

// Act
await umbracoUi.content.openContent(contentName);
await umbracoUi.content.removeContentPicker(contentPickerName);
await umbracoUi.content.clickSaveButton();

// Assert
await umbracoUi.content.isSuccessNotificationVisible();
const contentData = await umbracoApi.document.getByName(contentName);
expect(contentData.values).toEqual([]);
});

Loading

0 comments on commit 4f62746

Please sign in to comment.