From 57ab23a1035aec597aa4eecfcb6d3e4b8f634994 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Gu=CC=88nther?= Date: Thu, 5 Dec 2024 13:27:37 +0100 Subject: [PATCH] TASK: Write content via CKEditor instance As the firefox could not deal with the testcafe workaround. We now write the content to the CKE --- .../Fixtures/1Dimension/createNewNodes.e2e.js | 6 +++--- .../Fixtures/1Dimension/richTextEditor.e2e.js | 4 ++-- .../Fixtures/1Dimension/syncing.e2e.js | 12 +++++++----- Tests/IntegrationTests/utils.js | 15 ++++++++------- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/Tests/IntegrationTests/Fixtures/1Dimension/createNewNodes.e2e.js b/Tests/IntegrationTests/Fixtures/1Dimension/createNewNodes.e2e.js index d0656135ae..afdd9ef4e4 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, Selector('.test-headline [contenteditable="true"]').nth(-1), headlineTitle); + await typeTextInline(t, '.test-headline:last-child [contenteditable="true"]', headlineTitle); 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, Selector('.test-headline [contenteditable="true"]').nth(-1), 'Some text'); + await typeTextInline(t, '.test-headline:last-child [contenteditable="true"]', 'Some text'); await t .wait(1600) .switchToMainWindow(); @@ -221,7 +221,7 @@ test('Inline CKEditor mode `paragraph: false` works as expected', async t => { subSection('Insert text into the inline text and press enter'); await Page.waitForIframeLoading(t); - await typeTextInline(t, Selector('.test-inline-headline [contenteditable="true"]').nth(-1), 'Foo Bar\nBun Buz'); + await typeTextInline(t, '.test-inline-headline:last-child [contenteditable="true"]', 'Foo Bar
Bun Buz'); await t .expect(Selector('.neos-contentcollection').withText('Foo Bar').exists).ok('Inserted text exists'); diff --git a/Tests/IntegrationTests/Fixtures/1Dimension/richTextEditor.e2e.js b/Tests/IntegrationTests/Fixtures/1Dimension/richTextEditor.e2e.js index 4dee9c53c8..78ca3745bd 100644 --- a/Tests/IntegrationTests/Fixtures/1Dimension/richTextEditor.e2e.js +++ b/Tests/IntegrationTests/Fixtures/1Dimension/richTextEditor.e2e.js @@ -14,10 +14,10 @@ test('Can crop an image', async t => { await Page.waitForIframeLoading(t); const rteInspectorEditor = await ReactSelector('InspectorEditorEnvelope').withProps('id', 'rte'); - const ckeContent = await Selector('.ck-content p'); + // const ckeContent = await Selector('.ck-content p'); await t .click(rteInspectorEditor.findReact('Button')); - await typeTextInline(t, ckeContent, testContent, false); + await typeTextInline(t, '.ck-content p', testContent, false); await t .wait(400) .click(Selector('#neos-Inspector-Apply')); diff --git a/Tests/IntegrationTests/Fixtures/1Dimension/syncing.e2e.js b/Tests/IntegrationTests/Fixtures/1Dimension/syncing.e2e.js index 4f51df0e0c..15f88779da 100644 --- a/Tests/IntegrationTests/Fixtures/1Dimension/syncing.e2e.js +++ b/Tests/IntegrationTests/Fixtures/1Dimension/syncing.e2e.js @@ -154,17 +154,17 @@ async function prepareContentElementConflictBetweenAdminAndEditor(t) { .switchToMainWindow(); await openContentTree(t); - await openContentTree(t); await t + .wait(1000) .click(Page.treeNode.withText('Content Collection (main)')) .click(Selector('#neos-ContentTree-AddNode')) .click(Selector('button#into')) - .click(ReactSelector('NodeTypeItem').withProps({nodeType: {label: 'Headline_Test'}})); + .click(ReactSelector('NodeTypeItem').find('button>span>span').withText('Headline_Test')) await Page.waitForIframeLoading(t); subSection('Type something inside of it'); - await typeTextInline(t, Selector('.test-headline [contenteditable="true"]').nth(-1), 'Hello from Page "Sync Demo #3"!'); + await typeTextInline(t, '.test-headline:last-child [contenteditable="true"]', 'Hello from Page "Sync Demo #3"!'); await t .expect(Selector('.neos-contentcollection').withText('Hello from Page "Sync Demo #3"!').exists).ok('Typed headline text exists') .switchToMainWindow(); @@ -216,14 +216,16 @@ async function prepareDocumentConflictBetweenAdminAndEditor(t) { await openContentTree(t); await t + .wait(1000) + .click(Selector('#neos-ContentTree-ToggleContentTree')) .click(Page.treeNode.withText('Content Collection (main)')) .click(Selector('#neos-ContentTree-AddNode')) .click(Selector('button#into')) - .click(ReactSelector('NodeTypeItem').withProps({nodeType: {label: 'Headline_Test'}})); + .click(ReactSelector('NodeTypeItem').find('button>span>span').withText('Headline_Test')); await Page.waitForIframeLoading(t); subSection('Type something inside of it'); - await typeTextInline(t, Selector('.test-headline').nth(-1), 'This change will not be published.'); + await typeTextInline(t, '.test-headline:last-child', 'This change will not be published.'); await t .wait(2000) .switchToMainWindow(); diff --git a/Tests/IntegrationTests/utils.js b/Tests/IntegrationTests/utils.js index e80c00fe8f..949678aec3 100644 --- a/Tests/IntegrationTests/utils.js +++ b/Tests/IntegrationTests/utils.js @@ -75,20 +75,21 @@ export async function beforeEach(t) { export async function typeTextInline(t, selector, text, switchToIframe = true) { await waitForReact(30000); await Page.waitForIframeLoading(); - const keyList = text.split('').map((char) => - char === ' ' ? 'space' : char === '\n' ? 'enter' : char - ); try { const contentIframeSelector = Selector('[name="neos-content-main"]', {timeout: 2000}); - const lastEditableElement = selector; + if (switchToIframe) { await t.switchToIframe(contentIframeSelector); } - await t - .selectEditableContent(lastEditableElement, lastEditableElement) - .pressKey(keyList.join(' ')); + await t.eval(() => { + const element = window.document.querySelector(selector); + const editor = element.closest('.ck-editor__editable'); + editor.ckeditorInstance.data.set(text); + }, + {dependencies: {selector, text}} + ); } catch (e) { // console.log(e); }