* Fixed the function name due to test helper changes * Updated assertion steps due to UI changes * Added more waits * Bumped version * Increase timeout * Reverted --------- Co-authored-by: Andreas Zerbst <73799582+andr317c@users.noreply.github.com>
107 lines
5.0 KiB
TypeScript
107 lines
5.0 KiB
TypeScript
import {ConstantHelper, test, AliasHelper} from '@umbraco/playwright-testhelpers';
|
|
import {expect} from "@playwright/test";
|
|
|
|
const contentName = 'TestContent';
|
|
const documentTypeName = 'TestDocumentTypeForContent';
|
|
const dataTypeName = 'Upload Vector Graphics';
|
|
const uploadVectorGraphicsPath = './fixtures/mediaLibrary/';
|
|
|
|
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 upload vector graphics 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 upload vector graphics 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 upload a file with the svg extension in the content`, async ({umbracoApi, umbracoUi}) => {
|
|
// Arrange
|
|
const vectorGraphicsName = 'VectorGraphics.svg';
|
|
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.uploadFile(uploadVectorGraphicsPath + vectorGraphicsName);
|
|
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(dataTypeName));
|
|
expect(contentData.values[0].value.src).toContain(AliasHelper.toAlias(vectorGraphicsName));
|
|
await umbracoUi.content.doesUploadedSvgThumbnailHaveSrc(umbracoApi.baseUrl + contentData.values[0].value.src);
|
|
});
|
|
|
|
test('can remove an svg file in the content', async ({umbracoApi, umbracoUi}) => {
|
|
// Arrange
|
|
const uploadVectorGraphicsName = 'VectorGraphics.svg';
|
|
const mineType = 'image/svg+xml';
|
|
const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
|
|
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id);
|
|
await umbracoApi.document.createDocumentWithUploadFile(contentName, documentTypeId, dataTypeName, uploadVectorGraphicsName, mineType);
|
|
await umbracoUi.goToBackOffice();
|
|
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
|
|
|
|
// Act
|
|
await umbracoUi.content.goToContentWithName(contentName);
|
|
await umbracoUi.content.clickRemoveFilesButton();
|
|
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([]);
|
|
});
|