Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(e2e): more test fixes #4173

Merged
merged 4 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 11 additions & 31 deletions e2e-tests/codecept.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import config from './config'
import { configInput } from './config'
import { loginAsAdmin } from './tests/helpers/login-as-admin'

const { isCI, browser, frontendUrl } = config
const { isCI, browser, frontendUrl, adminUser, isChromium } = configInput

const useLocalAPI = process.env.FRONTEND_API == 'local'
export const adminUser = useLocalAPI ? 'admin' : 'Kulla'

const isChromium = browser === 'chromium'
export { adminUser }

exports.config = {
tests: 'tests/**.ts',
Expand All @@ -16,13 +14,12 @@ exports.config = {
restart: 'keep',
keepBrowserState: true,
keepCookies: true,
show: isCI ? false : true,
show: !isCI,
waitForTimeout: 30_000,
...(isCI && isChromium
? {
chromium: {
args: ['--no-sandbox'], // this is needed for github CI to work
},
// this is needed for github CI to work
chromium: { args: ['--no-sandbox'] },
}
: { browser }),
},
Expand All @@ -41,18 +38,7 @@ exports.config = {
inject: 'login',
users: {
admin: {
login: (I: CodeceptJS.I) => {
I.amOnPage('/')
I.see('Anmelden')
I.click('Anmelden')
I.waitForText('Benutzername oder E-Mailadresse', 10)
I.fillField('Benutzername oder E-Mailadresse', adminUser)
I.fillField('Passwort', '123456')
I.click('Anmelden', "button[value='password']")
I.waitForText(`Willkommen ${adminUser}!`, 30)
// Wait as a fix for: https://github.com/microsoft/playwright/issues/20749
I.wait(1)
},
login: loginAsAdmin,
check: (I: CodeceptJS.I) => {
I.amOnPage('/')
I.waitForElement(`header nav img[alt='Avatar']`, 15)
Expand All @@ -64,14 +50,8 @@ exports.config = {
},
},
...(isCI ? {} : { pauseOnFail: {} }),
retryFailedStep: {
enabled: true,
},
tryTo: {
enabled: true,
},
screenshotOnFail: {
enabled: true,
},
retryFailedStep: { enabled: true },
tryTo: { enabled: true },
screenshotOnFail: { enabled: true },
},
}
27 changes: 14 additions & 13 deletions e2e-tests/config.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import dotenv from 'dotenv'

function createConfig() {
const localUrl = 'http://localhost:3000'
const stagingUrl = 'https://de.serlo-staging.dev'

export const configInput = (() => {
dotenv.config()

const useLocalAPI = process.env.FRONTEND_API == 'local'
const isCI = Boolean(process.env.CI)
const browser = process.env.BROWSER ?? 'chromium'
const localApi = process.env.FRONTEND_API === 'local'

const defaultUrl = localApi ? localUrl : stagingUrl
const frontendUrl = process.env.FRONTEND_URL ?? defaultUrl

return {
isCI: Boolean(process.env.CI),
browser: process.env.BROWSER ?? 'chromium',
frontendUrl:
process.env.FRONTEND_URL ?? useLocalAPI
? 'http://localhost:3000'
: 'https://de.serlo-staging.dev',
}
}
const adminUser = localApi ? 'admin' : 'Kulla'

const config = createConfig()
const isChromium = browser === 'chromium'

export default config
return { isCI, browser, frontendUrl, adminUser, isChromium }
})()
22 changes: 11 additions & 11 deletions e2e-tests/tests/100-learners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,15 @@ Scenario('Geogebra', ({ I }) => {
I.waitForElement('canvas[data-test="euclidianView"]', 10)
})

Scenario('Video + Injection', ({ I }) => {
I.amOnPage('/277232')
I.scrollTo('#f7f13990')
I.see('dass externe Inhalte von')
I.click('Video abspielen von YouTube')
I.switchTo('iframe')
I.seeElement('video')
})
// deactivated for a while until youtube does not block us any more 😅
// Scenario('Video + Injection', ({ I }) => {
// I.amOnPage('/277232')
// I.scrollTo('#f7f13990')
// I.see('dass externe Inhalte von')
// I.click('Video abspielen von YouTube')
// I.switchTo('iframe')
// I.seeElement('video')
// })

Scenario('Toggle Solution', ({ I }) => {
I.amOnPage('/37779')
Expand Down Expand Up @@ -178,11 +179,10 @@ Scenario('Taxonomy', ({ I }) => {
I.click('Klasse 7')
I.see('Klasse 7')
I.click('Grundwissenstest 7. Klasse')
I.see('Aufgaben')
I.waitForText('Aufgaben', 5)
I.click('2021')

// Takes a long time to load
I.see('Berechne')
I.waitForText('Berechne', 5)

I.amOnPage('/24370')
I.see('Artikel')
Expand Down
8 changes: 4 additions & 4 deletions e2e-tests/tests/421-text-plugin-formatting-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Scenario(
I.type('https://de.serlo.org/mathe/1541/hypotenuse')
I.click('$link-suggestion-0')
I.click('Some text')
I.see('Hypotenuse')
I.waitForText('Hypotenuse', 10)
I.seeElement({ css: '.serlo-editor-hacks a' })

I.say('Toggle link off')
Expand All @@ -55,7 +55,7 @@ Scenario(
// just to make sure we are in the right mode
I.selectOption('$plugin-toolbar-math-type-switch', 'visuell')
I.seeElement('span.mq-editable-field')
I.type('x / 2')
I.type('x/2')
I.pressKey('ArrowRight')
I.pressKey('ArrowRight')
I.wait(1)
Expand Down Expand Up @@ -162,7 +162,7 @@ Scenario(
I.say('Refocus link')
I.click('Some text')
I.click('Some text')
I.see('Hypotenuse')
I.waitForText('Hypotenuse', 10)

I.say('Toggle link off via plugin bar')
I.click('Some text')
Expand Down Expand Up @@ -233,7 +233,7 @@ Scenario(
I.click('$plugin-toolbar-button-matheformel')
I.selectOption('$plugin-toolbar-math-type-switch', 'visuell')
I.seeElement('span.mq-editable-field')
I.type('x / 2')
I.type('x/2')
I.pressKey('ArrowRight')
I.pressKey('ArrowRight')
I.wait(1)
Expand Down
14 changes: 14 additions & 0 deletions e2e-tests/tests/helpers/login-as-admin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { adminUser } from '../../codecept.config'

export function loginAsAdmin(I: CodeceptJS.I) {
I.amOnPage('/')
I.see('Anmelden')
I.click('Anmelden')
I.waitForText('Benutzername oder E-Mailadresse', 10)
I.fillField('Benutzername oder E-Mailadresse', adminUser)
I.fillField('Passwort', '123456')
I.click('Anmelden', "button[value='password']")
I.waitForText(`Willkommen ${adminUser}!`, 30)
// Wait as a fix for: https://github.com/microsoft/playwright/issues/20749
I.wait(1)
}
Loading