Skip to content

Commit

Permalink
chore(e2e): copy/paste from local frontend-e2e-tests repo
Browse files Browse the repository at this point in the history
  • Loading branch information
hejtful committed Dec 12, 2023
1 parent 9924e59 commit cee4e3f
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 142 deletions.
161 changes: 64 additions & 97 deletions apps/e2e-tests/tests/400-serlo-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
}
)
67 changes: 22 additions & 45 deletions apps/e2e-tests/tests/420-text-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand All @@ -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 }) => {
Expand Down

0 comments on commit cee4e3f

Please sign in to comment.