Skip to content

Commit

Permalink
Add integration test for notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
fcollonval committed Jul 30, 2023
1 parent 9b2cf5a commit 76f13a6
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ui-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
"private": true,
"scripts": {
"start": "jupyter lab --config jupyter_server_test_config.py",
"start:notebook": "jupyter notebook --config jupyter_server_test_config.py",
"test": "jlpm playwright test",
"test:update": "jlpm playwright test --update-snapshots"
"test:notebook": "jlpm playwright test -c playwright-notebook.config.js",
"test:update": "jlpm playwright test --update-snapshots",
"test:notebook:update": "jlpm playwright test -c playwright-notebook.config.js --update-snapshots"
},
"devDependencies": {
"@jupyterlab/galata": "^5.0.0",
Expand Down
19 changes: 19 additions & 0 deletions ui-tests/playwright-notebook.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Configuration for Playwright using default from @jupyterlab/galata
*/
const baseConfig = require('@jupyterlab/galata/lib/playwright-config');

module.exports = {
...baseConfig,
testMatch: 'tests/notebook*.spec.ts',
use: {
...baseConfig.use,
appPath: ''
},
webServer: {
command: 'jlpm start:notebook',
url: 'http://localhost:8888/tree',
timeout: 120 * 1000,
reuseExistingServer: !process.env.CI
}
};
1 change: 1 addition & 0 deletions ui-tests/playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const baseConfig = require('@jupyterlab/galata/lib/playwright-config');

module.exports = {
...baseConfig,
testMatch: 'tests/jupyterlab*.spec.ts',
webServer: {
command: 'jlpm start',
url: 'http://localhost:8888/lab',
Expand Down
43 changes: 43 additions & 0 deletions ui-tests/tests/notebook-tour.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { expect, test as base } from '@jupyterlab/galata';

export const test = base.extend({
waitForApplication: async ({ baseURL }, use, testInfo) => {
const waitIsReady = async (page): Promise<void> => {
await page.waitForSelector('#main-panel');
};
await use(waitIsReady);
},
});

test('should run the welcome tour', async ({ page }) => {

await page.getByRole('button', { name: 'Start now' }).click();
await page.getByLabel('Next', { exact: true }).click();
await page.getByLabel('Next', { exact: true }).click();
await page.getByLabel('Next', { exact: true }).click();
await page.getByLabel('Next', { exact: true }).click();
await page.getByLabel('Next', { exact: true }).click();

await expect
.soft(page.locator('.react-joyride__tooltip h4'))
.toHaveText('Command Palette');
await page.getByLabel('Done').click();
});

test('should run the notebook tour', async ({ page }) => {
await page.getByRole('menuitem', { name: 'File' }).click();
await page.getByText('New', { exact: true }).click();
await page.locator('#jp-mainmenu-file-new').getByText('Notebook').click();
await page.getByRole('button', { name: 'Select Kernel' }).click();
await page.getByRole('button', { name: 'Start now' }).click();
await page.getByLabel('Next', { exact: true }).click();
await page.getByLabel('Next', { exact: true }).click();
await page.getByLabel('Next', { exact: true }).click();
await page.getByLabel('Next', { exact: true }).click();
await page.getByLabel('Next', { exact: true }).click();
await page.getByLabel('Next', { exact: true }).click();
await expect
.soft(page.locator('.react-joyride__tooltip p'))
.toHaveText(/Its name and its status are displayed here\.$/);
await page.getByLabel('Done').click();
});

0 comments on commit 76f13a6

Please sign in to comment.