V14 Added acceptance tests for the List View Media and custom data type in Content section (#17025)

* Added Content tests with custom data type

* Added tests for List View Media data type in Media section

* Updated method name due to api helper changes

* Updated the assertion of Content tests with custom data type

* Bumped version of test helper

* Make all Content tests run in the pipeline

* Skipped test for code editor as it is removed

* Fixed comment

* Make Media tests running in the pipeline

* Bumped version

* Updated code due to ui helper changes

* Bumped version of test helper

* Updated tests for bulk trash in the media section

* Fixed notification message

* Make Content tests and Media tests run in the pipeline

* Added more waits

* Reverted
This commit is contained in:
Nhu Dinh
2024-10-28 10:53:33 +07:00
committed by GitHub
parent 76fcf19b15
commit 41da2e2cf3
3 changed files with 479 additions and 2 deletions

View File

@@ -0,0 +1,317 @@
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([]);
});
test('can add text to the email address in the content section', async ({umbracoApi, umbracoUi}) => {
// Arrange
customDataTypeName = 'Email Address';
const emailAddress = 'test@acceptance.test';
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 decimal = 3.9;
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(decimal);
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(decimal);
});
// 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([]);
});
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 in the content section', async ({umbracoApi, umbracoUi}) => {
// 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();
});

View File

