-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add UI tests * lint * add yarn.lock * fixes * fix workflow * increase timeout * timeout * fix snapshots * remove snapshots * update dep on jupyterlab
- Loading branch information
Showing
11 changed files
with
4,478 additions
and
3 deletions.
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
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,11 @@ | ||
# Integration Testing | ||
|
||
This folder contains the integration tests of the extension. | ||
|
||
They are defined using [Playwright](https://playwright.dev/docs/intro) test runner and | ||
[Galata](https://github.com/jupyterlab/jupyterlab/tree/main/galata) helper. | ||
|
||
The Playwright configuration is defined in | ||
[playwright.config.js](./playwright.config.js). | ||
|
||
The default configuration will produce video for failing tests and an HTML report. |
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 @@ | ||
from pathlib import Path | ||
from subprocess import run | ||
|
||
import jupyterlab | ||
|
||
extra_labextensions_path = str(Path(jupyterlab.__file__).parent / "galata") | ||
cmd = f"jupyter lite build --FederatedExtensionAddon.extra_labextensions_path={extra_labextensions_path}" | ||
|
||
run( | ||
cmd, | ||
check=True, | ||
shell=True, | ||
) |
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,7 @@ | ||
{ | ||
"jupyter-lite-schema-version": 0, | ||
"jupyter-config-data": { | ||
"appName": "JupyterLite UI Tests", | ||
"exposeAppInBrowser": true | ||
} | ||
} |
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,5 @@ | ||
{ | ||
"LiteBuildConfig": { | ||
"output_dir": "dist" | ||
} | ||
} |
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,24 @@ | ||
{ | ||
"name": "@jupyterlite/pyodide-kernel-ui-tests", | ||
"version": "1.0.0", | ||
"description": "JupyterLite Pyodide kernel integration tests", | ||
"private": true, | ||
"scripts": { | ||
"build": "yarn run clean && python build.py", | ||
"clean": "rimraf dist", | ||
"start": "python -m http.server -b 127.0.0.1 8000 --directory dist", | ||
"start:crossoriginisolated": "npx static-handler --cors --coop --coep --corp ./dist", | ||
"start:detached": "yarn run start&", | ||
"test": "playwright test", | ||
"test:debug": "PWDEBUG=1 playwright test", | ||
"test:report": "http-server ./playwright-report -a localhost -o", | ||
"test:update": "playwright test --update-snapshots" | ||
}, | ||
"devDependencies": { | ||
"@playwright/test": "^1.37.0", | ||
"rimraf": "^5.0.5" | ||
}, | ||
"dependencies": { | ||
"@jupyterlab/galata": "~5.0.5" | ||
} | ||
} |
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,43 @@ | ||
const baseConfig = require('@jupyterlab/galata/lib/playwright-config'); | ||
|
||
module.exports = { | ||
...baseConfig, | ||
reporter: [[process.env.CI ? 'dot' : 'list'], ['html']], | ||
use: { | ||
acceptDownloads: true, | ||
appPath: '', | ||
autoGoto: false, | ||
baseURL: 'http://localhost:8000', | ||
trace: 'on-first-retry', | ||
video: 'retain-on-failure', | ||
}, | ||
projects: [ | ||
{ | ||
name: 'default', | ||
use: { | ||
baseURL: 'http://localhost:8000', | ||
}, | ||
}, | ||
{ | ||
name: 'crossoriginisolated', | ||
use: { | ||
baseURL: 'http://localhost:8080', | ||
}, | ||
}, | ||
], | ||
retries: 1, | ||
webServer: [ | ||
{ | ||
command: 'yarn start', | ||
port: 8000, | ||
timeout: 120 * 1000, | ||
reuseExistingServer: true, | ||
}, | ||
{ | ||
command: 'yarn start:crossoriginisolated', | ||
port: 8080, | ||
timeout: 120 * 1000, | ||
reuseExistingServer: true, | ||
}, | ||
], | ||
}; |
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,53 @@ | ||
import { test } from '@jupyterlab/galata'; | ||
|
||
import { expect } from '@playwright/test'; | ||
|
||
const TIMEOUT = 600000; | ||
|
||
test.describe('General Tests', () => { | ||
test.setTimeout(TIMEOUT); | ||
|
||
test.beforeEach(({ page }) => { | ||
page.on('console', (message) => { | ||
console.log('CONSOLE MSG ---', message.text()); | ||
}); | ||
}); | ||
|
||
test('should execute some code', async ({ page }) => { | ||
await page.goto('lab/index.html'); | ||
|
||
const kernel = page.locator('[title="Python (Pyodide)"]').first(); | ||
await kernel.click(); | ||
|
||
// Wait for kernel to be idle | ||
await page.locator('#jp-main-statusbar').getByText('Idle').waitFor(); | ||
|
||
await page.notebook.setCell(0, 'code', 'print("ok")'); | ||
await page.notebook.runCell(0); | ||
|
||
// Wait for kernel to be idle | ||
await page.locator('#jp-main-statusbar').getByText('Idle').waitFor(); | ||
|
||
const cell = await page.notebook.getCellOutput(0); | ||
const cellContent = await cell?.textContent(); | ||
expect(cellContent).toContain('ok'); | ||
}); | ||
|
||
test('the kernel should have access to the file system', async ({ page }) => { | ||
await page.goto('lab/index.html'); | ||
|
||
// Create a Python notebook | ||
const kernel = page.locator('[title="Python (Pyodide)"]').first(); | ||
await kernel.click(); | ||
|
||
await page.notebook.save(); | ||
|
||
await page.notebook.setCell(0, 'code', 'import os; os.listdir()'); | ||
await page.notebook.runCell(0); | ||
|
||
const cell = await page.notebook.getCellOutput(0); | ||
const cellContent = await cell?.textContent(); | ||
const name = 'Untitled.ipynb'; | ||
expect(cellContent).toContain(name); | ||
}); | ||
}); |
Oops, something went wrong.