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 the Content tests with Radiobox and Tags datatype #16909

Merged
merged 11 commits into from
Aug 19, 2024
Merged
18 changes: 9 additions & 9 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.

6 changes: 3 additions & 3 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"
},
"devDependencies": {
"@playwright/test": "^1.43",
Expand All @@ -21,8 +21,8 @@
"wait-on": "^7.2.0"
},
"dependencies": {
"@umbraco/json-models-builders": "^2.0.14",
"@umbraco/playwright-testhelpers": "^2.0.0-beta.73",
"@umbraco/json-models-builders": "^2.0.15",
"@umbraco/playwright-testhelpers": "^2.0.0-beta.74",
"camelize": "^1.0.0",
"dotenv": "^16.3.1",
"faker": "^4.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,30 +96,6 @@ test.skip('can create content with the upload file datatype', async ({umbracoApi
expect(contentData.values[0].value.src).toContainEqual(uploadFilePath);
});

test('can create content with the tags datatype', async ({umbracoApi, umbracoUi}) => {
// Arrange
const dataTypeName = 'Tags';
const tagName = 'test';
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.addTags(tagName);
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.values[0].value).toEqual([tagName]);
});

// TODO: Remove skip and update the test when the front-end is ready. Currently the list of content is not displayed.
test.skip('can create content with the list view - content datatype', async ({umbracoApi, umbracoUi}) => {
// Arrange
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { ConstantHelper, test, AliasHelper } from '@umbraco/playwright-testhelpers';
import {expect} from "@playwright/test";

const contentName = 'TestContent';
const documentTypeName = 'TestDocumentTypeForContent';
const dataTypeName = 'Radiobox';

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);
});

test('can create content with the radiobox data type', async ({umbracoApi, umbracoUi}) => {
// Arrange
const expectedState = 'Draft';
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.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);
expect(contentData.values).toEqual([]);
});

test('can publish content with the radiobox data type', async ({umbracoApi, umbracoUi}) => {
// Arrange
const expectedState = 'Published';
const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id);
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.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);
expect(contentData.values).toEqual([]);
});

test('can create content with the custom radiobox data type', async ({umbracoApi, umbracoUi}) => {
// Arrange
const customDataTypeName = 'CustomRadiobox';
const optionValues = ['testOption1', 'testOption2'];
const customDataTypeId = await umbracoApi.dataType.createRadioboxDataType(customDataTypeName, optionValues);
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.chooseRadioboxOption(optionValues[0]);
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(optionValues[0]);

// Clean
await umbracoApi.dataType.ensureNameNotExists(customDataTypeName);
});

Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import {ConstantHelper, test} from '@umbraco/playwright-testhelpers';
import {expect} from "@playwright/test";

const contentName = 'TestContent';
const documentTypeName = 'TestDocumentTypeForContent';
const dataTypeName = 'Tags';
const tagsName = ['testTag1', 'testTag2'];

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

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

test('can create content with one tag', async ({umbracoApi, umbracoUi}) => {
// Arrange
const expectedState = 'Draft';
const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id);
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.clickPlusIconButton();
await umbracoUi.content.enterTag(tagsName[0]);
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);
expect(contentData.values[0].value).toEqual([tagsName[0]]);
});

test('can publish content with multiple tags', async ({umbracoApi, umbracoUi}) => {
// Arrange
const expectedState = 'Published';
const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id);
await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
await umbracoUi.content.goToSection(ConstantHelper.sections.content);

// Act
await umbracoUi.content.goToContentWithName(contentName);
await umbracoUi.content.clickPlusIconButton();
await umbracoUi.content.enterTag(tagsName[0]);
await umbracoUi.content.enterTag(tagsName[1]);
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);
expect(contentData.values[0].value).toEqual(tagsName);
});

test('can remove a tag in the content', async ({umbracoApi, umbracoUi}) => {
// Arrange
const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id);
await umbracoApi.document.createDocumentWithTags(contentName, documentTypeId, [tagsName[0]]);
await umbracoUi.content.goToSection(ConstantHelper.sections.content);

// Act
await umbracoUi.content.goToContentWithName(contentName);
await umbracoUi.content.removeTagByName(tagsName[0]);
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([]);
});

Loading