-
Notifications
You must be signed in to change notification settings - Fork 323
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
Integration Tests #11186
Merged
Merged
Integration Tests #11186
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
527a87f
Integration test stub
farmaazon 5110167
Sandboxing tests and login
farmaazon 832e4e5
Small refactoring
farmaazon 8ff8293
Allow other platforms WIP
farmaazon f69562f
increase threshold for slow tests
farmaazon 8745b6b
Is this proper mac path?
farmaazon 4b781ac
fixes
farmaazon af07d2f
Review
farmaazon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** @file Playwright browser testing configuration. */ | ||
import { defineConfig } from '@playwright/test' | ||
|
||
/* eslint-disable @typescript-eslint/no-magic-numbers, @typescript-eslint/strict-boolean-expressions */ | ||
|
||
export default defineConfig({ | ||
testDir: './tests', | ||
forbidOnly: !!process.env.CI, | ||
workers: 1, | ||
timeout: 60000, | ||
reportSlowTests: { max: 5, threshold: 60000 }, | ||
globalSetup: './tests/setup.ts', | ||
expect: { | ||
timeout: 5000, | ||
toHaveScreenshot: { threshold: 0 }, | ||
}, | ||
use: { | ||
actionTimeout: 5000, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** @file A test for basic flow of the application: open project and see if nodes appear. */ | ||
|
||
/* eslint-disable @typescript-eslint/no-magic-numbers */ | ||
|
||
import { expect } from '@playwright/test' | ||
import { electronTest, loginAsTestUser } from './electronTest' | ||
|
||
electronTest('Create new project', async page => { | ||
await loginAsTestUser(page) | ||
await expect(page.getByRole('button', { name: 'New Project', exact: true })).toBeVisible() | ||
await page.getByRole('button', { name: 'New Project', exact: true }).click() | ||
await expect(page.locator('.GraphNode'), {}).toBeVisible({ timeout: 30000 }) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** @file Commonly used functions for electron tests */ | ||
|
||
import { _electron, expect, type Page, test } from '@playwright/test' | ||
|
||
/** | ||
* 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 ?? '', | ||
env: { ...process.env, ['ENSO_TEST']: name }, | ||
}) | ||
const page = await app.firstWindow() | ||
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.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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i suppose this is sufficient for now. but we will probably want to extract dashboard and/or GUI actions to a shared package |
||
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() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** @file {@link setup} function for all tests. */ | ||
|
||
import * as fs from 'node:fs' | ||
|
||
const POSSIBLE_EXEC_PATHS = [ | ||
'../../../dist/ide/linux-unpacked/enso', | ||
'../../../dist/ide/win-unpacked/Enso.exe', | ||
'../../../dist/ide/mac/Enso.app/Contents/MacOS/Enso', | ||
'../../../dist/ide/mac-arm64/Enso.app/Contents/MacOS/Enso', | ||
] | ||
|
||
/** | ||
* Setup for all tests: checks if and where electron exec is. | ||
* @throws when no Enso package could be found. | ||
*/ | ||
export default function setup() { | ||
const execPath = POSSIBLE_EXEC_PATHS.find(path => { | ||
try { | ||
fs.accessSync(path, fs.constants.X_OK) | ||
return true | ||
} catch (err) { | ||
return false | ||
} | ||
}) | ||
if (execPath != null) { | ||
process.env.ENSO_TEST_EXEC_PATH = execPath | ||
} else { | ||
throw Error('Cannot find Enso package') | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: consider
inspect\b
andport\b
. not perfect but might as well