Skip to content

Commit b477564

Browse files
krassowskiandrii-i
authored andcommitted
Fix UI tests (jupyterlab#277)
* Upgrade galata to lab 4.1 Fix lockfile * Use `jp-button` instead of button * Be more explicit with test checking for "user menu with 2 items" (it is not!); because in lab 4.1 the DOM hierarchy changed (toolbar is now using shadow DOM), instead select the things which are of interest using precise selectors * Update snapshots * Update two more snapshots, switch serial assertions to soft * Fix `Create a notebook` test
1 parent 2dc2d6b commit b477564

12 files changed

+527
-525
lines changed

ui-tests/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"test:update": "npx playwright test --update-snapshots"
1010
},
1111
"devDependencies": {
12-
"@jupyterlab/galata": "^5.0.5",
13-
"@jupyterlab/services": "^7.0.5",
12+
"@jupyterlab/galata": "^5.1.5",
13+
"@jupyterlab/services": "^7.1.5",
1414
"@playwright/test": "^1.35.0"
1515
},
1616
"resolutions": {
-3.62 KB
Loading
-5.43 KB
Loading
-4.25 KB
Loading

ui-tests/tests/notebook.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ test.describe('Initialization', () => {
109109
await guestPage.notebook.open(pathUntitled);
110110

111111
const nbPanel = await page.notebook.getNotebookInPanel();
112-
expect(await nbPanel?.screenshot()).toMatchSnapshot(
112+
expect.soft(await nbPanel?.screenshot()).toMatchSnapshot(
113113
'initialization-create-notebook-host.png'
114114
);
115115

@@ -131,9 +131,10 @@ test.describe('Initialization', () => {
131131

132132
await guestPage.filebrowser.refresh();
133133
await guestPage.notebook.open(exampleNotebook);
134+
await guestPage.notebook.activate(exampleNotebook);
134135

135136
const nbPanel = await page.notebook.getNotebookInPanel();
136-
expect(await nbPanel?.screenshot()).toMatchSnapshot(
137+
expect.soft(await nbPanel?.screenshot()).toMatchSnapshot(
137138
'initialization-open-notebook-host.png'
138139
);
139140

-3.04 KB
Loading
-3.04 KB
Loading
-33.9 KB
Loading
-33.9 KB
Loading

ui-tests/tests/user-menu.spec.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,21 @@ test.use( {
1111
});
1212

1313
const openDialog = async (page: IJupyterLabPageFixture): Promise<Locator> => {
14-
const sharedLinkButton = page.locator('button[data-command="collaboration:shared-link"]');
14+
const sharedLinkButton = page.locator('jp-button[data-command="collaboration:shared-link"]');
1515
await sharedLinkButton.click();
1616
await expect(page.locator('.jp-Dialog')).toBeVisible();
1717
return page.locator('.jp-Dialog').first();
1818
};
1919

20-
test('the top bar should contain the user menu with 2 items', async ({ page }) => {
21-
const topBarItems = page.locator('#jp-top-bar > :not(.jp-Toolbar-spacer)');
22-
await expect(topBarItems).toHaveCount(2);
20+
test('the top bar should contain one user menu and one share button', async ({ page }) => {
21+
const shareButton = page.locator('#jp-top-bar jp-button[data-command="collaboration:shared-link"]');
22+
await expect(shareButton).toHaveCount(1);
23+
const userMenu = page.locator('#jp-top-bar .jp-MenuBar-anonymousIcon');
24+
await expect(userMenu).toHaveCount(1);
2325
});
2426

2527
test('should open dialog when clicking on the shared link button', async ({ page }) => {
26-
const sharedLinkButton = page.locator('button[data-command="collaboration:shared-link"]');
28+
const sharedLinkButton = page.locator('jp-button[data-command="collaboration:shared-link"]');
2729

2830
expect(await sharedLinkButton.screenshot()).toMatchSnapshot(
2931
'shared-link-icon.png'

0 commit comments

Comments
 (0)