Skip to content

Commit

Permalink
TASK: Write content via CKEditor instance
Browse files Browse the repository at this point in the history
As the firefox could not deal with the testcafe workaround. We now write the content to the CKE
  • Loading branch information
markusguenther committed Dec 5, 2024
1 parent 8b64c06 commit 0aed581
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(' '))
Expand All @@ -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();
Expand Down Expand Up @@ -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<br>Bun Buz');
await t
.expect(Selector('.neos-contentcollection').withText('Foo Bar').exists).ok('Inserted text exists');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
11 changes: 6 additions & 5 deletions Tests/IntegrationTests/Fixtures/1Dimension/syncing.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -216,14 +216,15 @@ async function prepareDocumentConflictBetweenAdminAndEditor(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').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();
Expand Down
15 changes: 8 additions & 7 deletions Tests/IntegrationTests/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 0aed581

Please sign in to comment.