Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 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.

2 changes: 1 addition & 1 deletion tests/Umbraco.Tests.AcceptanceTest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"dependencies": {
"@umbraco/json-models-builders": "^2.0.33",
"@umbraco/playwright-testhelpers": "^15.0.47",
"@umbraco/playwright-testhelpers": "^15.0.49",
"camelize": "^1.0.0",
"dotenv": "^16.3.1",
"node-fetch": "^2.6.7"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers';

Check notice on line 1 in tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/RichTextEditor/ContentWithTiptap.spec.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (v15/dev)

✅ No longer an issue: Code Duplication

The module no longer contains too many functions with similar structure
import {expect} from "@playwright/test";

const contentName = 'TestContent';
Expand Down Expand Up @@ -84,136 +84,4 @@
const contentData = await umbracoApi.document.getByName(contentName);
expect(contentData.variants[0].state).toBe(expectedState);
expect(contentData.values[0].value.markup).toEqual('<p>' + inputText + '</p>');
});

test.fixme('can add a media in RTE Tiptap property editor', async ({umbracoApi, umbracoUi}) => {
// Arrange
const iconTitle = 'Media Picker';
const imageName = 'Test Image For Content';
await umbracoApi.media.ensureNameNotExists(imageName);
await umbracoApi.media.createDefaultMediaWithImage(imageName);
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.clickTipTapToolbarIconWithTitle(iconTitle);
// fix this
await umbracoUi.content.selectMediaWithName(imageName);
await umbracoUi.content.clickChooseModalButton();
await umbracoUi.content.clickMediaCaptionAltTextModalSubmitButton();
await umbracoUi.content.clickSaveButton();

// Assert
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved);
expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy();
const contentData = await umbracoApi.document.getByName(contentName);
expect(contentData.values[0].value.markup).toContain('<img');
expect(contentData.values[0].value.markup).toContain(imageName);

// Clean
await umbracoApi.media.ensureNameNotExists(imageName);
});

test('can add a video in RTE Tiptap property editor', async ({umbracoApi, umbracoUi}) => {
// Arrange
const iconTitle = 'Embed';
const videoURL = 'https://www.youtube.com/watch?v=Yu29dE-0OoI';
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.clickTipTapToolbarIconWithTitle(iconTitle);
await umbracoUi.content.enterEmbeddedURL(videoURL);
await umbracoUi.content.clickEmbeddedRetrieveButton();
await umbracoUi.content.waitForEmbeddedPreviewVisible();
await umbracoUi.content.clickEmbeddedMediaModalConfirmButton();
await umbracoUi.content.clickSaveButton();

// Assert
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved);
expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy();
const contentData = await umbracoApi.document.getByName(contentName);
expect(contentData.values[0].value.markup).toContain('data-embed-url');
expect(contentData.values[0].value.markup).toContain(videoURL);
});

test('cannot submit an empty link in RTE Tiptap property editor', async ({umbracoApi, umbracoUi}) => {
// Arrange
const iconTitle = 'Link';
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.clickTipTapToolbarIconWithTitle(iconTitle);
await umbracoUi.content.clickManualLinkButton();
await umbracoUi.content.enterLink('');
await umbracoUi.content.enterAnchorOrQuerystring('');
await umbracoUi.content.enterLinkTitle('');
await umbracoUi.content.clickAddButton();

// Assert
await umbracoUi.content.isTextWithMessageVisible(ConstantHelper.validationMessages.emptyLinkPicker);
});

// TODO: Remove skip when the front-end ready. Currently it still accept the empty link with an anchor or querystring
// Issue link: https://github.com/umbraco/Umbraco-CMS/issues/17411
test.skip('cannot submit an empty URL with an anchor or querystring in RTE Tiptap property editor', async ({umbracoApi, umbracoUi}) => {
// Arrange
const iconTitle = 'Link';
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.clickTipTapToolbarIconWithTitle(iconTitle);
await umbracoUi.content.clickManualLinkButton();
await umbracoUi.content.enterLink('');
await umbracoUi.content.enterAnchorOrQuerystring('#value');
await umbracoUi.content.clickAddButton();

// Assert
await umbracoUi.content.isTextWithMessageVisible(ConstantHelper.validationMessages.emptyLinkPicker);
});

