Skip to content

Commit

Permalink
Run the UI tests with the COOP/COEP headers (#103)
Browse files Browse the repository at this point in the history
* Add Playwright webserver with COOP/COEP headers

* Test on cross origin isolated

* try -U with --pre

* use project on the CI matrix

* fix typo

* add exclude

* only exclude

* Add file system test

* lint

* update tests

* fix tests
  • Loading branch information
jtpio authored Jul 22, 2024
1 parent c2b9362 commit 235f00e
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 4 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,12 @@ jobs:
fail-fast: false
matrix:
# try the latest stable and potential pre-releases
jupyterlite_version: ["jupyterlite-core -U", "jupyterlite-core --pre"]
jupyterlite_version: ["jupyterlite-core -U", "jupyterlite-core -U --pre"]
project: ["default", "crossoriginisolated"]
# the latest stable release is not compatible for now
exclude:
- jupyterlite_version: "jupyterlite-core -U"
project: "crossoriginisolated"

steps:
- name: Checkout
Expand Down Expand Up @@ -250,7 +255,7 @@ jobs:
- name: Execute integration tests
working-directory: ui-tests
run: |
jlpm playwright test
jlpm playwright test --project ${{ matrix.project }}
- name: Upload Playwright Test report
if: always()
Expand Down
3 changes: 2 additions & 1 deletion ui-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"scripts": {
"build": "yarn run clean && python build.py",
"clean": "rimraf dist",
"start": "cd dist && python -m http.server -b 127.0.0.1 8000",
"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",
Expand Down
20 changes: 20 additions & 0 deletions ui-tests/playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,33 @@ module.exports = {
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
}
]
};
19 changes: 18 additions & 1 deletion ui-tests/tests/jupyterlite_xeus.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ test.describe('General Tests', () => {
test('xeus-python should execute some code', async ({ page }) => {
await page.goto('lab/index.html');

// Launch a Python notebook
const xpython = page.locator('[title="Python 3.11 (XPython)"]').first();
await xpython.click();

Expand All @@ -44,4 +43,22 @@ test.describe('General Tests', () => {
'jupyter-xeus-execute.png'
);
});

test('the kernel should have access to the file system', async ({ page }) => {
await page.goto('lab/index.html');

// Create a Python notebook
const xpython = page.locator('[title="Python 3.11 (XPython)"]').first();
await xpython.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);
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 235f00e

Please sign in to comment.