Skip to content
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

Update @jupyterlab/galata #7361

Merged
merged 18 commits into from
May 14, 2024
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ repos:
rev: 'v2.2.6'
hooks:
- id: codespell
args: ['-L', 'hart,noteable']
args: ['-L', 'hart,noteable', '--skip', "*.spec.ts"]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like afterAll makes the pre-commit check fail: https://results.pre-commit.ci/run/github/33653601/1715676598.F47qygP7RKuJagZupcWLmA

image

Adding afterAll to the list of ignored words (via -L) does not seem to help, but skipping all .spec.ts files does. Might be worth investigating more in a separate issue or PR.

exclude: |
(?x)^(
yarn.lock|
Expand Down
4 changes: 2 additions & 2 deletions ui-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"test:update": "playwright test --update-snapshots"
},
"dependencies": {
"@jupyterlab/galata": "~5.2.0-rc.0",
"@playwright/test": "^1.33.0",
"@jupyterlab/galata": "~5.2.0",
"@playwright/test": "^1.44.0",
"rimraf": "^3.0.2"
}
}
2 changes: 1 addition & 1 deletion ui-tests/test/editor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import path from 'path';

import { test } from './fixtures';

import { expect } from '@playwright/test';
import { expect } from '@jupyterlab/galata';

const FILE = 'environment.yml';

Expand Down
2 changes: 1 addition & 1 deletion ui-tests/test/filebrowser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import path from 'path';

import { expect } from '@playwright/test';
import { expect } from '@jupyterlab/galata';

import { test } from './fixtures';

Expand Down Expand Up @@ -36,7 +36,7 @@
const toolbar = page.getByRole('toolbar');

['Rename', 'Delete', 'Open', 'Download', 'Delete'].forEach(async (text) => {
expect(toolbar.getByText(text)).toBeVisible();

Check failure on line 39 in ui-tests/test/filebrowser.spec.ts

View workflow job for this annotation

GitHub Actions / ui-tests (firefox)

[firefox] › test/filebrowser.spec.ts:31:7 › File Browser › Select one file

1) [firefox] › test/filebrowser.spec.ts:31:7 › File Browser › Select one file ──────────────────── Error: expect(locator).toBeVisible() Locator: getByRole('toolbar').getByText('Open') Expected: visible Received: hidden Call log: - expect.toBeVisible with timeout 5000ms - waiting for getByRole('toolbar').getByText('Open') 37 | 38 | ['Rename', 'Delete', 'Open', 'Download', 'Delete'].forEach(async (text) => { > 39 | expect(toolbar.getByText(text)).toBeVisible(); | ^ 40 | }); 41 | }); 42 | at forEach (/home/runner/work/notebook/notebook/ui-tests/test/filebrowser.spec.ts:39:39) at /home/runner/work/notebook/notebook/ui-tests/test/filebrowser.spec.ts:38:56
});
});

Expand Down
2 changes: 1 addition & 1 deletion ui-tests/test/general.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import path from 'path';

import { expect } from '@playwright/test';
import { expect } from '@jupyterlab/galata';

import { test } from './fixtures';

Expand Down
2 changes: 1 addition & 1 deletion ui-tests/test/layout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import path from 'path';

import { expect } from '@playwright/test';
import { expect } from '@jupyterlab/galata';

import { galata } from '@jupyterlab/galata';

Expand Down
2 changes: 1 addition & 1 deletion ui-tests/test/links.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import path from 'path';

import { expect } from '@playwright/test';
import { expect } from '@jupyterlab/galata';

import { test } from './fixtures';

Expand Down
2 changes: 1 addition & 1 deletion ui-tests/test/menus.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import path from 'path';

import { test } from './fixtures';

import { expect } from '@playwright/test';
import { expect } from '@jupyterlab/galata';
import { waitForKernelReady } from './utils';

const NOTEBOOK = 'empty.ipynb';
Expand Down
34 changes: 27 additions & 7 deletions ui-tests/test/mobile.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

import { expect } from '@playwright/test';
import { IJupyterLabPage, expect, galata } from '@jupyterlab/galata';

Check warning on line 4 in ui-tests/test/mobile.spec.ts

View workflow job for this annotation

GitHub Actions / Test Lint

'IJupyterLabPage' is defined but never used

import { test } from './fixtures';

import { hideAddCellButton, waitForKernelReady } from './utils';

test.use({ autoGoto: false, viewport: { width: 524, height: 800 } });
test.use({
autoGoto: false,
viewport: { width: 524, height: 800 },
// Set a fixed string as Playwright is preventing the unique test name to be too long
// and replaces part of the path with a hash
tmpPath: 'mobile-layout',
});

