Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V14 QA Added Content acceptance tests #16289

Merged
merged 41 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
afb1675
Added api tests for Document - not done
nhudinh0309 Feb 28, 2024
7fe8706
Added ui tests for Content - not done
nhudinh0309 Feb 28, 2024
aa96d9a
Added api test for Documents
nhudinh0309 Mar 8, 2024
d94b5d6
Added ui tests for Content
nhudinh0309 Mar 8, 2024
fcf6995
Merge branch 'v14/dev' into v14/QA/content-acceptance-tests
nhudinh0309 Mar 8, 2024
079c662
Merge branch 'v14/dev' into v14/QA/content-acceptance-tests
nhudinh0309 Apr 16, 2024
5b3bfe1
Updated method name due to ui changes
nhudinh0309 May 13, 2024
d18aac3
Merge branch 'v14/dev' into v14/QA/content-acceptance-tests
nhudinh0309 May 15, 2024
56aa3b4
Bumped version of test helpers and json builders
nhudinh0309 May 15, 2024
e5b2d40
Added smoke tag to run all Content tests in the pipeline
nhudinh0309 May 15, 2024
1956fe5
Merge branch 'v14/dev' into v14/QA/content-acceptance-tests
nhudinh0309 May 17, 2024
f6b0388
Bumped version of json builder
nhudinh0309 May 17, 2024
8191619
Merge branch 'v14/dev' into v14/QA/content-acceptance-tests
nhudinh0309 May 20, 2024
1e45429
Revert files
nhudinh0309 May 20, 2024
e5b1c27
Updated the syntax of smoke tag
nhudinh0309 May 23, 2024
660b984
Added tests for content with different property editors
nhudinh0309 May 23, 2024
2339f42
Merge branch 'v14/dev' into v14/QA/content-acceptance-tests
nhudinh0309 May 23, 2024
9a775ef
Added tests for Info Tab
nhudinh0309 May 27, 2024
a865c57
Added more steps for before tests
nhudinh0309 May 27, 2024
689faa2
Added more tests for Redirect Management
nhudinh0309 May 27, 2024
2e22950
Added more tests for Content
nhudinh0309 May 27, 2024
d7a6313
Merge branch 'v14/dev' into v14/QA/content-acceptance-tests
nhudinh0309 May 27, 2024
c17b085
Bumped version of test helper
nhudinh0309 May 27, 2024
6ce5973
Merge branch 'v14/dev' into v14/QA/content-acceptance-tests
nhudinh0309 May 27, 2024
f249232
Merge branch 'v14/dev' into v14/QA/content-acceptance-tests
nhudinh0309 May 28, 2024
9f330c1
Changed test name
nhudinh0309 May 28, 2024
c76f785
Merge branch 'v14/dev' into v14/QA/content-acceptance-tests
nhudinh0309 May 28, 2024
d1deca7
Updated the method name due to the test helper changes
nhudinh0309 May 28, 2024
596c6cc
Fixed typo
nhudinh0309 May 28, 2024
caad29b
Added more waits and skip tests
nhudinh0309 May 28, 2024
cc80b70
Updated the test name
nhudinh0309 May 28, 2024
04b05d1
Changed click action for save button
nhudinh0309 May 28, 2024
1fa13b8
Bumped version of test helper
nhudinh0309 May 28, 2024
e54e0f7
Bumped version of test helper
nhudinh0309 May 29, 2024
2a8af2d
Updated choose document type step after clicking create button due to…
nhudinh0309 May 29, 2024
563200b
Added skip tests
nhudinh0309 May 29, 2024
c5f3e5f
Changed clean method
nhudinh0309 May 30, 2024
984e29f
Fixed arrange step
nhudinh0309 May 30, 2024
3e6d17c
Fixed the arrange steps
nhudinh0309 May 30, 2024
e9dc481
Removed test.describe and unnecessary variables
nhudinh0309 May 30, 2024
ed99096
Added smoke tests
nhudinh0309 May 30, 2024
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.

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,137 @@
import {ConstantHelper, test} from '@umbraco/playwright-testhelpers';
import {expect} from "@playwright/test";

// Remove smoke tag before merging
test.describe('Children content tests', {tag: '@smoke'}, () => {
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', 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);
nhudinh0309 marked this conversation as resolved.
Show resolved Hide resolved

// 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', 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,165 @@
import {ConstantHelper, test} from '@umbraco/playwright-testhelpers';
import {expect} from "@playwright/test";

// Remove smoke tag before merging
test.describe('Content tests', {tag: '@smoke'}, () => {
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);
});

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

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (v14/dev)

❌ New issue: Code Duplication

The module contains 5 functions with similar structure: 'can create content','can create empty content','can publish content','can save and publish empty content' and 1 more functions. Avoid duplicated, aka copy-pasted, code inside the module. More duplication lowers the code health.

test('can save and publish empty content', 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', 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', 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', 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
Loading