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

Open
wants to merge 18 commits into
base: v14/dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
9 changes: 4 additions & 5 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.

4 changes: 2 additions & 2 deletions 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 Defaultconfig/Media"
},
"devDependencies": {
"@playwright/test": "^1.43",
Expand All @@ -19,7 +19,7 @@
},
"dependencies": {
"@umbraco/json-models-builders": "^2.0.20",
"@umbraco/playwright-testhelpers": "^2.0.0-beta.84",
"@umbraco/playwright-testhelpers": "^2.0.0-beta.85",
"camelize": "^1.0.0",
"dotenv": "^16.3.1",
"node-fetch": "^2.6.7"
Expand Down
Original file line number Diff line number Diff line change
@@ -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([]);
});

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 in the content section','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 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();
});
Loading
Loading