Skip to content

Commit

Permalink
Add tests for menu opening
Browse files Browse the repository at this point in the history
  • Loading branch information
krassowski committed May 20, 2024
1 parent 9bcc716 commit 3291ff2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/components/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,9 @@ export function KernelTable(props: {
onContextMenu={(event: React.MouseEvent) => {
event.preventDefault();
const contextMenu = new MenuSvg({ commands: props.commands });
contextMenu.addClass('jp-NewLauncher-contextMenu');
const columnsSubMenu = new MenuSvg({ commands: props.commands });
columnsSubMenu.addClass('jp-NewLauncher-contextMenu-visibleColumns');
for (const column of columns) {
columnsSubMenu.addItem({
command: CommandIDs.toggleColumn,
Expand Down
23 changes: 23 additions & 0 deletions ui-tests/tests/jupyterlab_new_launcher.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,29 @@ test.describe('Default settings', () => {
const launcher = page.locator('.jp-LauncherBody');
expect(await launcher.screenshot()).toMatchSnapshot('launcher.png');
});

test('should open table context menu', async ({ page }) => {
const tableHead = page.locator(
'.jp-Launcher-launchNotebook thead > tr > th[data-id="star"]'
);
await tableHead.click({ button: 'right' });
const contextMenu = page.locator('.jp-NewLauncher-contextMenu');
await expect(contextMenu).toBeVisible();
expect
.soft(await contextMenu.screenshot())
.toMatchSnapshot('table-context-menu.png');

Check failure on line 20 in ui-tests/tests/jupyterlab_new_launcher.spec.ts

View workflow job for this annotation

GitHub Actions / Integration tests

tests/jupyterlab_new_launcher.spec.ts:11:7 › Default settings › should open table context menu

1) tests/jupyterlab_new_launcher.spec.ts:11:7 › Default settings › should open table context menu Error: A snapshot doesn't exist at /home/runner/work/jupyterlab-new-launcher/jupyterlab-new-launcher/ui-tests/tests/jupyterlab_new_launcher.spec.ts-snapshots/table-context-menu-linux.png, writing actual. 18 | expect 19 | .soft(await contextMenu.screenshot()) > 20 | .toMatchSnapshot('table-context-menu.png'); | ^ 21 | const visibleColumnsEntry = page.locator( 22 | '.jp-NewLauncher-contextMenu li >> text="Visible Columns"' 23 | ); at /home/runner/work/jupyterlab-new-launcher/jupyterlab-new-launcher/ui-tests/tests/jupyterlab_new_launcher.spec.ts:20:8
const visibleColumnsEntry = page.locator(
'.jp-NewLauncher-contextMenu li >> text="Visible Columns"'
);
await visibleColumnsEntry.hover();
const columnsContextMenu = page.locator(
'.jp-NewLauncher-contextMenu-visibleColumns'
);
await expect(columnsContextMenu).toBeVisible();
expect
.soft(await columnsContextMenu.screenshot())
.toMatchSnapshot('table-context-menu-visible-columns.png');

Check failure on line 31 in ui-tests/tests/jupyterlab_new_launcher.spec.ts

View workflow job for this annotation

GitHub Actions / Integration tests

tests/jupyterlab_new_launcher.spec.ts:11:7 › Default settings › should open table context menu

1) tests/jupyterlab_new_launcher.spec.ts:11:7 › Default settings › should open table context menu Error: A snapshot doesn't exist at /home/runner/work/jupyterlab-new-launcher/jupyterlab-new-launcher/ui-tests/tests/jupyterlab_new_launcher.spec.ts-snapshots/table-context-menu-visible-columns-linux.png, writing actual. 29 | expect 30 | .soft(await columnsContextMenu.screenshot()) > 31 | .toMatchSnapshot('table-context-menu-visible-columns.png'); | ^ 32 | }); 33 | }); 34 | at /home/runner/work/jupyterlab-new-launcher/jupyterlab-new-launcher/ui-tests/tests/jupyterlab_new_launcher.spec.ts:31:8
});
});

test.describe('With starred section', () => {
Expand Down

0 comments on commit 3291ff2

Please sign in to comment.