* Removed this as these tests are covered in other files * Added release tags * Make all tests with @smoke and @release tags run in the pipeline * Updated npx command * Updated npx command * Updated npx command * Fixed failed tests related to document type folder * Cleaned up * Used grep in yaml file instead of package.json file * Updated yml file * Updated testCommand * Fixed command * Added releaseTest command * Added another job to run regression test in the release build * Fixed comments * Updated name of test job * Make all release tests run in the pipeline * Updated warning message * Reverted npm command
112 lines
5.1 KiB
TypeScript
112 lines
5.1 KiB
TypeScript
import {ConstantHelper, test, AliasHelper} from '@umbraco/playwright-testhelpers';
|
|
import {expect} from "@playwright/test";
|
|
|
|
const contentName = 'TestContent';
|
|
const documentTypeName = 'TestDocumentTypeForContent';
|
|
const dataTypeName = 'Upload Article';
|
|
const uploadFilePath = './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 article 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.clickCreateActionMenuOption();
|
|
await umbracoUi.content.chooseDocumentType(documentTypeName);
|
|
await umbracoUi.content.enterContentName(contentName);
|
|
await umbracoUi.content.clickSaveButton();
|
|
|
|
// Assert
|
|
await umbracoUi.content.waitForContentToBeCreated();
|
|
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 article 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.isSuccessStateVisibleForSaveAndPublishButton();
|
|
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([]);
|
|
});
|
|
|
|
const uploadFiles = [
|
|
{fileExtension: 'pdf', fileName: 'Article.pdf'},
|
|
{fileExtension: 'docx', fileName: 'ArticleDOCX.docx'},
|
|
{fileExtension: 'doc', fileName: 'ArticleDOC.doc'}
|
|
];
|
|
for (const uploadFile of uploadFiles) {
|
|
test(`can upload an article with the ${uploadFile.fileExtension} extension in the content`, {tag: '@release'}, async ({umbracoApi, umbracoUi}) => {
|
|
// Arrange
|
|
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(uploadFilePath + uploadFile.fileName);
|
|
await umbracoUi.content.clickSaveButton();
|
|
|
|
// Assert
|
|
await umbracoUi.content.isSuccessStateVisibleForSaveButton();
|
|
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(uploadFile.fileName));
|
|
});
|
|
}
|
|
|
|
test('can remove an article file in the content', async ({umbracoApi, umbracoUi}) => {
|
|
// Arrange
|
|
const uploadFileName = 'Article.pdf';
|
|
const mimeType = 'application/pdf';
|
|
const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
|
|
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id);
|
|
await umbracoApi.document.createDocumentWithUploadFile(contentName, documentTypeId, dataTypeName, uploadFileName, mimeType);
|
|
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.isSuccessStateVisibleForSaveButton();
|
|
expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy();
|
|
const contentData = await umbracoApi.document.getByName(contentName);
|
|
expect(contentData.values).toEqual([]);
|
|
});
|