Skip to content

Commit 0457aff

Browse files
jtpiofcollonval
andauthored
[3.2.x] Relax @playright/test dependency in Galata (jupyterlab#11371)
* Relax `@playright/test` dependency in Galata * Backport fix for POST request status Co-authored-by: Frédéric Collonval <[email protected]>
1 parent a150e3b commit 0457aff

17 files changed

+237
-51
lines changed

galata/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"@jupyterlab/settingregistry": "^3.2.1",
5454
"@lumino/algorithm": "^1.3.3",
5555
"@lumino/coreutils": "^1.5.3",
56-
"@playwright/test": "1.14.1",
56+
"@playwright/test": "^1.16.2",
5757
"canvas": "^2.6.1",
5858
"fs-extra": "^9.0.1",
5959
"http-server": "^13.0.0",

galata/src/fixtures.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ namespace Private {
562562
runners.set(id, data);
563563
if (!page.isClosed() && !isClosed) {
564564
return route.fulfill({
565-
status: 201,
565+
status: type === 'sessions' ? 201 : 200,
566566
body: JSON.stringify(data),
567567
contentType: 'application/json',
568568
headers: response.headers as any

galata/src/playwright-config.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ import { PlaywrightTestConfig } from '@playwright/test';
55

66
// Default Playwright configuration for JupyterLab
77
module.exports = {
8-
reporter: [
9-
[process.env.CI ? 'dot' : 'list'],
10-
['@playwright/test/lib/test/reporters/html']
11-
],
8+
reporter: [[process.env.CI ? 'dot' : 'list'], ['html']],
129
reportSlowTests: null,
1310
timeout: 60000,
1411
use: {

galata/test/galata/fixture.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ test.describe('terminals', () => {
162162
test.describe('tmpPath', () => {
163163
test('should return an unique test folder', ({ tmpPath }) => {
164164
expect(tmpPath).toEqual(
165-
'test-galata-fixture-should-return-an-unique-test-folder-galata'
165+
'test-galata-fixture-tmpPath-should-return-an-unique-test-folder-galata'
166166
);
167167
});
168168
});
1.74 KB
Loading
3.19 KB
Loading
1.75 KB
Loading
1.33 KB
Loading
744 Bytes
Loading
Lines changed: 54 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,86 @@
11
import { test } from '@jupyterlab/galata';
22
import { expect } from '@playwright/test';
33

4-
test.describe('Terminal Tests', () => {
5-
test.describe('Open Terminal', () => {
6-
test.beforeEach(async ({ page }) => {
7-
await page.menu.clickMenuItem('File>New>Terminal');
8-
await page.sidebar.openTab('jp-running-sessions');
9-
await page.sidebar.getTab('jp-running-sessions');
10-
const content = await page.sidebar.getContentPanel('left');
11-
await page.waitForSelector(
12-
'span.jp-RunningSessions-itemLabel:has-text("terminals")'
13-
);
14-
await (
15-
await content.$(
16-
'span.jp-RunningSessions-itemLabel:has-text("terminals")'
17-
)
18-
).click();
4+
const TERMINAL_SELECTOR = '.jp-Terminal';
5+
const TERMINAL_THEME_ATTRIBUTE = 'data-term-theme';
6+
7+
test.describe('Terminal', () => {
8+
test.beforeEach(async ({ page }) => {
9+
await page.menu.clickMenuItem('File>New>Terminal');
10+
await page.waitForSelector(TERMINAL_SELECTOR);
11+
});
1912

20-
await page.waitForSelector('div.xterm-viewport');
13+
test.describe('Open', () => {
14+
test('should appear in the sidebar', async ({ page }) => {
15+
await page.sidebar.openTab('jp-running-sessions');
16+
await expect(page.locator('text=terminals/1')).toBeVisible();
2117
});
18+
});
2219

20+
test.describe('Theme', () => {
2321
test('Light theme terminal inherit', async ({ page }) => {
24-
expect(await page.screenshot()).toMatchSnapshot('light-term-inherit.png');
22+
const terminal = page.locator(TERMINAL_SELECTOR);
23+
await terminal.waitFor();
24+
await expect(terminal).toHaveAttribute(
25+
TERMINAL_THEME_ATTRIBUTE,
26+
'inherit'
27+
);
28+
expect(await terminal.screenshot()).toMatchSnapshot(
29+
'light-term-inherit.png'
30+
);
2531
});
2632

2733
test('Light theme terminal light', async ({ page }) => {
34+
const terminal = page.locator(TERMINAL_SELECTOR);
35+
await terminal.waitFor();
2836
await page.menu.clickMenuItem('Settings>Terminal Theme>Light');
29-
await page.menu.closeAll();
30-
expect(await page.screenshot()).toMatchSnapshot('light-term-light.png');
37+
await expect(terminal).toHaveAttribute(TERMINAL_THEME_ATTRIBUTE, 'light');
38+
expect(await terminal.screenshot()).toMatchSnapshot(
39+
'light-term-light.png'
40+
);
3141
});
3242

3343
test('Light theme terminal dark', async ({ page }) => {
44+
const terminal = page.locator(TERMINAL_SELECTOR);
45+
await terminal.waitFor();
3446
await page.menu.clickMenuItem('Settings>Terminal Theme>Dark');
35-
await page.menu.closeAll();
36-
expect(await page.screenshot()).toMatchSnapshot('light-term-dark.png');
47+
await expect(terminal).toHaveAttribute(TERMINAL_THEME_ATTRIBUTE, 'dark');
48+
expect(await terminal.screenshot()).toMatchSnapshot(
49+
'light-term-dark.png'
50+
);
3751
});
3852

3953
test('Dark theme terminal inherit', async ({ page }) => {
54+
const terminal = page.locator(TERMINAL_SELECTOR);
55+
await terminal.waitFor();
4056
await page.theme.setDarkTheme();
41-
await page.menu.closeAll();
42-
expect(await page.screenshot()).toMatchSnapshot('dark-term-inherit.png');
57+
await expect(terminal).toHaveAttribute(
58+
TERMINAL_THEME_ATTRIBUTE,
59+
'inherit'
60+
);
61+
expect(await terminal.screenshot()).toMatchSnapshot(
62+
'dark-term-inherit.png'
63+
);
4364
});
4465

4566
test('Dark theme terminal light', async ({ page }) => {
67+
const terminal = page.locator(TERMINAL_SELECTOR);
68+
await terminal.waitFor();
4669
await page.theme.setDarkTheme();
4770
await page.menu.clickMenuItem('Settings>Terminal Theme>Light');
48-
await page.menu.closeAll();
49-
expect(await page.screenshot()).toMatchSnapshot('dark-term-light.png');
71+
await expect(terminal).toHaveAttribute(TERMINAL_THEME_ATTRIBUTE, 'light');
72+
expect(await terminal.screenshot()).toMatchSnapshot(
73+
'dark-term-light.png'
74+
);
5075
});
5176

5277
test('Dark theme terminal dark', async ({ page }) => {
78+
const terminal = page.locator(TERMINAL_SELECTOR);
79+
await terminal.waitFor();
5380
await page.theme.setDarkTheme();
5481
await page.menu.clickMenuItem('Settings>Terminal Theme>Dark');
55-
await page.menu.closeAll();
56-
expect(await page.screenshot()).toMatchSnapshot('dark-term-dark.png');
82+
await expect(terminal).toHaveAttribute(TERMINAL_THEME_ATTRIBUTE, 'dark');
83+
expect(await terminal.screenshot()).toMatchSnapshot('dark-term-dark.png');
5784
});
5885
});
5986
});

0 commit comments

Comments
 (0)