@@ -0,0 +1,160 @@
import {expect} from '@playwright/test';
import {ConstantHelper, test} from '@umbraco/playwright-testhelpers';
const dataTypeName = 'List View - Media';
let dataTypeDefaultData = null;
const firstMediaFileName = 'FirstMediaFile';
const secondMediaFileName = 'SecondMediaFile';
test.beforeEach(async ({umbracoUi, umbracoApi}) => {
dataTypeDefaultData = await umbracoApi.dataType.getByName(dataTypeName);
await umbracoApi.media.ensureNameNotExists(firstMediaFileName);
await umbracoApi.media.createDefaultMediaFile(firstMediaFileName);
await umbracoApi.media.ensureNameNotExists(secondMediaFileName);
await umbracoApi.media.createDefaultMediaFile(secondMediaFileName);
await umbracoUi.goToBackOffice();
});
test.afterEach(async ({umbracoApi}) => {
if (dataTypeDefaultData !== null) {
await umbracoApi.dataType.update(dataTypeDefaultData.id, dataTypeDefaultData);
}
await umbracoApi.media.ensureNameNotExists(firstMediaFileName);
await umbracoApi.media.ensureNameNotExists(secondMediaFileName);
await umbracoApi.media.emptyRecycleBin();
});
test('can change the the default sort order for the list in the media section', async ({umbracoApi, umbracoUi}) => {
// Arrange
const sortOrder = 'creator';
const expectedMediaValues = await umbracoApi.media.getAllMediaNames(sortOrder);
// Act
await umbracoApi.dataType.updateListViewMediaDataType('orderBy', sortOrder);
await umbracoUi.media.goToSection(ConstantHelper.sections.media);
await umbracoUi.media.changeToListView();
await umbracoUi.waitForTimeout(500);
// Assert
await umbracoUi.media.isMediaListViewVisible();
await umbracoUi.media.doesMediaListNameValuesMatch(expectedMediaValues);
});
test('can change the the order direction for the list in the media section', async ({umbracoApi, umbracoUi}) => {
// Arrange
const expectedMediaValues = await umbracoApi.media.getAllMediaNames('updateDate', 'Ascending');
// Act
await umbracoApi.dataType.updateListViewMediaDataType('orderDirection', 'asc');
await umbracoUi.media.goToSection(ConstantHelper.sections.media);
// Assert
await umbracoUi.media.isMediaGridViewVisible();
await umbracoUi.media.doesMediaGridValuesMatch(expectedMediaValues);
await umbracoUi.media.changeToListView();
await umbracoUi.waitForTimeout(500);
await umbracoUi.media.isMediaListViewVisible();
await umbracoUi.media.doesMediaListNameValuesMatch(expectedMediaValues);
});
test('can add more columns to the list in the media section', async ({umbracoApi, umbracoUi}) => {
// Arrange
const expectedColumns = ['Name', 'Last edited', 'Updated by', 'Size'];
const updatedValue = [
{"alias": "updateDate", "header": "Last edited", "isSystem": true},
{"alias": "creator", "header": "Updated by", "isSystem": true},
{"alias": "umbracoBytes", "header": "Size", "isSystem": 0}
];
// Act
await umbracoApi.dataType.updateListViewMediaDataType('includeProperties', updatedValue);
await umbracoUi.media.goToSection(ConstantHelper.sections.media);
await umbracoUi.media.changeToListView();
await umbracoUi.waitForTimeout(500);
// Assert
await umbracoUi.media.isMediaListViewVisible();
await umbracoUi.media.doesMediaListHeaderValuesMatch(expectedColumns);
});
test('can disable one view in the media section', async ({umbracoApi, umbracoUi}) => {
// Arrange
const updatedValue = [
{
"name": "List",
"collectionView": "Umb.CollectionView.Media.Table",
"icon": "icon-list",
"isSystem": true,
"selected": true
}
];
// Act
await umbracoApi.dataType.updateListViewMediaDataType('layouts', updatedValue);
await umbracoUi.media.goToSection(ConstantHelper.sections.media);
// Assert
await umbracoUi.media.isViewBundleButtonVisible(false);
await umbracoUi.media.isMediaListViewVisible();
await umbracoUi.media.isMediaGridViewVisible(false);
});
test('can allow bulk trash in the media section', async ({umbracoApi, umbracoUi}) => {
// Arrange
const updatedValue = {
"allowBulkPublish": false,
"allowBulkUnpublish": false,
"allowBulkCopy": false,
"allowBulkDelete": true,
"allowBulkMove": false
};
// Act
await umbracoApi.dataType.updateListViewMediaDataType('bulkActionPermissions', updatedValue);
await umbracoUi.media.goToSection(ConstantHelper.sections.media);
await umbracoUi.media.selectMediaByName(firstMediaFileName);
await umbracoUi.media.selectMediaByName(secondMediaFileName);
await umbracoUi.media.clickBulkTrashButton();
await umbracoUi.media.clickConfirmTrashButton();
// Assert
await umbracoUi.media.reloadMediaTree();
expect(await umbracoApi.media.doesNameExist(firstMediaFileName)).toBeFalsy();
expect(await umbracoApi.media.doesNameExist(secondMediaFileName)).toBeFalsy();
expect(await umbracoApi.media.doesMediaItemExistInRecycleBin(firstMediaFileName)).toBeTruthy();
expect(await umbracoApi.media.doesMediaItemExistInRecycleBin(secondMediaFileName)).toBeTruthy();
await umbracoUi.media.isItemVisibleInRecycleBin(firstMediaFileName);
await umbracoUi.media.isItemVisibleInRecycleBin(secondMediaFileName, true, false);
});
test('can allow bulk move in the media section', async ({umbracoApi, umbracoUi}) => {
// Arrange
const mediaFolderName = 'Test Folder Name';
const updatedValue = {
"allowBulkPublish": false,
"allowBulkUnpublish": false,
"allowBulkCopy": false,
"allowBulkDelete": false,
"allowBulkMove": true
};
await umbracoApi.media.ensureNameNotExists(mediaFolderName);
const mediaFolderId = await umbracoApi.media.createDefaultMediaFolder(mediaFolderName);
// Act
await umbracoApi.dataType.updateListViewMediaDataType('bulkActionPermissions', updatedValue);
await umbracoUi.media.goToSection(ConstantHelper.sections.media);
await umbracoUi.media.selectMediaByName(firstMediaFileName);
await umbracoUi.media.selectMediaByName(secondMediaFileName);
await umbracoUi.media.clickBulkMoveToButton();
await umbracoUi.media.clickCaretButtonForName('Media');
await umbracoUi.media.clickModalTextByName(mediaFolderName);
await umbracoUi.media.clickChooseModalButton();
// Assert
await umbracoUi.media.isSuccessNotificationVisible();
expect(await umbracoApi.media.doesMediaItemHaveChildName(mediaFolderId, firstMediaFileName)).toBeTruthy();
expect(await umbracoApi.media.doesMediaItemHaveChildName(mediaFolderId, secondMediaFileName)).toBeTruthy();
// Clean
await umbracoApi.media.ensureNameNotExists(mediaFolderName);
});

View File

@@ -110,7 +110,7 @@ test('can create a folder', async ({umbracoApi, umbracoUi}) => {
await umbracoUi.media.clickSaveButton();
// Assert
await umbracoUi.media.doesSuccessNotificationHaveText(NotificationConstantHelper.success.folderCreated);
await umbracoUi.media.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created);
await umbracoUi.media.isTreeItemVisible(folderName);
expect(await umbracoApi.media.doesNameExist(folderName)).toBeTruthy();
@@ -152,7 +152,7 @@ test('can create a folder in a folder', async ({umbracoApi, umbracoUi}) => {
await umbracoUi.media.clickSaveButton();
// Assert
await umbracoUi.media.doesSuccessNotificationHaveText(NotificationConstantHelper.success.folderCreated);
await umbracoUi.media.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created);
await umbracoUi.media.isTreeItemVisible(parentFolderName);
await umbracoUi.media.clickMediaCaretButtonForName(parentFolderName);
await umbracoUi.media.isTreeItemVisible(folderName);