-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a simple test that executes the notebook 1 and checks that it corresponds to the stored snapshot
- Loading branch information
1 parent
501104a
commit 6e68e52
Showing
7 changed files
with
105 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Playwright Tests | ||
on: | ||
push: | ||
branches: [main, master] | ||
pull_request: | ||
branches: [main, master] | ||
jobs: | ||
test: | ||
timeout-minutes: 60 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: lts/* | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.11" | ||
- name: Install dependencies | ||
run: | | ||
npm install | ||
python -m pip install . | ||
python -m pip install jupyterlab | ||
- name: Install Playwright Browser | ||
run: npx playwright install chromium | ||
- name: Run Playwright tests | ||
run: npx playwright test | ||
- uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
name: playwright-report | ||
path: playwright-report/ | ||
retention-days: 10 |
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,33 @@ | ||
/** | ||
* Run the notebooks of the examples folder | ||
*/ | ||
|
||
import { expect, test, galata } from "@jupyterlab/galata"; | ||
import { setTimeout } from "timers/promises"; | ||
import * as path from "path"; | ||
|
||
// request and tmpPath are Playwright fixtures | ||
test("1-Getting-Started", async ({ page, request, tmpPath }) => { | ||
// Import notebook 1 | ||
const content = galata.newContentsHelper(request); | ||
const filename = "1_Getting_Started.ipynb"; | ||
await content.uploadFile( | ||
path.resolve(__dirname, `../../examples/${filename}`), | ||
`${tmpPath}/${filename}`, | ||
); | ||
// Activate notebook | ||
await page.notebook.openByPath(`${tmpPath}/${filename}`); | ||
await page.notebook.activate(filename); | ||
// Wait until kernel is ready | ||
await page.waitForSelector( | ||
"#jp-main-statusbar >> text=Python 3 (ipykernel) | Idle", | ||
); | ||
// Execute all cells | ||
await page.notebook.runCellByCell(); | ||
// Wait for Aladin to pop | ||
await setTimeout(1000); // 1s | ||
// Save | ||
await page.notebook.save(); | ||
// And check snapshot | ||
expect(await page.screenshot()).toMatchSnapshot(); | ||
}); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,3 @@ | ||
from jupyterlab.galata import configure_jupyter_server | ||
|
||
configure_jupyter_server(c) # NOQA: F821 |
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,18 @@ | ||
/** | ||
* Configuration for Playwright using default from @jupyterlab/galata | ||
*/ | ||
const baseConfig = require("@jupyterlab/galata/lib/playwright-config"); | ||
|
||
module.exports = { | ||
...baseConfig, | ||
testDir: "./js/ui-tests", | ||
webServer: { | ||
command: "jlpm start", | ||
url: "http://localhost:8888/lab", | ||
timeout: 120 * 1000, | ||
reuseExistingServer: !process.env.CI, | ||
}, | ||
expect: { | ||
toMatchSnapshot: { maxDiffPixelsRatio: 0.02 }, // allow 2% difference on snapshots | ||
}, | ||
}; |