// TODO: Remove skip when the front-end ready. Currently it is impossible to link to unpublished document
// Issue link: https://github.com/umbraco/Umbraco-CMS/issues/17974
test.skip('can insert a link to an unpublished document in RTE Tiptap property editor', async ({umbracoApi, umbracoUi}) => {
// Arrange
const iconTitle = 'Link';
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId);
await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
// Create a document to link
const documentTypeForLinkedDocumentName = 'TestDocumentType';
const documentTypeForLinkedDocumentId = await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(documentTypeForLinkedDocumentName);
const linkedDocumentName = 'LinkedDocument';
await umbracoApi.document.createDefaultDocument(linkedDocumentName, documentTypeForLinkedDocumentId);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);

// Act
await umbracoUi.content.goToContentWithName(contentName);
await umbracoUi.content.clickTipTapToolbarIconWithTitle(iconTitle);
await umbracoUi.content.clickDocumentLinkButton();
await umbracoUi.content.selectLinkByName(linkedDocumentName);
await umbracoUi.content.clickButtonWithName('Choose');
await umbracoUi.content.clickAddButton();
await umbracoUi.content.clickSaveButton();

// Assert
await umbracoUi.content.isSuccessNotificationVisible();

// Clean
await umbracoApi.documentType.ensureNameNotExists(documentTypeForLinkedDocumentName);
await umbracoApi.document.ensureNameNotExists(linkedDocumentName);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers';
import {expect} from "@playwright/test";

const contentName = 'TestContent';
const documentTypeName = 'TestDocumentTypeForContent';
const customDataTypeName = 'Test RTE Tiptap';

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);
await umbracoApi.dataType.ensureNameNotExists(customDataTypeName);
});

test('can add a media in RTE Tiptap property editor', async ({umbracoApi, umbracoUi}) => {
// Arrange
const iconTitle = 'Media Picker';
const imageName = 'Test Image For Content';
await umbracoApi.media.ensureNameNotExists(imageName);
await umbracoApi.media.createDefaultMediaWithImage(imageName);
const customDataTypeId = await umbracoApi.dataType.createDefaultTiptapDataType(customDataTypeName);
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.clickTipTapToolbarIconWithTitle(iconTitle);
await umbracoUi.content.selectMediaWithName(imageName);
await umbracoUi.content.clickChooseModalButton();
await umbracoUi.content.clickMediaCaptionAltTextModalSubmitButton();
await umbracoUi.content.clickSaveAndPublishButton();

// Assert
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved);
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.published);
expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy();
const contentData = await umbracoApi.document.getByName(contentName);
expect(contentData.values[0].value.markup).toContain('<img');
expect(contentData.values[0].value.markup).toContain(imageName);

// Clean
await umbracoApi.media.ensureNameNotExists(imageName);
});

test('can embed a video into RTE Tiptap property editor', async ({umbracoApi, umbracoUi}) => {
// Arrange
const iconTitle = 'Embed';
const videoURL = 'https://www.youtube.com/watch?v=Yu29dE-0OoI';
const customDataTypeId = await umbracoApi.dataType.createDefaultTiptapDataType(customDataTypeName);
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.clickTipTapToolbarIconWithTitle(iconTitle);
await umbracoUi.content.enterEmbeddedURL(videoURL);
await umbracoUi.content.clickEmbeddedRetrieveButton();
await umbracoUi.content.waitForEmbeddedPreviewVisible();
await umbracoUi.content.clickEmbeddedMediaModalConfirmButton();
await umbracoUi.content.clickSaveButton();

// Assert
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.saved);
expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy();
const contentData = await umbracoApi.document.getByName(contentName);
expect(contentData.values[0].value.markup).toContain('data-embed-url');
expect(contentData.values[0].value.markup).toContain(videoURL);
});

test('cannot submit an empty link in RTE Tiptap property editor', async ({umbracoApi, umbracoUi}) => {
// Arrange
const iconTitle = 'Link';
const customDataTypeId = await umbracoApi.dataType.createDefaultTiptapDataType(customDataTypeName);
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.clickTipTapToolbarIconWithTitle(iconTitle);
await umbracoUi.content.clickManualLinkButton();
await umbracoUi.content.enterLink('');
await umbracoUi.content.enterAnchorOrQuerystring('');
await umbracoUi.content.enterLinkTitle('');
await umbracoUi.content.clickAddButton();

// Assert
await umbracoUi.content.isTextWithMessageVisible(ConstantHelper.validationMessages.emptyLinkPicker);
});

