From e6152f0068a4721b2dd7097718c8d88e6950d0f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Gu=CC=88nther?= Date: Thu, 5 Dec 2024 20:43:53 +0100 Subject: [PATCH] TASK: Render CKE with headings --- .../Fixtures/1Dimension/createNewNodes.e2e.js | 4 ++-- Tests/IntegrationTests/utils.js | 23 ++++++++++++++++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Tests/IntegrationTests/Fixtures/1Dimension/createNewNodes.e2e.js b/Tests/IntegrationTests/Fixtures/1Dimension/createNewNodes.e2e.js index afdd9ef4e4..33f025fea8 100644 --- a/Tests/IntegrationTests/Fixtures/1Dimension/createNewNodes.e2e.js +++ b/Tests/IntegrationTests/Fixtures/1Dimension/createNewNodes.e2e.js @@ -171,7 +171,7 @@ test('Can create content node from inside InlineUI', async t => { subSection('Type something inside of it'); await Page.waitForIframeLoading(t); - await typeTextInline(t, '.test-headline:last-child [contenteditable="true"]', headlineTitle); + await typeTextInline(t, '.test-headline:last-child [contenteditable="true"]', headlineTitle, 'heading1'); await t // .selectEditableContent(lastEditableElement, lastEditableElement) // .pressKey(headlineTitle.split('').join(' ')) @@ -189,7 +189,7 @@ test('Can create content node from inside InlineUI', async t => { .expect(ReactSelector('InlineValidationTooltips').exists).ok('Validation tooltip appeared'); await t .expect(changeRequestLogger.count(() => true)).eql(0, 'No requests were fired with invalid state'); - await typeTextInline(t, '.test-headline:last-child [contenteditable="true"]', 'Some text'); + await typeTextInline(t, '.test-headline:last-child [contenteditable="true"]', 'Some text', 'heading1'); await t .wait(1600) .switchToMainWindow(); diff --git a/Tests/IntegrationTests/utils.js b/Tests/IntegrationTests/utils.js index 949678aec3..5317eb4593 100644 --- a/Tests/IntegrationTests/utils.js +++ b/Tests/IntegrationTests/utils.js @@ -72,10 +72,25 @@ export async function beforeEach(t) { // This is a workaround for the fact that the contenteditable element is not directly selectable // for more information see https://testcafe.io/documentation/402688/reference/test-api/testcontroller/selecteditablecontent -export async function typeTextInline(t, selector, text, switchToIframe = true) { +export async function typeTextInline(t, selector, text, textType, switchToIframe = true) { await waitForReact(30000); await Page.waitForIframeLoading(); + const textTypeToTagMap = { + paragraph: 'p', + heading1: 'h1', + heading2: 'h2', + heading3: 'h3', + heading4: 'h4' + }; + + if (!Object.keys(textTypeToTagMap).includes(textType)) { + console.warn('Invalid textType, defaulting to "paragraph".'); + textType = 'paragraph'; + } + + const tagName = textTypeToTagMap[textType] || ''; + try { const contentIframeSelector = Selector('[name="neos-content-main"]', {timeout: 2000}); @@ -86,9 +101,11 @@ export async function typeTextInline(t, selector, text, switchToIframe = true) { await t.eval(() => { const element = window.document.querySelector(selector); const editor = element.closest('.ck-editor__editable'); - editor.ckeditorInstance.data.set(text); + const content = tagName !== '' ? `<${tagName}>${text}` : text; + console.log('content', content); + editor.ckeditorInstance.data.set(content); }, - {dependencies: {selector, text}} + {dependencies: {selector, text, tagName}} ); } catch (e) { // console.log(e);