test.describe('Mobile', () => {
// manually create the test directory since tmpPath is set to a fixed value
test.beforeAll(async ({ request, tmpPath }) => {
const contents = galata.newContentsHelper(request);
await contents.createDirectory(tmpPath);
});

test.afterAll(async ({ request, tmpPath }) => {
const contents = galata.newContentsHelper(request);
await contents.deleteDirectory(tmpPath);
});

test('The layout should be more compact on the file browser page', async ({
page,
tmpPath,
Expand All @@ -29,11 +46,14 @@
await page.goto(`tree/${tmpPath}`);

// Create a new notebook
const [notebook] = await Promise.all([
page.waitForEvent('popup'),
page.click('text="New"'),
page.click('text="Python 3 (ipykernel)"'),
]);
const notebookPromise = page.waitForEvent('popup');
await page.click('text="New"');
await page
.locator(
'[data-command="notebook:create-new"] >> text="Python 3 (ipykernel)"'
)
.click();
const notebook = await notebookPromise;

// wait for the kernel status animations to be finished
await waitForKernelReady(notebook);
Expand All @@ -48,7 +68,7 @@
await hideAddCellButton(notebook);
}

expect(await notebook.screenshot()).toMatchSnapshot('notebook.png');

Check failure on line 71 in ui-tests/test/mobile.spec.ts

View workflow job for this annotation

GitHub Actions / ui-tests (firefox)

[firefox] › test/mobile.spec.ts:41:7 › Mobile › The layout should be more compact on the notebook page

2) [firefox] › test/mobile.spec.ts:41:7 › Mobile › The layout should be more compact on the notebook page Error: Screenshot comparison failed: 275 pixels (ratio 0.01 of all image pixels) are different. Expected: /home/runner/work/notebook/notebook/ui-tests/test/mobile.spec.ts-snapshots/notebook-firefox-linux.png Received: /home/runner/work/notebook/notebook/ui-tests/test-results/test-mobile-Mobile-The-lay-36afb-ompact-on-the-notebook-page-firefox/notebook-actual.png Diff: /home/runner/work/notebook/notebook/ui-tests/test-results/test-mobile-Mobile-The-lay-36afb-ompact-on-the-notebook-page-firefox/notebook-diff.png 69 | } 70 | > 71 | expect(await notebook.screenshot()).toMatchSnapshot('notebook.png'); | ^ 72 | await notebook.close(); 73 | }); 74 | }); at /home/runner/work/notebook/notebook/ui-tests/test/mobile.spec.ts:71:41

Check failure on line 71 in ui-tests/test/mobile.spec.ts

View workflow job for this annotation

GitHub Actions / ui-tests (chromium)

[chromium] › test/mobile.spec.ts:41:7 › Mobile › The layout should be more compact on the notebook page

1) [chromium] › test/mobile.spec.ts:41:7 › Mobile › The layout should be more compact on the notebook page Error: Screenshot comparison failed: 274 pixels (ratio 0.01 of all image pixels) are different. Expected: /home/runner/work/notebook/notebook/ui-tests/test/mobile.spec.ts-snapshots/notebook-chromium-linux.png Received: /home/runner/work/notebook/notebook/ui-tests/test-results/test-mobile-Mobile-The-lay-36afb-ompact-on-the-notebook-page-chromium/notebook-actual.png Diff: /home/runner/work/notebook/notebook/ui-tests/test-results/test-mobile-Mobile-The-lay-36afb-ompact-on-the-notebook-page-chromium/notebook-diff.png 69 | } 70 | > 71 | expect(await notebook.screenshot()).toMatchSnapshot('notebook.png'); | ^ 72 | await notebook.close(); 73 | }); 74 | }); at /home/runner/work/notebook/notebook/ui-tests/test/mobile.spec.ts:71:41
await notebook.close();
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ui-tests/test/mobile.spec.ts-snapshots/tree-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ui-tests/test/mobile.spec.ts-snapshots/tree-firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion ui-tests/test/notebook.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) Jupyter Development Team.

Check failure on line 1 in ui-tests/test/notebook.spec.ts

View workflow job for this annotation

GitHub Actions / ui-tests (firefox)

[firefox] › test/notebook.spec.ts:32:7 › Notebook › Renaming the notebook should be possible

