Skip to content

Commit

Permalink
Merge pull request #4296 from serlo/e2e/adapt-some-exercise-tests
Browse files Browse the repository at this point in the history
fix(e2e): adapt some exercise tests
  • Loading branch information
elbotho authored Nov 18, 2024
2 parents ad05524 + 6a43bfa commit d05ab20
Showing 1 changed file with 27 additions and 33 deletions.
60 changes: 27 additions & 33 deletions e2e-tests/tests/450-blanks-exercise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const initialTextPluginCount = 1
Scenario('Create and remove fill in the blanks exercise', async ({ I }) => {
createNewEditorEntity(I, 'exercise')

I.seeNumberOfElements('$plugin-text-editor', initialTextPluginCount)
I.click(BlanksExerciseButton)
I.see('Aufgabe: Lückentext')
I.click('$plugin-blanks-child-text-button')
I.seeNumberOfElements('$plugin-text-editor', initialTextPluginCount + 1)

Expand All @@ -24,37 +24,35 @@ Scenario('Create and remove fill in the blanks exercise', async ({ I }) => {

I.click('$additional-toolbar-controls')
I.click('$change-interactive-button')
I.seeNumberOfElements('$plugin-text-editor', initialTextPluginCount)
I.dontSee('Aufgabe: Lückentext')
})

Scenario(
'Create and remove fill in the gap exercise via undo',
'Create and remove fill in the blank exercise via undo',
async ({ I }) => {
createNewEditorEntity(I, 'exercise')

I.seeNumberOfElements('$plugin-text-editor', initialTextPluginCount)
I.click(BlanksExerciseButton)
I.click('$plugin-blanks-child-text-button')
I.seeNumberOfElements('$plugin-text-editor', initialTextPluginCount + 1)
I.see('Aufgabe: Lückentext')

I.pressKey(['CommandOrControl', 'Z'])

I.seeNumberOfElements('$plugin-text-editor', initialTextPluginCount)
I.dontSee('Aufgabe: Lückentext')
}
)

Scenario('Create and remove gaps through toolbar', async ({ I }) => {
Scenario('Create and remove blanks through toolbar', async ({ I }) => {
createNewEditorEntity(I, 'exercise')

I.seeNumberOfElements('$plugin-text-editor', initialTextPluginCount)
I.click(BlanksExerciseButton)
I.click('$plugin-blanks-child-text-button')
I.seeNumberOfElements('$plugin-text-editor', initialTextPluginCount + 1)

I.click(locate('$plugin-text-editor').last())
I.type('This is a test with one gap')
I.type('This is a test with one blank')

I.say('Select last word with keyboard and create gap')
I.say('Select last word with keyboard and create blank')
I.pressKey(['CommandOrControl', 'Shift', 'ArrowLeft'])

I.seeElement('$plugin-toolbar-button-lücke-erstellen')
Expand All @@ -70,45 +68,43 @@ Scenario('Create and remove gaps through toolbar', async ({ I }) => {
I.dontSeeElement('$blank-input')
})

Scenario('Create a blank gap and type in it', async ({ I }) => {
Scenario('Create a blank blank and type in it', async ({ I }) => {
createNewEditorEntity(I, 'exercise')

I.seeNumberOfElements('$plugin-text-editor', initialTextPluginCount)
I.click(BlanksExerciseButton)
I.click('$plugin-blanks-child-text-button')
I.seeNumberOfElements('$plugin-text-editor', initialTextPluginCount + 1)

I.click(locate('$plugin-text-editor').last())
I.say('Create an empty gap then type in it')
I.say('Create an empty blank then type in it')

I.type('No gap here ')
I.type('No blank here ')
I.click('$plugin-toolbar-button-lücke-erstellen')
I.seeNumberOfElements('$blank-input', 1)
I.click('$blank-input')
const GapContent = 'gap content'
I.type(GapContent)
I.seeInField('$blank-input', GapContent)
const blankContent = 'blank content'
I.type(blankContent)
I.seeInField('$blank-input', blankContent)
})

Scenario('Create and delete gaps with backspace/del', async ({ I }) => {
Scenario('Create and delete blanks with backspace/del', async ({ I }) => {
createNewEditorEntity(I, 'exercise')

I.seeNumberOfElements('$plugin-text-editor', initialTextPluginCount)
I.click(BlanksExerciseButton)
I.click('$plugin-blanks-child-text-button')
I.seeNumberOfElements('$plugin-text-editor', initialTextPluginCount + 1)

I.click(locate('$plugin-text-editor').last())
I.type('No gap here ')
I.type('No blank here ')

I.say('Create a gap, then delete it with backspace')
I.say('Create a blank, then delete it with backspace')
I.click('$plugin-toolbar-button-lücke-erstellen')
I.seeNumberOfElements('$blank-input', 1)
I.click('$blank-input')
I.pressKey('Backspace')
I.dontSeeElement('$blank-input')

I.say('Create a gap, then delete it with del')
I.say('Create a blank, then delete it with del')
I.click('$plugin-toolbar-button-lücke-erstellen')
I.seeNumberOfElements('$blank-input', 1)
I.click('$blank-input')
Expand All @@ -117,11 +113,10 @@ Scenario('Create and delete gaps with backspace/del', async ({ I }) => {
})

Scenario.todo(
'Ensure an added gap before any text gets focused',
'Ensure an added blank before any text gets focused',
async ({ I }) => {
createNewEditorEntity(I, 'exercise')

I.seeNumberOfElements('$plugin-text-editor', initialTextPluginCount)
I.click(BlanksExerciseButton)
I.click('$plugin-blanks-child-text-button')
I.seeNumberOfElements('$plugin-text-editor', initialTextPluginCount + 1)
Expand All @@ -144,25 +139,24 @@ Scenario.todo(
)

Scenario(
'Create a few gaps, go to preview mode and solve them!',
'Create a few blanks, go to preview mode and solve them!',
async ({ I }) => {
createNewEditorEntity(I, 'exercise')

I.seeNumberOfElements('$plugin-text-editor', initialTextPluginCount)
I.click(BlanksExerciseButton)
I.click('$plugin-blanks-child-text-button')
I.seeNumberOfElements('$plugin-text-editor', initialTextPluginCount + 1)

I.click(locate('$plugin-text-editor').last())
I.type('No gap here ')
I.type('No blank here ')

I.say('Create two gaps')
I.say('Create two blanks')
I.click('$plugin-toolbar-button-lücke-erstellen')
I.seeNumberOfElements('$blank-input', 1)
I.click('$blank-input')
I.type('first')

// unfocus gap
// unfocus blank
I.pressKey('ArrowRight')
// add normal text with surrounding space
I.type(' and ')
Expand All @@ -177,21 +171,21 @@ Scenario(
I.click('$plugin-exercise-preview-button')
I.seeNumberOfElements('$blank-input', 2)
I.click(locate('$blank-input').first())
// Adding the second gap solution to the first gap
// Adding the second blank solution to the first blank
I.type('second')

// The button to check answers should only be visible once all gaps have
// The button to check answers should only be visible once all blanks have
// inputs
I.dontSeeElement('$plugin-exercise-check-answer-button')

I.click(locate('$blank-input').last())
// Adding the first gap solution to the second gap
// Adding the first blank solution to the second blank
I.type('first')
I.seeElement('$plugin-exercise-check-answer-button')
I.click('$plugin-exercise-check-answer-button')
I.seeElement('$plugin-exercise-feedback-incorrect')

I.say('We now edit the gaps and solve them correctly')
I.say('We now edit the blanks and solve them correctly')
// Double click to highlight and overwrite the existing input
I.doubleClick(locate('$blank-input').first())
I.type('first')
Expand Down

0 comments on commit d05ab20

Please sign in to comment.