Skip to content

Commit

Permalink
V14 QA Added Content acceptance tests (#16289)
Browse files Browse the repository at this point in the history
* Added api tests for Document - not done

* Added ui tests for Content - not done

* Added api test for Documents

* Added ui tests for Content

* Updated method name due to ui changes

* Bumped version of test helpers and json builders

* Added smoke tag to run all Content tests in the pipeline

* Bumped version of json builder

* Revert files

* Updated the syntax of smoke tag

* Added tests for content with different property editors

* Added tests for Info Tab

* Added more steps for before tests

* Added more tests for Redirect Management

* Added more tests for Content

* Bumped version of test helper

* Changed test name

* Updated the method name due to the test helper changes

* Fixed typo

* Added more waits and skip tests

* Updated the test name

* Changed click action for save button

* Bumped version of test helper

* Bumped version of test helper

* Updated choose document type step after clicking create button due to UI changes

* Added skip tests

* Changed clean method

* Fixed arrange step

* Fixed the arrange steps

* Removed test.describe and unnecessary variables

* Added smoke tests
  • Loading branch information
nhudinh0309 authored May 31, 2024
1 parent d105968 commit d78a063
Show file tree
Hide file tree
Showing 9 changed files with 915 additions and 5 deletions.
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.

2 changes: 1 addition & 1 deletion tests/Umbraco.Tests.AcceptanceTest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"dependencies": {
"@umbraco/json-models-builders": "^2.0.5",
"@umbraco/playwright-testhelpers": "^2.0.0-beta.51",
"@umbraco/playwright-testhelpers": "^2.0.0-beta.54",
"camelize": "^1.0.0",
"dotenv": "^16.3.1",
"faker": "^4.1.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import {test} from '@umbraco/playwright-testhelpers';
import {expect} from "@playwright/test";

test.describe('Documents tests', () => {
let documentTypeId = '';
let documentId = '';
const documentName = 'TestDocument';
const documentTypeName = 'TestDocumentType';

test.beforeEach(async ({umbracoApi}) => {
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
documentTypeId = await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(documentTypeName);
});

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

test('can create a document', async ({umbracoApi}) => {
// Act
await umbracoApi.document.createDefaultDocument(documentName, documentTypeId);

// Assert
expect(await umbracoApi.document.doesNameExist(documentName)).toBeTruthy();
});

test('can delete a document', async ({umbracoApi}) => {
// Arrange
documentId = await umbracoApi.document.createDefaultDocument(documentName, documentTypeId);
expect(umbracoApi.document.doesExist(documentId)).toBeTruthy();

// Act
await umbracoApi.document.delete(documentId);

// Assert
expect(await umbracoApi.document.doesNameExist(documentName)).toBeFalsy();
});

test('can update a document', async ({umbracoApi}) => {
// Arrange
const wrongName = 'WrongDocument';
documentId = await umbracoApi.document.createDefaultDocument(wrongName, documentTypeId);
expect(await umbracoApi.document.doesNameExist(wrongName)).toBeTruthy();
let documentData = await umbracoApi.document.get(documentId);
documentData.variants[0].name = documentName;

// Act
await umbracoApi.document.update(documentData.id, documentData);

// Assert
const updatedDocumentData = await umbracoApi.document.get(documentId);
expect(updatedDocumentData.variants[0].name).toEqual(documentName);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import {ConstantHelper, test} from '@umbraco/playwright-testhelpers';
import {expect} from "@playwright/test";

let documentTypeId = '';
let childDocumentTypeId = '';
let contentId = '';
const contentName = 'TestContent';
const childContentName = 'ChildContent';
const documentTypeName = 'DocumentTypeForContent';
const childDocumentTypeName = 'ChildDocumentTypeForContent';

test.beforeEach(async ({umbracoApi}) => {
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
await umbracoApi.document.ensureNameNotExists(contentName);
await umbracoApi.documentType.ensureNameNotExists(childDocumentTypeName);
});

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

test('can create child node', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => {
// Arrange
childDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentType(childDocumentTypeName);
documentTypeId = await umbracoApi.documentType.createDocumentTypeWithAllowedChildNode(documentTypeName, childDocumentTypeId, true);
contentId = await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);

// Act
await umbracoUi.content.clickActionsMenuForContent(contentName);
await umbracoUi.content.clickCreateButton();
await umbracoUi.content.chooseDocumentType(documentTypeName);
await umbracoUi.content.enterContentName(childContentName);
await umbracoUi.content.clickSaveButton();

// Assert
await umbracoUi.content.isSuccessNotificationVisible();
expect(await umbracoApi.document.doesNameExist(childContentName)).toBeTruthy();
const childData = await umbracoApi.document.getChildren(contentId);
expect(childData[0].variants[0].name).toBe(childContentName);
// verify that the child content displays in the tree after reloading children
await umbracoUi.content.clickActionsMenuForContent(contentName);
await umbracoUi.content.clickReloadButton();
await umbracoUi.content.clickCaretButtonForContentName(contentName);
await umbracoUi.content.doesContentTreeHaveName(childContentName);

// Clean
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}) => {
// Arrange
const childOfChildContentName = 'ChildOfChildContent';
const childOfChildDocumentTypeName = 'ChildOfChildDocumentType';
let childOfChildDocumentTypeId: any;
let childContentId: any;
await umbracoApi.documentType.ensureNameNotExists(childOfChildDocumentTypeName);
childOfChildDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentType(childOfChildDocumentTypeName);
childDocumentTypeId = await umbracoApi.documentType.createDocumentTypeWithAllowedChildNode(childDocumentTypeName, childOfChildDocumentTypeId, true);
documentTypeId = await umbracoApi.documentType.createDocumentTypeWithAllowedChildNode(documentTypeName, childDocumentTypeId, true);
contentId = await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
childContentId = await umbracoApi.document.createDefaultDocumentWithParent(childContentName, childDocumentTypeId, contentId);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);

// Act
await umbracoUi.content.clickCaretButtonForContentName(contentName);
await umbracoUi.content.clickActionsMenuForContent(childContentName);
await umbracoUi.content.clickCreateButton();
await umbracoUi.content.clickLabelWithName(childOfChildDocumentTypeName);
// This wait is needed
await umbracoUi.waitForTimeout(500);
await umbracoUi.content.enterContentName(childOfChildContentName);
await umbracoUi.content.clickSaveButton();

// Assert
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();
await umbracoUi.content.clickCaretButtonForContentName(childContentName);
await umbracoUi.content.doesContentTreeHaveName(childOfChildContentName);

// Clean
await umbracoApi.documentType.ensureNameNotExists(childOfChildDocumentTypeName);
await umbracoApi.document.ensureNameNotExists(childOfChildContentName);
});

test('cannot publish child if the parent is not published', async ({umbracoApi, umbracoUi}) => {
// Arrange
childDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentType(childDocumentTypeName);
documentTypeId = await umbracoApi.documentType.createDocumentTypeWithAllowedChildNode(documentTypeName, childDocumentTypeId, true);
contentId = await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
await umbracoApi.document.createDefaultDocumentWithParent(childContentName, childDocumentTypeId, contentId);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);

// Act
await umbracoUi.content.clickCaretButtonForContentName(contentName);
await umbracoUi.content.clickActionsMenuForContent(childContentName);
await umbracoUi.content.clickPublishButton();

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

test('can publish with descendants', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => {
// Arrange
childDocumentTypeId = await umbracoApi.documentType.createDefaultDocumentType(childDocumentTypeName);
documentTypeId = await umbracoApi.documentType.createDocumentTypeWithAllowedChildNode(documentTypeName, childDocumentTypeId, true);
contentId = await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
await umbracoApi.document.createDefaultDocumentWithParent(childContentName, childDocumentTypeId, contentId);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);

// Act
await umbracoUi.content.clickActionsMenuForContent(contentName);
await umbracoUi.content.clickPublishButton();

// Assert
await umbracoUi.content.isSuccessNotificationVisible();
const contentData = await umbracoApi.document.getByName(contentName);
expect(contentData.variants[0].state).toBe('Published');
const childContentData = await umbracoApi.document.getByName(contentName);
expect(childContentData.variants[0].state).toBe('Published');
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
import {ConstantHelper, test} from '@umbraco/playwright-testhelpers';
import {expect} from "@playwright/test";

let documentTypeId = '';
let contentId = '';
const contentName = 'TestContent';
const documentTypeName = 'TestDocumentTypeForContent';
const dataTypeName = 'Textstring';
const contentText = 'This is test content text';

test.beforeEach(async ({umbracoApi}) => {
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
});

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

test('can create empty content', async ({umbracoApi, umbracoUi}) => {
// Arrange
const expectedState = 'Draft';
await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(documentTypeName);
await umbracoUi.goToBackOffice();
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.clickSaveButton();

// Assert
await umbracoUi.content.isSuccessNotificationVisible();
expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy();
const contentData = await umbracoApi.document.getByName(contentName);
expect(contentData.variants[0].state).toBe(expectedState);
});

test('can save and publish empty content', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => {
// Arrange
const expectedState = 'Published';
await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(documentTypeName);
await umbracoUi.goToBackOffice();
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.clickSaveAndPublishButton();

// Assert
await umbracoUi.content.doesSuccessNotificationsHaveCount(2);
expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy();
const contentData = await umbracoApi.document.getByName(contentName);
expect(contentData.variants[0].state).toBe(expectedState);
});

test('can create content', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => {
// Arrange
const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id);
await umbracoUi.goToBackOffice();
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.enterTextstring(contentText);
await umbracoUi.content.clickSaveButton();

// Assert
await umbracoUi.content.isSuccessNotificationVisible();
expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy();
const contentData = await umbracoApi.document.getByName(contentName);
expect(contentData.values[0].value).toBe(contentText);
});

test('can rename content', async ({umbracoApi, umbracoUi}) => {
// Arrange
const wrongContentName = 'Wrong Content Name';
documentTypeId = await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(documentTypeName);
contentId = await umbracoApi.document.createDefaultDocument(wrongContentName, documentTypeId);
expect(await umbracoApi.document.doesNameExist(wrongContentName)).toBeTruthy();
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);

// Act
await umbracoUi.content.openContent(wrongContentName);
await umbracoUi.content.enterContentName(contentName);
await umbracoUi.content.clickSaveButton();

// Assert
await umbracoUi.content.isSuccessNotificationVisible();
const updatedContentData = await umbracoApi.document.get(contentId);
expect(updatedContentData.variants[0].name).toEqual(contentName);
});

test('can update content', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => {
// Arrange
const wrongContentText = 'This is wrong 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, wrongContentText, dataTypeName);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);

// Act
await umbracoUi.content.openContent(contentName);
await umbracoUi.content.enterTextstring(contentText);
await umbracoUi.content.clickSaveButton();

// Assert
await umbracoUi.content.isSuccessNotificationVisible();
const updatedContentData = await umbracoApi.document.get(contentId);
expect(updatedContentData.variants[0].name).toEqual(contentName);
expect(updatedContentData.values[0].value).toBe(contentText);
});

test('can publish content', async ({umbracoApi, umbracoUi}) => {
// Arrange
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);

// Act
await umbracoUi.content.clickActionsMenuForContent(contentName);
await umbracoUi.content.clickPublishButton();

// Assert
await umbracoUi.content.isSuccessNotificationVisible();
const contentData = await umbracoApi.document.getByName(contentName);
expect(contentData.variants[0].state).toBe('Published');
});

test('can unpublish content', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => {
// Arrange
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);
const publishData = {"publishSchedules":[{"culture":null}]};
await umbracoApi.document.publish(contentId, publishData);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);

// Act
await umbracoUi.content.clickActionsMenuForContent(contentName);
await umbracoUi.content.clickUnpublishButton();
await umbracoUi.content.clickConfirmToUnpublishButton();

// Assert
await umbracoUi.content.isSuccessNotificationVisible();
const contentData = await umbracoApi.document.getByName(contentName);
expect(contentData.variants[0].state).toBe('Draft');
});
Loading

0 comments on commit d78a063

Please sign in to comment.