Skip to content

Commit e6152f0

Browse files
TASK: Render CKE with headings
1 parent 0aed581 commit e6152f0

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

Tests/IntegrationTests/Fixtures/1Dimension/createNewNodes.e2e.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ test('Can create content node from inside InlineUI', async t => {
171171
subSection('Type something inside of it');
172172
await Page.waitForIframeLoading(t);
173173

174-
await typeTextInline(t, '.test-headline:last-child [contenteditable="true"]', headlineTitle);
174+
await typeTextInline(t, '.test-headline:last-child [contenteditable="true"]', headlineTitle, 'heading1');
175175
await t
176176
// .selectEditableContent(lastEditableElement, lastEditableElement)
177177
// .pressKey(headlineTitle.split('').join(' '))
@@ -189,7 +189,7 @@ test('Can create content node from inside InlineUI', async t => {
189189
.expect(ReactSelector('InlineValidationTooltips').exists).ok('Validation tooltip appeared');
190190
await t
191191
.expect(changeRequestLogger.count(() => true)).eql(0, 'No requests were fired with invalid state');
192-
await typeTextInline(t, '.test-headline:last-child [contenteditable="true"]', 'Some text');
192+
await typeTextInline(t, '.test-headline:last-child [contenteditable="true"]', 'Some text', 'heading1');
193193
await t
194194
.wait(1600)
195195
.switchToMainWindow();

Tests/IntegrationTests/utils.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,25 @@ export async function beforeEach(t) {
7272

7373
// This is a workaround for the fact that the contenteditable element is not directly selectable
7474
// for more information see https://testcafe.io/documentation/402688/reference/test-api/testcontroller/selecteditablecontent
75-
export async function typeTextInline(t, selector, text, switchToIframe = true) {
75+
export async function typeTextInline(t, selector, text, textType, switchToIframe = true) {
7676
await waitForReact(30000);
7777
await Page.waitForIframeLoading();
7878

79+
const textTypeToTagMap = {
80+
paragraph: 'p',
81+
heading1: 'h1',
82+
heading2: 'h2',
83+
heading3: 'h3',
84+
heading4: 'h4'
85+
};
86+
87+
if (!Object.keys(textTypeToTagMap).includes(textType)) {
88+
console.warn('Invalid textType, defaulting to "paragraph".');
89+
textType = 'paragraph';
90+
}
91+
92+
const tagName = textTypeToTagMap[textType] || '';
93+
7994
try {
8095
const contentIframeSelector = Selector('[name="neos-content-main"]', {timeout: 2000});
8196

@@ -86,9 +101,11 @@ export async function typeTextInline(t, selector, text, switchToIframe = true) {
86101
await t.eval(() => {
87102
const element = window.document.querySelector(selector);
88103
const editor = element.closest('.ck-editor__editable');
89-
editor.ckeditorInstance.data.set(text);
104+
const content = tagName !== '' ? `<${tagName}>${text}</${tagName}>` : text;
105+
console.log('content', content);
106+
editor.ckeditorInstance.data.set(content);
90107
},
91-
{dependencies: {selector, text}}
108+
{dependencies: {selector, text, tagName}}
92109
);
93110
} catch (e) {
94111
// console.log(e);

0 commit comments

Comments
 (0)