Skip to content

Commit a538f01

Browse files
martinRenoupre-commit-ci[bot]trungleduc
authored
Add a ui-test (#27)
* Add a ui-test * Try closing the left sidebar * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Iterate * Update * Change screen res * Update * Update UI tests * SKip failed test to run the UI test * Use sidebar helper * here we go again * Activate test * Activate test again --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Duc Trung Le <leductrungxf@gmail.com>
1 parent 9885a25 commit a538f01

File tree

9 files changed

+82
-19
lines changed

9 files changed

+82
-19
lines changed

.github/workflows/update-integration-tests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ jobs:
3939
jlpm
4040
python -m pip install .
4141
42+
- name: Install UI test dependencies
43+
working-directory: ui-tests
44+
run: jlpm install
45+
4246
- uses: jupyterlab/maintainer-tools/.github/actions/update-snapshots@v1
4347
with:
4448
github_token: ${{ secrets.GITHUB_TOKEN }}

src/viewPanel/tabView.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ export class TabView extends Widget {
111111
* Update the viewers.
112112
*/
113113
private async _initGrid(): Promise<void> {
114-
for (const [viewerId, viewerData] of Object.entries(this.tabData)) {
114+
const viewerKeys = Object.keys(this.tabData).sort();
115+
116+
for (const viewerId of viewerKeys) {
117+
const viewerData = this.tabData[viewerId];
115118
// Create new viewers
116119
const viewer = await this._createViewer(
117120
this.tabName,

ui-tests/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
"description": "JupyterLab gluepyter Integration Tests",
55
"private": true,
66
"scripts": {
7-
"start": "jupyter lab --config jupyter_server_test_config.py",
7+
"start": "rimraf .jupyter_ystore.db && jupyter lab ../examples --config jupyter_server_test_config.py",
88
"test": "npx playwright test",
99
"test:update": "npx playwright test --update-snapshots"
1010
},
1111
"devDependencies": {
1212
"@jupyterlab/galata": "^5.0.0-beta.0",
13-
"@playwright/test": "^1.32.0"
14-
}
13+
"@playwright/test": "^1.32.0",
14+
"rimraf": "^3.0.2"
15+
}
1516
}

ui-tests/playwright.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,15 @@ module.exports = {
1010
url: 'http://localhost:8888/lab',
1111
timeout: 120 * 1000,
1212
reuseExistingServer: !process.env.CI
13+
},
14+
retries: 0,
15+
expect: {
16+
toMatchSnapshot: {
17+
// An acceptable ratio of pixels that are different to the total amount of pixels, between 0 and 1.
18+
maxDiffPixelRatio: 0.01
19+
}
20+
},
21+
use: {
22+
viewport: { width: 1920, height: 1080 }
1323
}
1424
};

ui-tests/tests/test.spec.ts

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,62 @@
1-
import { expect, test } from '@jupyterlab/galata';
1+
import { IJupyterLabPageFixture, expect, test } from '@jupyterlab/galata';
2+
3+
async function closeSideTab(page: IJupyterLabPageFixture): Promise<void> {
4+
await page
5+
.getByRole('tablist', { name: 'main sidebar' })
6+
.getByRole('tab', { name: 'gluepyter' })
7+
.click();
8+
}
29

310
/**
411
* Don't load JupyterLab webpage before running the tests.
512
* This is required to ensure we capture all log messages.
613
*/
714
test.use({ autoGoto: false });
815

9-
test('should emit an activation console message', async ({ page }) => {
10-
const logs: string[] = [];
16+
test('should render session file', async ({ page }) => {
17+
await page.goto();
18+
19+
await expect(page.getByText('session.glu')).toBeVisible();
20+
await page.getByText('session.glu').dblclick();
21+
22+
await closeSideTab(page);
23+
24+
// TODO Wait for spinner to not be visible once we have one
25+
await page.waitForSelector('.bqplot');
1126

12-
page.on('console', message => {
13-
logs.push(message.text());
14-
});
27+
expect(await page.screenshot()).toMatchSnapshot('session-tab1.png');
28+
});
1529

30+
test('should switch tab', async ({ page }) => {
1631
await page.goto();
32+
33+
await expect(page.getByText('session.glu')).toBeVisible();
34+
await page.getByText('session.glu').dblclick();
35+
36+
await closeSideTab(page);
37+
38+
// TODO Wait for spinner to not be visible once we have one
39+
await page.waitForSelector('.bqplot');
40+
41+
// Switch tab
42+
await page.getByRole('tab', { name: 'Tab 2' }).click();
43+
44+
await page.waitForSelector('li#tab-key-2-6.lm-TabBar-tab.lm-mod-current');
45+
46+
expect(await page.screenshot()).toMatchSnapshot('session-tab2.png');
47+
});
48+
49+
test('should open link editor', async ({ page }) => {
50+
await page.goto();
51+
52+
await expect(page.getByText('session.glu')).toBeVisible();
53+
await page.getByText('session.glu').dblclick();
54+
55+
// TODO Wait for spinner to not be visible once we have one
56+
await page.waitForSelector('.bqplot');
57+
58+
// Switch to link editor
59+
await (await page.waitForSelector('text="Link Data"')).click();
60+
61+
expect(await page.screenshot()).toMatchSnapshot('link-editor.png');
1762
});
71.7 KB
Loading
74.8 KB
Loading
38.9 KB
Loading

ui-tests/yarn.lock

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2501,6 +2501,15 @@ __metadata:
25012501
languageName: node
25022502
linkType: hard
25032503

2504+
"gluepyter-ui-tests@workspace:.":
2505+
version: 0.0.0-use.local
2506+
resolution: "gluepyter-ui-tests@workspace:."
2507+
dependencies:
2508+
"@jupyterlab/galata": ^5.0.0-beta.0
2509+
"@playwright/test": ^1.32.0
2510+
languageName: unknown
2511+
linkType: soft
2512+
25042513
"graceful-fs@npm:^4.1.6, graceful-fs@npm:^4.2.0, graceful-fs@npm:^4.2.6":
25052514
version: 4.2.11
25062515
resolution: "graceful-fs@npm:4.2.11"
@@ -2744,15 +2753,6 @@ __metadata:
27442753
languageName: node
27452754
linkType: hard
27462755

2747-
"jupytercad-ui-tests@workspace:.":
2748-
version: 0.0.0-use.local
2749-
resolution: "jupytercad-ui-tests@workspace:."
2750-
dependencies:
2751-
"@jupyterlab/galata": ^5.0.0-beta.0
2752-
"@playwright/test": ^1.32.0
2753-
languageName: unknown
2754-
linkType: soft
2755-
27562756
"lib0@npm:^0.2.42, lib0@npm:^0.2.74":
27572757
version: 0.2.74
27582758
resolution: "lib0@npm:0.2.74"

0 commit comments

Comments
 (0)