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 Added acceptance tests for the List View Media and custom data type in Content section #17025

Merged
merged 30 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
859acde
Added Content tests with custom data type
nhudinh0309 Aug 30, 2024
fac0d22
Added tests for List View Media data type in Media section
nhudinh0309 Sep 9, 2024
3aa0355
Updated method name due to api helper changes
nhudinh0309 Sep 9, 2024
ebb8a1d
Merge branch 'v14/QA/content-with-custom-data-type-tests' into v14/QA…
nhudinh0309 Sep 9, 2024
079b8cd
Updated the assertion of Content tests with custom data type
nhudinh0309 Sep 9, 2024
46a52f4
Merge branch 'v14/dev' into v14/QA/list-view-media-tests
nhudinh0309 Sep 9, 2024
2df0650
Bumped version of test helper
nhudinh0309 Sep 9, 2024
42f6539
Make all Content tests run in the pipeline
nhudinh0309 Sep 9, 2024
d8f6edd
Skipped test for code editor as it is removed
nhudinh0309 Sep 9, 2024
ce84d02
Merge branch 'v14/dev' into v14/QA/list-view-media-tests
nhudinh0309 Sep 12, 2024
e524050
Fixed comment
nhudinh0309 Sep 17, 2024
49c704c
Merge branch 'v14/dev' into v14/QA/list-view-media-tests
nhudinh0309 Sep 17, 2024
89098ec
Make Media tests running in the pipeline
nhudinh0309 Sep 17, 2024
8d76966
Merge branch 'v14/dev' into v14/QA/list-view-media-tests
nhudinh0309 Sep 18, 2024
7281458
Merge branch 'v14/dev' into v14/QA/list-view-media-tests
nhudinh0309 Sep 25, 2024
7840fbd
Merge branch 'v14/dev' into v14/QA/list-view-media-tests
nhudinh0309 Sep 26, 2024
71625a5
Bumped version
nhudinh0309 Sep 26, 2024
36b98ab
Updated code due to ui helper changes
nhudinh0309 Sep 26, 2024
d9e4cec
Merge branch 'v14/dev' into v14/QA/list-view-media-tests
nhudinh0309 Oct 11, 2024
3096927
Bumped version of test helper
nhudinh0309 Oct 11, 2024
30d3ea0
Merge branch 'v14/dev' into v14/QA/list-view-media-tests
nhudinh0309 Oct 14, 2024
b740b03
Updated tests for bulk trash in the media section
nhudinh0309 Oct 15, 2024
70c1702
Merge branch 'v14/dev' into v14/QA/list-view-media-tests
nhudinh0309 Oct 22, 2024
431cd62
Merge branch 'v14/dev' into v14/QA/list-view-media-tests
nhudinh0309 Oct 23, 2024
e6ef60d
Fixed notification message
nhudinh0309 Oct 23, 2024
3881f2d
Make Content tests and Media tests run in the pipeline
nhudinh0309 Oct 23, 2024
63261f1
Merge branch 'v14/dev' into v14/QA/list-view-media-tests
nhudinh0309 Oct 25, 2024
93b537f
Added more waits
nhudinh0309 Oct 25, 2024
3d8f984
Merge branch 'v14/dev' into v14/QA/list-view-media-tests
nhudinh0309 Oct 28, 2024
4b65223
Reverted
nhudinh0309 Oct 28, 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
2 changes: 1 addition & 1 deletion tests/Umbraco.Tests.AcceptanceTest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"test": "npx playwright test DefaultConfig",
"all": "npx playwright test",
"createTest": "node createTest.js",
"smokeTest": "npx playwright test DefaultConfig --grep \"@smoke\""
"smokeTest": "npx playwright test DefaultConfig/Content"
nhudinh0309 marked this conversation as resolved.
Show resolved Hide resolved
},
"devDependencies": {
"@playwright/test": "^1.43",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,321 @@
import {ConstantHelper, test, AliasHelper} from '@umbraco/playwright-testhelpers';
import {expect} from "@playwright/test";

const contentName = 'TestContent';
const documentTypeName = 'TestDocumentTypeForContent';
let customDataTypeName = '';

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

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

test('can create content with the custom data type with email address property editor', async ({umbracoApi, umbracoUi}) => {
// Arrange
customDataTypeName = 'Email Address';
const customDataTypeId = await umbracoApi.dataType.createEmailAddressDataType(customDataTypeName);
await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId);
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.values).toEqual([]);
});

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

View check run for this annotation

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

❌ New issue: Code Duplication

The module contains 12 functions with similar structure: 'can add code to the markdown editor','can add decimal number to the decimal in the content section','can add javascript code to the code editor in the content section','can add string to the multiple text string in the content section' and 8 more functions. Avoid duplicated, aka copy-pasted, code inside the module. More duplication lowers the code health.

test('can add text to the email address in the content section', async ({umbracoApi, umbracoUi}) => {
// Arrange
customDataTypeName = 'Email Address';
const emailAddress = '[email protected]';
const customDataTypeId = await umbracoApi.dataType.createEmailAddressDataType(customDataTypeName);
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId);
await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);

// Act
await umbracoUi.content.goToContentWithName(contentName);
await umbracoUi.content.enterTextstring(emailAddress);
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].alias).toEqual(AliasHelper.toAlias(customDataTypeName));
expect(contentData.values[0].value).toEqual(emailAddress);
});

test('can create content with the custom data type with decimal property editor', async ({umbracoApi, umbracoUi}) => {
// Arrange
customDataTypeName = 'Decimal';
const customDataTypeId = await umbracoApi.dataType.createDecimalDataType(customDataTypeName);
await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId);
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.values).toEqual([]);
});

