Skip to content

Commit

Permalink
Backport PR #15355: More robust galata/UI tests (#15450)
Browse files Browse the repository at this point in the history
Co-authored-by: Michał Krassowski <5832902+krassowski@users.noreply.github.com>
  • Loading branch information
meeseeksmachine and krassowski committed Nov 29, 2023
1 parent 338df29 commit 118ea00
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
12 changes: 5 additions & 7 deletions galata/src/helpers/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,11 @@ export class ActivityHelper {
return activeTab === name;
} else {
const tab = await this.getTab(name);
return (
(tab &&
(await tab.evaluate((tab: Element) =>
tab.classList.contains('jp-mod-current')
))) ??
false
);
if (!tab) {
return false;
}
const classes = ((await tab.getAttribute('class')) ?? '').split(' ');
return classes.includes('jp-mod-current');
}
}

Expand Down
23 changes: 14 additions & 9 deletions galata/test/jupyterlab/kernel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ test.describe('Kernel', () => {
page
.getByRole('tabpanel', { name: 'Launcher' })
.waitFor({ state: 'detached' }),
page.getByTitle('Python 3 (ipykernel)').nth(1).click()
page
.locator('[data-category="Notebook"][title="Python 3 (ipykernel)"]')
.click()
]);

await expect.soft(page.locator('.jp-Dialog')).toHaveCount(0);
Expand Down Expand Up @@ -112,14 +114,16 @@ test.describe('Kernel', () => {
page
.getByRole('tabpanel', { name: 'Launcher' })
.waitFor({ state: 'detached' }),
page.getByTitle('Python 3 (ipykernel)').nth(2).click()
page
.locator('[data-category="Console"][title="Python 3 (ipykernel)"]')
.click()
]);

await expect.soft(page.locator('.jp-Dialog')).toHaveCount(0);

await expect(page.getByTitle('Change kernel for Console 1')).toHaveText(
'Python 3 (ipykernel) | Idle'
);
await page
.getByTitle('Change kernel for Console 1')
.getByText('Python 3 (ipykernel) | Idle')
.waitFor();
});

test('Should ask for kernel when creating console from menu', async ({
Expand All @@ -132,9 +136,10 @@ test.describe('Kernel', () => {
.getByRole('button', { name: 'Select Kernel', exact: true })
.click();

await expect(page.getByTitle('Change kernel for Console 1')).toHaveText(
'Python 3 (ipykernel) | Idle'
);
await page
.getByTitle('Change kernel for Console 1')
.getByText('Python 3 (ipykernel) | Idle')
.waitFor();
});
});
});

0 comments on commit 118ea00

Please sign in to comment.