mirror of
https://github.com/enso-org/enso.git
synced 2024-12-22 20:31:45 +03:00
c7cc5f0be0
Added a step for packaging IDE which runs integration tests. This is an additional step, not a job, because here I'm sure the package will exist and won't be built unnecessarily twice. Technically I could make a job downloading it from GH action, but didn't want to invest time to rust scripts. Once Bazel will be fully introduced, the integration test will be improved. # Important Notes Fixes #8487
55 lines
2.1 KiB
TypeScript
55 lines
2.1 KiB
TypeScript
/** @file Commonly used functions for electron tests */
|
|
|
|
import { _electron, expect, type Page, test } from '@playwright/test'
|
|
|
|
const LOADING_TIMEOUT = 10000
|
|
|
|
/**
|
|
* Tests run on electron executable.
|
|
*
|
|
* Similar to playwright's test, but launches electron, and passes Page of the main window.
|
|
*/
|
|
export function electronTest(name: string, body: (page: Page) => Promise<void> | void) {
|
|
test(name, async () => {
|
|
const app = await _electron.launch({
|
|
executablePath: process.env.ENSO_TEST_EXEC_PATH ?? '',
|
|
args: process.env.ENSO_TEST_APP_ARGS != null ? process.env.ENSO_TEST_APP_ARGS.split(',') : [],
|
|
env: { ...process.env, ['ENSO_TEST']: name },
|
|
})
|
|
const page = await app.firstWindow()
|
|
// Wait until page will be finally loaded: we expect login screen.
|
|
// There's bigger timeout, because the page may load longer on CI machines.
|
|
await expect(page.getByText('Login to your account')).toBeVisible({ timeout: LOADING_TIMEOUT })
|
|
await body(page)
|
|
await app.close()
|
|
})
|
|
}
|
|
|
|
/**
|
|
* Login as test user. This function asserts that page is the login page, and uses
|
|
* credentials from ENSO_TEST_USER and ENSO_TEST_USER_PASSWORD env variables.
|
|
*/
|
|
export async function loginAsTestUser(page: Page) {
|
|
// Login screen
|
|
await expect(page.getByRole('textbox', { name: 'email' })).toBeVisible()
|
|
await expect(page.getByRole('textbox', { name: 'password' })).toBeVisible()
|
|
if (process.env.ENSO_TEST_USER == null || process.env.ENSO_TEST_USER_PASSWORD == null) {
|
|
throw Error(
|
|
'Cannot log in; `ENSO_TEST_USER` and `ENSO_TEST_USER_PASSWORD` env variables are not provided',
|
|
)
|
|
}
|
|
await page.getByRole('textbox', { name: 'email' }).click()
|
|
await page.keyboard.insertText(process.env.ENSO_TEST_USER)
|
|
await page.keyboard.press('Tab')
|
|
await page.keyboard.insertText(process.env.ENSO_TEST_USER_PASSWORD)
|
|
await page.keyboard.press('Enter')
|
|
|
|
// Accept terms screen
|
|
await expect(page.getByText('I agree')).toHaveCount(2)
|
|
await expect(page.getByRole('button')).toHaveCount(1)
|
|
for (const checkbox of await page.getByText('I agree').all()) {
|
|
await checkbox.click()
|
|
}
|
|
await page.getByRole('button').click()
|
|
}
|