// TODO: Remove skip when the front-end ready. Currently it still accept the empty link with an anchor or querystring
// Issue link: https://github.com/umbraco/Umbraco-CMS/issues/17411
test.skip('cannot submit an empty URL with an anchor or querystring in RTE Tiptap property editor', async ({umbracoApi, umbracoUi}) => {
// Arrange
const iconTitle = 'Link';
const customDataTypeId = await umbracoApi.dataType.createDefaultTiptapDataType(customDataTypeName);
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.clickTipTapToolbarIconWithTitle(iconTitle);
await umbracoUi.content.clickManualLinkButton();
await umbracoUi.content.enterLink('');
await umbracoUi.content.enterAnchorOrQuerystring('#value');
await umbracoUi.content.clickAddButton();

// Assert
await umbracoUi.content.isTextWithMessageVisible(ConstantHelper.validationMessages.emptyLinkPicker);
});

// TODO: Remove skip when the front-end ready. Currently it is impossible to link to unpublished document
// Issue link: https://github.com/umbraco/Umbraco-CMS/issues/17974
test.skip('can insert a link to an unpublished document in RTE Tiptap property editor', async ({umbracoApi, umbracoUi}) => {
// Arrange
const iconTitle = 'Link';
const customDataTypeId = await umbracoApi.dataType.createDefaultTiptapDataType(customDataTypeName);
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId);
await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
// Create a document to link
const documentTypeForLinkedDocumentName = 'TestDocumentType';
const documentTypeForLinkedDocumentId = await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(documentTypeForLinkedDocumentName);
const linkedDocumentName = 'LinkedDocument';
await umbracoApi.document.createDefaultDocument(linkedDocumentName, documentTypeForLinkedDocumentId);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);

// Act
await umbracoUi.content.goToContentWithName(contentName);
await umbracoUi.content.clickTipTapToolbarIconWithTitle(iconTitle);
await umbracoUi.content.clickDocumentLinkButton();
await umbracoUi.content.selectLinkByName(linkedDocumentName);
await umbracoUi.content.clickButtonWithName('Choose');
await umbracoUi.content.clickAddButton();
await umbracoUi.content.clickSaveButton();

// Assert
await umbracoUi.content.isSuccessNotificationVisible();

// Clean
await umbracoApi.documentType.ensureNameNotExists(documentTypeForLinkedDocumentName);
await umbracoApi.document.ensureNameNotExists(linkedDocumentName);
});

test('can view word count', async ({umbracoApi, umbracoUi}) => {
// Arrange
const inputText = 'Test Tiptap <b>here</b>!!!';
const expectedWordCount = 3;
const customDataTypeId = await umbracoApi.dataType.createTiptapDataTypeWithWordCountStatusbar(customDataTypeName);
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.enterRTETipTapEditor(inputText);

// Assert
await umbracoUi.content.doesTiptapHaveWordCount(expectedWordCount);
});

test('can view element path', async ({umbracoApi, umbracoUi}) => {
// Arrange
const inputText = 'This is Tiptap test';
const expectedElementPath = 'p';
const customDataTypeId = await umbracoApi.dataType.createTiptapDataTypeWithElementPathStatusbar(customDataTypeName);
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.enterRTETipTapEditor(inputText);

// Assert
await umbracoUi.content.doesElementPathHaveText(expectedElementPath);
});

Check warning on line 190 in tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/RichTextEditor/TiptapToolbar.spec.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (v15/dev)

❌ New issue: Code Duplication

The module contains 6 functions with similar structure: 'can add a media in RTE Tiptap property editor','can embed a video into RTE Tiptap property editor','can view element path','can view word count' and 2 more functions. Avoid duplicated, aka copy-pasted, code inside the module. More duplication lowers the code health.
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ test('tiptap is the default property editor in rich text editor', async ({umbrac
await umbracoUi.dataType.goToDataType(dataTypeName);

// Assert
//await umbracoUi.dataType.doesSettingHaveValue(ConstantHelper.tipTapSettings);
//await umbracoUi.dataType.doesSettingItemsHaveCount(ConstantHelper.tipTapSettings);
await umbracoUi.dataType.doesSettingHaveValue(ConstantHelper.tipTapSettings);
await umbracoUi.dataType.doesSettingItemsHaveCount(ConstantHelper.tipTapSettings);
await umbracoUi.dataType.doesPropertyEditorHaveName(tipTapPropertyEditorName);
await umbracoUi.dataType.doesPropertyEditorHaveAlias(tipTapAlias);
await umbracoUi.dataType.doesPropertyEditorHaveUiAlias(tipTapUiAlias);
Expand Down
Loading