3) [firefox] › test/notebook.spec.ts:32:7 › Notebook › Renaming the notebook should be possible ── Error: apiRequestContext.fetch: Test ended. Call log: - → POST http://localhost:8888/api/sessions?1715693516719 - user-agent: Mozilla/5.0 (X11; Linux x86_64; rv:125.0) Gecko/20100101 Firefox/125.0 - accept: */* - accept-encoding: gzip, deflate, br - host: localhost:8888 - accept-language: en-US - content-type: text/plain;charset=UTF-8 - content-length: 172 - referer: http://localhost:8888/notebooks/test-notebook-Notebook-Title-should-be-rendered-firefox/example.ipynb - x-xsrftoken: 2|7375e24d|cb676d331853aa76794aeccd303b646b|1715693513 - origin: http://localhost:8888 - sec-fetch-dest: empty - sec-fetch-mode: cors - sec-fetch-site: same-origin - connection: keep-alive - cookie: username-localhost-8888=2|1:0|10:1715693513|23:username-localhost-8888|196:eyJ1c2VybmFtZSI6ICJhY2IwNzgwN2VkZmY0YzIwOWU5ZWNjZWJhNmU2ZTU2YyIsICJuYW1lIjogIkFub255bW91cyBFdWFudGhlIiwgImRpc3BsYXlfbmFtZSI6ICJBbm9ueW1vdXMgRXVhbnRoZSIsICJpbml0aWFscyI6ICJBRSIsICJjb2xvciI6IG51bGx9|666b41a288d431fee19cc32ed48e8f11370bf19298516888df5cfc401ff7f64a; _xsrf=2|7375e24d|cb676d331853aa76794aeccd303b646b|1715693513 at /home/runner/work/notebook/notebook/ui-tests/node_modules/@jupyterlab/galata/src/galata.ts:925:49
// Distributed under the terms of the Modified BSD License.

import path from 'path';

import { expect } from '@playwright/test';
import { expect } from '@jupyterlab/galata';

import { test } from './fixtures';

Expand Down
16 changes: 14 additions & 2 deletions ui-tests/test/settings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,23 @@

import { test } from './fixtures';

import { expect } from '@playwright/test';
import { expect, galata } from '@jupyterlab/galata';

test.use({ autoGoto: false });
// Set a fixed string as Playwright is preventing the unique test name to be too long
// and replaces part of the path with a hash
test.use({ autoGoto: false, tmpPath: 'settings' });

test.describe('Settings', () => {
test.beforeAll(async ({ request, tmpPath }) => {
const contents = galata.newContentsHelper(request);
await contents.createDirectory(tmpPath);
});

test.afterAll(async ({ request, tmpPath }) => {
const contents = galata.newContentsHelper(request);
await contents.deleteDirectory(tmpPath);
});

test('Should be persisted after reloading the page', async ({
page,
tmpPath,
Expand Down
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.
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.
15 changes: 9 additions & 6 deletions ui-tests/test/smoke.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect } from '@playwright/test';
import { expect } from '@jupyterlab/galata';

import { test } from './fixtures';

Expand All @@ -24,11 +24,14 @@ test.describe('Smoke', () => {
await console.waitForSelector('.jp-CodeConsole');

// Create a new notebook
const [notebook] = await Promise.all([
page.waitForEvent('popup'),
page.click('text="New"'),
page.click('text="Python 3 (ipykernel)"'),
]);
const notebookPromise = page.waitForEvent('popup');
await page.click('text="New"');
await page
.locator(
'[data-command="notebook:create-new"] >> text="Python 3 (ipykernel)"'
)
.click();
const notebook = await notebookPromise;

try {
// we may have to select the kernel first
Expand Down
2 changes: 1 addition & 1 deletion ui-tests/test/tree.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { test } from './fixtures';

import { expect } from '@playwright/test';
import { expect } from '@jupyterlab/galata';

const SUBFOLDER = 'subfolder';

Expand Down
8 changes: 2 additions & 6 deletions ui-tests/test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ export async function runAndAdvance(
/**
* Wait for the kernel to be ready
*/
export async function waitForKernelReady(
page: IJupyterLabPageFixture
): Promise<void> {
export async function waitForKernelReady(page: Page): Promise<void> {
await page.waitForSelector('.jp-NotebookKernelStatus-fade');
await page.waitForFunction(() => {
const status = window.document.getElementsByClassName(
Expand All @@ -41,9 +39,7 @@ export async function waitForKernelReady(
* Special case for firefox headless issue
* See https://github.com/jupyter/notebook/pull/6872#issuecomment-1549594166 for more details
*/
export async function hideAddCellButton(
page: IJupyterLabPageFixture
): Promise<void> {
export async function hideAddCellButton(page: Page): Promise<void> {
await page
.locator('.jp-Notebook-footer')
.evaluate((element) => (element.style.display = 'none'));
Expand Down
Loading
Loading