Skip to content

Commit

Permalink
V14 Added acceptance tests for Data Type - p2 (#15873)
Browse files Browse the repository at this point in the history
* Added tests for Multi URL Picker

* Added tests for Multiple Media Picker

* Added tests for RichTextEditor - not done

* Added tests for Richtext Editor

* Added tests for Content Picker

* Added tests for Tags

* Fixed the tests for Approved Color

* Added tests for Checkbox list

* Fixed tests for DataTypeFolder

* Fixed tests for DatePicker due to api changes

* Added tests for Dropdown

* Fixed tests for ImageCropper due to ui changes

* Added tests for List View

* Added tests for Multiple Media Picker

* Added tests for RichTextEditor

* Added tests for Radiobox

* Added tests for True false

* Added tests for Upload

* Bumped version of test helper

* Bumped version

* Fixed code format

* Removed hard waits

* Updated tests for Template and Partial View - not done

* Added insert section tests

* Used defaultTemplateContent to avoid duplicate code

* Added insert section tests

* Added missing tests for Partial View

* Added missing tests for Scripts

* Added missing tests for Stylesheet

* Added missing tests for Template

* Changed method's name due to test helper changes

* Added skip tests

* Bumped version of test helper

* Reversed waits

* Changed createThreeDotsButton to createButton due to UI changes

* Removed List View - Members tests as the UI changes

* Added more waits

* Removed unnecessary waits

* Added and removed skip tests

* Fixed and added missing tests

* Changed name of test file for Media Picker, Image Media Picker, Multiple Media Picker and Multiple Image Media Picker

* Updated and added missing tests for Data Types

* Bumped version of test helper

* Changed configuration of smokeTest to make all DataType tests run in the pipeline. It should remove before merging

* Added skip for all tests of Numeric as there is no configuration now

* Removed test.describle

* Change syntax of smoke tag

* Removed duplicate code

* Added the tests that avoid the minimum value is greater than the maximum value

* Added the tests that avoid the min height value is greater than the max height value

* Added test for adding available block to RTE

* Remove skip and add more tests

* Added tests for create an empty data type

* Fixed the create data type tests

* Added tests for changing setting a data type

* Updated the test for creating a new data type

* Added skip tests due to UI changes

* Skipped unhappy tests as the front-end is not ready

* Changed the way to create a new stylesheet

* Updated method names due to test helpers changes

* Bumped version of test helper

* Updated expected result

* Updated method name due to UI changes

* Bumped version of test helper

* Bumped version of test helper

* Fixed add start node tests

* Added skip tests

* Updated the expected result

* Fixed add layout tests

* Added more waits

* Add skip tests

* Removed , in the objects and renamed some tests

* Added tests for updating the option

* Fixed naming and removed unnecessary commas

* Update tests/Umbraco.Tests.AcceptanceTest/package.json

Co-authored-by: Andreas Zerbst <73799582+andr317c@users.noreply.github.com>

---------

Co-authored-by: Andreas Zerbst <andr317c@live.dk>
Co-authored-by: Andreas Zerbst <73799582+andr317c@users.noreply.github.com>
  • Loading branch information
3 people authored Jun 6, 2024
1 parent ebf7702 commit 71199b3
Show file tree
Hide file tree
Showing 20 changed files with 1,448 additions and 198 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import {expect} from "@playwright/test";

const dataTypeName = 'Approved Color';
let dataTypeDefaultData = null;
let dataTypeData = null;
const colorValue = '#ffffff';
const colorLabel = 'TestColor';
let dataTypeData = null;
const colorValue = 'ffffff';
const colorLabel = '';

test.beforeEach(async ({umbracoUi, umbracoApi}) => {
await umbracoUi.goToBackOffice();
Expand Down Expand Up @@ -42,8 +42,7 @@ test('can include label', async ({umbracoApi, umbracoUi}) => {
expect(dataTypeData.values).toEqual(expectedDataTypeValues);
});

//TODO: Remove skip when the frontend is ready
test.skip('can add color', async ({umbracoApi, umbracoUi}) => {
test('can add color', async ({umbracoApi, umbracoUi}) => {
// Arrange
const expectedDataTypeValues = [
{
Expand All @@ -63,16 +62,15 @@ test.skip('can add color', async ({umbracoApi, umbracoUi}) => {
await umbracoUi.dataType.goToDataType(dataTypeName);

// Act
await umbracoUi.dataType.addColor(colorValue, colorLabel);
await umbracoUi.dataType.addColor(colorValue);
await umbracoUi.dataType.clickSaveButton();

// Assert
dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
expect(dataTypeData.values).toEqual(expectedDataTypeValues);
});

// TODO: remove .skip when the frontend is able to display the added color. Currently the added colors are not displayed after reloading page
test.skip('can remove color', async ({umbracoApi, umbracoUi}) => {
test('can remove color', async ({umbracoApi, umbracoUi}) => {
// Arrange
const removedDataTypeValues = [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import {test} from '@umbraco/playwright-testhelpers';
import {expect} from "@playwright/test";

const dataTypeName = 'Checkbox list';
let dataTypeDefaultData = null;
let dataTypeData = null;

test.beforeEach(async ({umbracoUi, umbracoApi}) => {
await umbracoUi.goToBackOffice();
await umbracoUi.dataType.goToSettingsTreeItem('Data Types');
dataTypeDefaultData = await umbracoApi.dataType.getByName(dataTypeName);
});

test.afterEach(async ({umbracoApi}) => {
if (dataTypeDefaultData !== null) {
await umbracoApi.dataType.update(dataTypeDefaultData.id, dataTypeDefaultData);
}
});

test('can add option', async ({umbracoApi, umbracoUi}) => {
// Arrange
const optionName = 'Test option';
const expectedDataTypeValues = [
{
"alias": "items",
"value": [optionName]
}
];
// Remove all existing options
dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
dataTypeData.values = [];
await umbracoApi.dataType.update(dataTypeData.id, dataTypeData);
await umbracoUi.dataType.goToDataType(dataTypeName);

// Act
await umbracoUi.dataType.clickAddOptionButton();
await umbracoUi.dataType.enterOptionName(optionName);
await umbracoUi.dataType.clickSaveButton();

// Assert
dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
expect(dataTypeData.values).toEqual(expectedDataTypeValues);
});

test('can remove option', async ({umbracoApi, umbracoUi}) => {
// Arrange
const removedOptionName = 'Removed Option';
const removedOptionValues = [
{
"alias": "items",
"value": [removedOptionName]
}
];
// Remove all existing options and add an option to remove
dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
dataTypeData.values = removedOptionValues;
await umbracoApi.dataType.update(dataTypeData.id, dataTypeData);
await umbracoUi.dataType.goToDataType(dataTypeName);

// Act
await umbracoUi.dataType.removeOptionByName(removedOptionName);
await umbracoUi.dataType.clickSaveButton();

// Assert
dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
expect(dataTypeData.values).toEqual([]);
});

test('can update option', async ({umbracoApi, umbracoUi}) => {
// Arrange
const optionName = 'Test option';
const updatedOptionName = 'Updated option';
const optionValues = [
{
"alias": "items",
"value": [optionName]
}
];
const expectedOptionValues = [
{
"alias": "items",
"value": [updatedOptionName]
}
];
// Remove all existing options and add an option to update
dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
dataTypeData.values = optionValues;
await umbracoApi.dataType.update(dataTypeData.id, dataTypeData);
await umbracoUi.dataType.goToDataType(dataTypeName);

// Act
await umbracoUi.dataType.enterOptionName(updatedOptionName);
await umbracoUi.dataType.clickSaveButton();

// Assert
dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
expect(dataTypeData.values).toEqual(expectedOptionValues);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import {test} from '@umbraco/playwright-testhelpers';
import {expect} from "@playwright/test";

const dataTypeName = 'Content Picker';
let dataTypeDefaultData = null;
let dataTypeData = null;

test.beforeEach(async ({umbracoUi, umbracoApi}) => {
await umbracoUi.goToBackOffice();
await umbracoUi.dataType.goToSettingsTreeItem('Data Types');
dataTypeDefaultData = await umbracoApi.dataType.getByName(dataTypeName);
});

test.afterEach(async ({umbracoApi}) => {
if (dataTypeDefaultData !== null) {
await umbracoApi.dataType.update(dataTypeDefaultData.id, dataTypeDefaultData);
}
});

test('can show open button', async ({umbracoApi, umbracoUi}) => {
// Arrange
const expectedDataTypeValues = {
"alias": "showOpenButton",
"value": true
};
await umbracoUi.dataType.goToDataType(dataTypeName);

// Act
await umbracoUi.dataType.clickShowOpenButtonSlider();
await umbracoUi.dataType.clickSaveButton();

// Assert
dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
expect(dataTypeData.values).toContainEqual(expectedDataTypeValues);
});

test('can ignore user start nodes', async ({umbracoApi, umbracoUi}) => {
// Arrange
const expectedDataTypeValues = {
"alias": "ignoreUserStartNodes",
"value": true
};
await umbracoUi.dataType.goToDataType(dataTypeName);

// Act
await umbracoUi.dataType.clickIgnoreUserStartNodesSlider();
await umbracoUi.dataType.clickSaveButton();

// Assert
dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
expect(dataTypeData.values).toContainEqual(expectedDataTypeValues);
});

test('can add start node', async ({umbracoApi, umbracoUi}) => {
// Arrange
// Create content
const documentTypeName = 'TestDocumentType';
const contentName = 'TestStartNode';
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
const documentTypeId = await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(documentTypeName);
await umbracoApi.document.ensureNameNotExists(contentName);
const contentId = await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
expect(await umbracoApi.document.doesExist(contentId)).toBeTruthy();

const expectedDataTypeValues = {
"alias": "startNodeId",
"value": contentId
};
await umbracoUi.dataType.goToDataType(dataTypeName);

// Act
await umbracoUi.dataType.clickChooseButton();
await umbracoUi.dataType.addContentStartNode(contentName);
await umbracoUi.dataType.clickSaveButton();

// Assert
dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
expect(dataTypeData.values).toContainEqual(expectedDataTypeValues);

// Clean
await umbracoApi.document.ensureNameNotExists(contentName);
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
});

test('can remove start node', async ({umbracoApi, umbracoUi}) => {
// Arrange
// Create content
const documentTypeName = 'TestDocumentType';
const contentName = 'TestStartNode';
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
const documentTypeId = await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(documentTypeName);
await umbracoApi.document.ensureNameNotExists(contentName);
const contentId = await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
expect(await umbracoApi.document.doesExist(contentId)).toBeTruthy();

const expectedDataTypeValues = {
"alias": "startNodeId",
"value": ""
}
const removedDataTypeValues = [{
"alias": "startNodeId",
"value": contentId
}];

// Remove all existing values and add a start node to remove
dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
dataTypeData.values = removedDataTypeValues;
await umbracoApi.dataType.update(dataTypeData.id, dataTypeData);
await umbracoUi.dataType.goToDataType(dataTypeName);

// Act
await umbracoUi.dataType.removeContentStartNode(contentName);
await umbracoUi.dataType.clickSaveButton();

// Assert
dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
expect(dataTypeData.values).toContainEqual(expectedDataTypeValues);

// Clean
await umbracoApi.document.ensureNameNotExists(contentName);
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import {expect} from "@playwright/test";

const dataTypeName = 'TestDataType';
const editorAlias = 'Umbraco.DateTime';
const editorAlias = 'Umbraco.ColorPicker';
const propertyEditorName = 'Color Picker';

test.beforeEach(async ({umbracoApi, umbracoUi}) => {
await umbracoApi.dataType.ensureNameNotExists(dataTypeName);
Expand All @@ -20,14 +21,16 @@ test('can create a data type', {tag: '@smoke'}, async ({umbracoApi, umbracoUi})
await umbracoUi.dataType.clickCreateButton();
await umbracoUi.dataType.clickNewDataTypeThreeDotsButton();
await umbracoUi.dataType.enterDataTypeName(dataTypeName);
await umbracoUi.dataType.clickSelectAPropertyEditorButton();
await umbracoUi.dataType.selectAPropertyEditor(propertyEditorName);
await umbracoUi.dataType.clickSaveButton();

// Assert
await umbracoUi.dataType.isSuccessNotificationVisible();
expect(await umbracoApi.dataType.doesNameExist(dataTypeName)).toBeTruthy();
});

test('can update a data type name', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => {
test('can rename a data type', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => {
// Arrange
const wrongDataTypeName = 'Wrong Data Type';
await umbracoApi.dataType.ensureNameNotExists(wrongDataTypeName);
Expand All @@ -44,7 +47,7 @@ test('can update a data type name', {tag: '@smoke'}, async ({umbracoApi, umbraco
expect(await umbracoApi.dataType.doesNameExist(wrongDataTypeName)).toBeFalsy();
});

test.skip('can delete a data type', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => {
test('can delete a data type', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => {
// Arrange
await umbracoApi.dataType.create(dataTypeName, editorAlias, []);
expect(await umbracoApi.dataType.doesNameExist(dataTypeName)).toBeTruthy();
Expand All @@ -58,7 +61,7 @@ test.skip('can delete a data type', {tag: '@smoke'}, async ({umbracoApi, umbraco
expect(await umbracoApi.dataType.doesNameExist(dataTypeName)).toBeFalsy();
});

test.skip('can change Property Editor in a data type', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => {
test('can change property editor in a data type', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => {
// Arrange
const updatedEditorName = 'Text Area';
const updatedEditorAlias = 'Umbraco.TextArea';
Expand All @@ -70,7 +73,7 @@ test.skip('can change Property Editor in a data type', {tag: '@smoke'}, async ({
// Act
await umbracoUi.dataType.goToDataType(dataTypeName);
await umbracoUi.dataType.clickChangeButton();
await umbracoUi.dataType.selectPropertyEditorUIByName(updatedEditorName);
await umbracoUi.dataType.selectAPropertyEditor(updatedEditorName);
await umbracoUi.dataType.clickSaveButton();

// Assert
Expand All @@ -79,3 +82,36 @@ test.skip('can change Property Editor in a data type', {tag: '@smoke'}, async ({
expect(dataTypeData.editorAlias).toBe(updatedEditorAlias);
expect(dataTypeData.editorUiAlias).toBe(updatedEditorUiAlias);
});

test('cannot create a data type without selecting the property editor', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => {
// Act
await umbracoUi.dataType.clickActionsMenuAtRoot();
await umbracoUi.dataType.clickCreateButton();
await umbracoUi.dataType.clickNewDataTypeThreeDotsButton();
await umbracoUi.dataType.enterDataTypeName(dataTypeName);
await umbracoUi.dataType.clickSaveButton();

// Assert
await umbracoUi.dataType.isFailedStateButtonVisible();
expect(await umbracoApi.dataType.doesNameExist(dataTypeName)).toBeFalsy();
});

test('can change settings', {tag: '@smoke'}, async ({umbracoApi, umbracoUi}) => {
// Arrange
const expectedDataTypeValues = {
alias: "useLabel",
value: true
};
await umbracoApi.dataType.create(dataTypeName, editorAlias, []);
expect(await umbracoApi.dataType.doesNameExist(dataTypeName)).toBeTruthy();

// Act
await umbracoUi.dataType.goToDataType(dataTypeName);
await umbracoUi.dataType.clickIncludeLabelsSlider();
await umbracoUi.dataType.clickSaveButton();

// Assert
await umbracoUi.dataType.isSuccessNotificationVisible();
const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
expect(dataTypeData.values).toContainEqual(expectedDataTypeValues);
});
Loading

0 comments on commit 71199b3

Please sign in to comment.