Skip to content
Merged
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers';
import {expect} from "@playwright/test";

const testUser = ConstantHelper.testUserCredentials;
let testUserCookieAndToken = {cookie: "", accessToken: "", refreshToken: ""};

let userGroupId = null;

const documentTypeName = 'TestDocumentType';
const documentName = 'TestDocument';
const richTextEditorName = 'TestRichTextEditor';
const stylesheetName = 'TestStylesheet.css';

test.beforeEach(async ({umbracoApi}) => {
await umbracoApi.user.ensureNameNotExists(testUser.name);
await umbracoApi.stylesheet.ensureNameNotExists(stylesheetName);
const stylesheetPath = await umbracoApi.stylesheet.createStylesheetWithHeaderContent(stylesheetName);
const dataTypeId = await umbracoApi.dataType.createRichTextEditorDataTypeWithStylesheet(richTextEditorName, stylesheetPath);
await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, richTextEditorName, dataTypeId);
const userGroup = await umbracoApi.userGroup.getByName('Editors');
userGroupId = userGroup.id;
});

test.afterEach(async ({umbracoApi}) => {
// Ensure we are logged in to admin
await umbracoApi.loginToAdminUser(testUserCookieAndToken.cookie, testUserCookieAndToken.accessToken, testUserCookieAndToken.refreshToken);
await umbracoApi.stylesheet.ensureNameNotExists(stylesheetName);
await umbracoApi.dataType.ensureNameNotExists(richTextEditorName);
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
});

test('can create content with a rich text editor that has a stylesheet', async ({umbracoApi, umbracoUi}) => {
// Arrange
await umbracoApi.user.setUserPermissions(testUser.name, testUser.email, testUser.password, userGroupId);
testUserCookieAndToken = await umbracoApi.user.loginToUser(testUser.name, testUser.email, testUser.password);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content, false);

// Act
await umbracoUi.content.clickActionsMenuAtRoot();
await umbracoUi.content.clickCreateButton();
await umbracoUi.content.chooseDocumentType(documentTypeName);
await umbracoUi.content.enterContentName(documentName);
// Is needed to make sure that the rich text editor is loaded
await umbracoUi.waitForTimeout(500);
await umbracoUi.content.doesErrorNotificationHaveText(NotificationConstantHelper.error.noAccessToResource, false);
await umbracoUi.content.clickSaveButton();

// Assert
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created);
expect(await umbracoApi.document.doesNameExist(documentName)).toBeTruthy();
});