test('can add decimal number to the decimal in the content section', async ({umbracoApi, umbracoUi}) => {
// Arrange
customDataTypeName = 'Decimal';
const decmial = 3.9;
nhudinh0309 marked this conversation as resolved.
Show resolved Hide resolved
const customDataTypeId = await umbracoApi.dataType.createDecimalDataType(customDataTypeName);
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId);
await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);

// Act
await umbracoUi.content.goToContentWithName(contentName);
await umbracoUi.content.enterNumeric(decmial);
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].alias).toEqual(AliasHelper.toAlias(customDataTypeName));
expect(contentData.values[0].value).toEqual(decmial);
});

// Skip this test as currently there is no code editor property editor available.
test.skip('can create content with the custom data type with code editor property editor', async ({umbracoApi, umbracoUi}) => {
// Arrange
customDataTypeName = 'Code Editor';
const customDataTypeId = await umbracoApi.dataType.createCodeEditorDataType(customDataTypeName);
await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId);
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.values).toEqual([]);
});

// Skip this test as currently there is no code editor property editor available.
nhudinh0309 marked this conversation as resolved.
Show resolved Hide resolved
test('can add javascript code to the code editor in the content section', async ({umbracoApi, umbracoUi}) => {
// Arrange
customDataTypeName = 'Code Editor';
const javascriptCode = 'const test = \'This is the acceptance test\';';
const customDataTypeId = await umbracoApi.dataType.createCodeEditorDataType(customDataTypeName);
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId);
await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);

// Act
await umbracoUi.content.goToContentWithName(contentName);
await umbracoUi.content.enterCodeEditorValue(javascriptCode);
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].alias).toEqual(AliasHelper.toAlias(customDataTypeName));
expect(contentData.values[0].value).toEqual(javascriptCode);
});

test('can create content with the custom data type with markdown editor property editor', async ({umbracoApi, umbracoUi}) => {
// Arrange
customDataTypeName = 'Markdown Editor';
const customDataTypeId = await umbracoApi.dataType.createMarkdownEditorDataType(customDataTypeName);
await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId);
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.values).toEqual([]);
});

test('can add code to the markdown editor', async ({umbracoApi, umbracoUi}) => {
nhudinh0309 marked this conversation as resolved.
Show resolved Hide resolved
// Arrange
customDataTypeName = 'Markdown Editor';
const inputText = '# This is test heading\r\n> This is test quote';
const customDataTypeId = await umbracoApi.dataType.createMarkdownEditorDataType(customDataTypeName);
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId);
await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);

// Act
await umbracoUi.content.goToContentWithName(contentName);
await umbracoUi.content.enterMarkdownEditorValue(inputText);
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].alias).toEqual(AliasHelper.toAlias(customDataTypeName));
expect(contentData.values[0].value).toEqual(inputText);
});

test('can create content with the custom data type with multiple text string property editor', async ({umbracoApi, umbracoUi}) => {
// Arrange
customDataTypeName = 'Multiple Text String';
const customDataTypeId = await umbracoApi.dataType.createMultipleTextStringDataType(customDataTypeName);
await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId);
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.values).toEqual([]);
});

test('can add string to the multiple text string in the content section', async ({umbracoApi, umbracoUi}) => {
// Arrange
customDataTypeName = 'Multiple Text String';
const multipleTextStringValue = 'Test text string item';
const customDataTypeId = await umbracoApi.dataType.createMultipleTextStringDataType(customDataTypeName);
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId);
await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);

// Act
await umbracoUi.content.goToContentWithName(contentName);
await umbracoUi.content.addMultipleTextStringItem(multipleTextStringValue);
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].alias).toEqual(AliasHelper.toAlias(customDataTypeName));
expect(contentData.values[0].value).toEqual([multipleTextStringValue]);
});

test('can create content with the custom data type with slider property editor', async ({umbracoApi, umbracoUi}) => {
// Arrange
customDataTypeName = 'Slider';
const customDataTypeId = await umbracoApi.dataType.createSliderDataTyper(customDataTypeName);
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId);
await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
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.values).toEqual([]);
});

test('can change slider value in the content section', async ({umbracoApi, umbracoUi}) => {
// Arrange
customDataTypeName = 'Slider';
const sliderValue = 10;
const expectedValue = {
"from": sliderValue,
"to": sliderValue
}
const customDataTypeId = await umbracoApi.dataType.createSliderDataTyper(customDataTypeName);
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId);
await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);

// Act
await umbracoUi.content.goToContentWithName(contentName);
await umbracoUi.content.changeSliderValue(sliderValue.toString());
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].alias).toEqual(AliasHelper.toAlias(customDataTypeName));
expect(contentData.values[0].value).toEqual(expectedValue);
});

test('can save content after changing the property editor of the custom data type', async ({umbracoApi, umbracoUi}) => {
// Arrange
customDataTypeName = 'Custom Text String';
const inputText = 'Test textstring';
const customDataTypeId = await umbracoApi.dataType.createTextstringDataType(customDataTypeName);
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId);
await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);

// Act
// Update the property editor of the custom data type
const customDataTypeData = await umbracoApi.dataType.getByName(customDataTypeName);
customDataTypeData.editorAlias = 'Umbraco.MultipleTextstring';
customDataTypeData.editorUiAlias = 'Umb.PropertyEditorUi.MultipleTextString';
await umbracoApi.dataType.update(customDataTypeId, customDataTypeData);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
await umbracoUi.content.goToContentWithName(contentName);
await umbracoUi.content.addMultipleTextStringItem(inputText);
await umbracoUi.content.clickSaveButton();

// Assert
await umbracoUi.content.isSuccessNotificationVisible();
});



nhudinh0309 marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading