From cee4e3f256fca327b5493d1647206ac9edf1ef5f Mon Sep 17 00:00:00 2001 From: Vitomir Budimir Date: Tue, 12 Dec 2023 11:38:09 +0100 Subject: [PATCH] chore(e2e): copy/paste from local frontend-e2e-tests repo --- apps/e2e-tests/tests/400-serlo-editor.ts | 161 +++++++++-------------- apps/e2e-tests/tests/420-text-plugin.ts | 67 ++++------ 2 files changed, 86 insertions(+), 142 deletions(-) diff --git a/apps/e2e-tests/tests/400-serlo-editor.ts b/apps/e2e-tests/tests/400-serlo-editor.ts index 27d3e76e4e..1c0b10f327 100644 --- a/apps/e2e-tests/tests/400-serlo-editor.ts +++ b/apps/e2e-tests/tests/400-serlo-editor.ts @@ -96,120 +96,87 @@ Scenario('Add plugin via slash command', async ({ I }) => { Scenario( 'Undo via keyboard in input field for article heading', async ({ I }) => { - const keyCombos = { - windowsAndLinux: ['control', 'z'], - mac: ['command', 'z'], - } + I.amOnPage('/entity/create/Article/1377') - for (const [platform, keys] of Object.entries(keyCombos)) { - I.say(`Checking undo keyboard shortcut for '${platform}'`) + const articleHeadingInput = 'input[placeholder="Titel"]' + I.click(articleHeadingInput) - I.amOnPage('/entity/create/Article/1377') + const firstWord = 'Some ' + I.type(firstWord) + I.wait(2) - const articleHeadingInput = 'input[placeholder="Titel"]' - I.click(articleHeadingInput) + const secondWord = 'Text' + I.type(secondWord) - const firstWord = 'Some ' - I.type(firstWord) - I.wait(2) + I.seeInField(articleHeadingInput, `${firstWord}${secondWord}`) - const secondWord = 'Text' - I.type(secondWord) + I.pressKey(['CommandOrControl', 'Z']) + I.dontSeeInField(articleHeadingInput, `${firstWord}${secondWord}`) + I.dontSeeInField(articleHeadingInput, `${secondWord}`) + I.seeInField(articleHeadingInput, firstWord) - I.seeInField(articleHeadingInput, `${firstWord}${secondWord}`) - - I.pressKey(keys) - I.dontSeeInField(articleHeadingInput, `${firstWord}${secondWord}`) - I.dontSeeInField(articleHeadingInput, `${secondWord}`) - I.seeInField(articleHeadingInput, firstWord) - - I.pressKey(keys) - I.dontSeeInField(articleHeadingInput, `${firstWord}${secondWord}`) - I.dontSeeInField(articleHeadingInput, firstWord) - } + I.pressKey(['CommandOrControl', 'Z']) + I.dontSeeInField(articleHeadingInput, `${firstWord}${secondWord}`) + I.dontSeeInField(articleHeadingInput, firstWord) } ) Scenario( 'Undo via keyboard in input field of picture plugin', async ({ I }) => { - const keyCombos = { - windowsAndLinux: ['control', 'z'], - mac: ['command', 'z'], - } - - for (const [platform, keys] of Object.entries(keyCombos)) { - I.say(`Checking undo keyboard shortcut for '${platform}'`) - - // make sure autofocus logic after opening is done - I.wait(0.5) - // No need to create the image plugin first as the multimedia plugin at the - // beginning of each page already contains one. But, we do need to focus it, - // in order to make the src input visible - I.click('$plugin-image-editor') - const imagePluginUrlInput = - 'input[placeholder="https://example.com/image.png"]' - - I.click(imagePluginUrlInput) - - const firstWord = 'Some ' - I.type(firstWord) - I.wait(2) - - const secondWord = 'Text' - I.type(secondWord) - - I.seeInField(imagePluginUrlInput, `${firstWord}${secondWord}`) - - I.pressKey(keys) - I.dontSeeInField(imagePluginUrlInput, `${firstWord}${secondWord}`) - I.dontSeeInField(imagePluginUrlInput, `${secondWord}`) - I.seeInField(imagePluginUrlInput, firstWord) - - I.pressKey(keys) - I.dontSeeInField(imagePluginUrlInput, `${firstWord}${secondWord}`) - I.dontSeeInField(imagePluginUrlInput, firstWord) - } + // make sure autofocus logic after opening is done + I.wait(0.5) + // No need to create the image plugin first as the multimedia plugin at the + // beginning of each page already contains one. But, we do need to focus it, + // in order to make the src input visible + I.click('$plugin-image-editor') + const imagePluginUrlInput = + 'input[placeholder="https://example.com/image.png"]' + + I.click(imagePluginUrlInput) + + const firstWord = 'Some ' + I.type(firstWord) + I.wait(2) + + const secondWord = 'Text' + I.type(secondWord) + + I.seeInField(imagePluginUrlInput, `${firstWord}${secondWord}`) + + I.pressKey(['CommandOrControl', 'Z']) + I.dontSeeInField(imagePluginUrlInput, `${firstWord}${secondWord}`) + I.dontSeeInField(imagePluginUrlInput, `${secondWord}`) + I.seeInField(imagePluginUrlInput, firstWord) + + I.pressKey(['CommandOrControl', 'Z']) + I.dontSeeInField(imagePluginUrlInput, `${firstWord}${secondWord}`) + I.dontSeeInField(imagePluginUrlInput, firstWord) } ) Scenario( 'Redo in input field for article heading via keyboard', async ({ I }) => { - const keyCombos = { - windowsAndLinux: { - UNDO: ['control', 'z'], - REDO: ['control', 'y'], - }, - mac: { - UNDO: ['command', 'z'], - REDO: ['command', 'y'], - }, - } - - for (const [platform, keys] of Object.entries(keyCombos)) { - I.say(`Checking redo keyboard shortcut for '${platform}'`) - - I.amOnPage('/entity/create/Article/1377') - - const articleHeadingInput = { xpath: '//input[@placeholder="Titel"]' } - I.click(articleHeadingInput) - - const firstWord = 'Some ' - I.type(firstWord) - I.wait(2) - - const secondWord = 'Text' - I.type(secondWord) - I.seeInField(articleHeadingInput, `${firstWord}${secondWord}`) - - I.pressKey(keys.UNDO) - I.dontSeeInField(articleHeadingInput, `${firstWord}${secondWord}`) - I.dontSeeInField(articleHeadingInput, `${secondWord}`) - I.seeInField(articleHeadingInput, firstWord) - - I.pressKey(keys.REDO) - I.seeInField(articleHeadingInput, `${firstWord}${secondWord}`) - } + I.amOnPage('/entity/create/Article/1377') + + const articleHeadingInput = { xpath: '//input[@placeholder="Titel"]' } + I.click(articleHeadingInput) + + const firstWord = 'Some ' + I.type(firstWord) + I.wait(2) + + const secondWord = 'Text' + I.type(secondWord) + I.seeInField(articleHeadingInput, `${firstWord}${secondWord}`) + + I.pressKey(['CommandOrControl', 'Z']) + I.dontSeeInField(articleHeadingInput, `${firstWord}${secondWord}`) + I.dontSeeInField(articleHeadingInput, `${secondWord}`) + I.seeInField(articleHeadingInput, firstWord) + + I.pressKey(['CommandOrControl', 'Y']) + I.seeInField(articleHeadingInput, `${firstWord}${secondWord}`) } ) diff --git a/apps/e2e-tests/tests/420-text-plugin.ts b/apps/e2e-tests/tests/420-text-plugin.ts index 564d57a1cb..d520642a5d 100644 --- a/apps/e2e-tests/tests/420-text-plugin.ts +++ b/apps/e2e-tests/tests/420-text-plugin.ts @@ -180,26 +180,18 @@ Scenario('Undo', async ({ I }) => { }) Scenario('Undo using keyboard', async ({ I }) => { - const keyCombos = { - windowsAndLinux: ['control', 'z'], - mac: ['command', 'z'], - } - - for (const [platform, keys] of Object.entries(keyCombos)) { - I.say(`Checking undo keyboard shortcut for '${platform}'`) - I.amOnPage('/entity/create/Article/1377') + I.amOnPage('/entity/create/Article/1377') - I.click('$add-new-plugin-row-button') + I.click('$add-new-plugin-row-button') - I.pressKey('Backspace') + I.pressKey('Backspace') - I.type('Some text') - I.see('Some text') + I.type('Some text') + I.see('Some text') - I.pressKey(keys) + I.pressKey(['CommandOrControl', 'Z']) - I.dontSee('Some text') - } + I.dontSee('Some text') }) Scenario('Redo', async ({ I }) => { @@ -223,44 +215,29 @@ Scenario('Redo', async ({ I }) => { }) Scenario('Redo using keyboard', async ({ I }) => { - const keyCombos = { - windowsAndLinux: { - UNDO: ['control', 'z'], - REDO: ['control', 'y'], - }, - mac: { - UNDO: ['command', 'z'], - REDO: ['command', 'y'], - }, - } - - for (const [platform, keys] of Object.entries(keyCombos)) { - I.say(`Checking redo keyboard shortcut for '${platform}'`) - - I.amOnPage('/entity/create/Article/1377') + I.amOnPage('/entity/create/Article/1377') - I.click('$add-new-plugin-row-button') + I.click('$add-new-plugin-row-button') - I.pressKey('Backspace') + I.pressKey('Backspace') - I.type('Some text') + I.type('Some text') - I.see('Some text') + I.see('Some text') - I.pressKey(keys.UNDO) + I.pressKey(['CommandOrControl', 'Z']) - I.dontSee('Some text') + I.dontSee('Some text') - // ! For some reason, the first redo does not work. The second one does. If - // one puts a pause() here and runs the command only once through the - // interactive shell , it works just as fine as clicking the button. - // Therefore, I thought the Ctrl+Y was maybe happening too quickly after the - // Ctrl+Z, but even with I.wait(1) inbetween, two executions were needed. - I.pressKey(keys.REDO) - I.pressKey(keys.REDO) + // ! For some reason, the first redo does not work. The second one does. If + // one puts a pause() here and runs the command only once through the + // interactive shell , it works just as fine as clicking the button. + // Therefore, I thought the Ctrl+Y was maybe happening too quickly after the + // Ctrl+Z, but even with I.wait(1) inbetween, two executions were needed. + I.pressKey(['CommandOrControl', 'Y']) + I.pressKey(['CommandOrControl', 'Y']) - I.see('Some text') - } + I.see('Some text') }) Scenario('Copy/cut/paste text', async ({ I }) => {