* Added Content tests with content picker * Removed the test for content picker * Added Content tests with the default content picker * Added more Content tests with Content Picker data type * Added the Content tests with Dropdown * Added Content tests with Image Cropper * Updated upload file method due to test helper changes * Added Content tests with Image Cropper * Added Content tests with Image Cropper data type * Added Content tests with Media Picker data type * Updated Media tests due to ui helper changes * Bumped version of test helper and json builder * Make all Content tests run in pipeline - should remove it before merging * Fixed the name of tests * Updated the tests for Media Picker in Content section * Added the Content tests with Multiple Media Picker * Updated the Content test with Content Picker due to the test helper changes * Bumped version of test helper * Fixed the failing tests for Content * Removed Image Cropper test in this branch * Added more waits * Added smoke tags * Make smoke tests run in the pipeline * Added Content tests for Image Cropper * Added smoke tags to make all Image Cropper tests running in the pipeline * Added Content tests with Member Picker * Added Content tests with Multiple Image Media Picker * Added Content tests with Numeric * Bumped version of test helper * Make all Content tests running in the pipeline * Assert that the content is published * Assert that the content is published * Fixed code conflict * Fixed comment and code conflict * Make all Content tests run in the pipeline * Refactor the Content tests with different data type * Cleaned code * Make the smoke tests run in the pipeline
98 lines
4.7 KiB
TypeScript
98 lines
4.7 KiB
TypeScript
import { ConstantHelper, test, AliasHelper } from '@umbraco/playwright-testhelpers';
|
|
import {expect} from "@playwright/test";
|
|
|
|
const dataTypeName = 'Member Picker';
|
|
const contentName = 'TestContent';
|
|
const memberName = 'TestMemberForContent';
|
|
const documentTypeName = 'TestDocumentTypeForContent';
|
|
const memberTypeName = 'Test Member Type';
|
|
const memberInfo = ['testmember@acceptance.test', 'testmember', '0123456789'];
|
|
let memberId = '';
|
|
|
|
test.beforeEach(async ({umbracoApi, umbracoUi}) => {
|
|
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
|
|
await umbracoApi.document.ensureNameNotExists(contentName);
|
|
await umbracoApi.memberType.ensureNameNotExists(memberTypeName);
|
|
await umbracoApi.member.ensureNameNotExists(memberName);
|
|
const memberTypeId = await umbracoApi.memberType.createDefaultMemberType(memberTypeName);
|
|
memberId = await umbracoApi.member.createDefaultMember(memberName, memberTypeId, memberInfo[0], memberInfo[1], memberInfo[2]);
|
|
await umbracoUi.goToBackOffice();
|
|
});
|
|
|
|
test.afterEach(async ({umbracoApi}) => {
|
|
await umbracoApi.memberType.ensureNameNotExists(memberTypeName);
|
|
await umbracoApi.member.ensureNameNotExists(memberName);
|
|
await umbracoApi.document.ensureNameNotExists(contentName);
|
|
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
|
|
});
|
|
|
|
test('can create content with the member picker data type', {tag: '@smoke'}, 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.clickChooseMemberPickerButton();
|
|
await umbracoUi.content.selectMemberByName(memberName);
|
|
await umbracoUi.content.clickSubmitButton();
|
|
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].alias).toEqual(AliasHelper.toAlias(dataTypeName));
|
|
expect(contentData.values[0].value).toEqual(memberId);
|
|
});
|
|
|
|
test('can publish content with the member picker 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.content.goToSection(ConstantHelper.sections.content);
|
|
|
|
// Act
|
|
await umbracoUi.content.goToContentWithName(contentName);
|
|
await umbracoUi.content.clickChooseMemberPickerButton();
|
|
await umbracoUi.content.selectMemberByName(memberName);
|
|
await umbracoUi.content.clickSubmitButton();
|
|
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].alias).toEqual(AliasHelper.toAlias(dataTypeName));
|
|
expect(contentData.values[0].value).toEqual(memberId);
|
|
});
|
|
|
|
test('can remove a member picker 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.createDocumentWithMemberPicker(contentName, documentTypeId, memberId);
|
|
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
|
|
|
|
// Act
|
|
await umbracoUi.content.goToContentWithName(contentName);
|
|
await umbracoUi.content.removeMemberPickerByName(memberName);
|
|
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([]);
|
|
});
|
|
|