From 0c3ad46e3b8d2215a22b3c272b3d81ed38dd830c Mon Sep 17 00:00:00 2001 From: krassowski <5832902+krassowski@users.noreply.github.com> Date: Sun, 14 Apr 2024 13:21:13 +0100 Subject: [PATCH] Fix the workspaces context menu flakiness --- galata/test/documentation/workspaces.test.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/galata/test/documentation/workspaces.test.ts b/galata/test/documentation/workspaces.test.ts index ee6e02398249..d7ec6837d3aa 100644 --- a/galata/test/documentation/workspaces.test.ts +++ b/galata/test/documentation/workspaces.test.ts @@ -85,6 +85,23 @@ test.describe('Workspaces sidebar', () => { await page.launcher.waitFor(); + // Force the kernel sidebar to "empty" state to avoid flaky snapshots; + // mocking the kernel session state does not help here, possibly due to + // concurrent test execution, so we manipulate the DOM directly. + const kernelsSection = page.locator('[aria-label="Kernels Section"]'); + for (const buttonName of ['collapse-expand', 'switch-view']) { + const button = kernelsSection.locator( + `.jp-ToolbarButton[data-jp-item-name="${buttonName}"]` + ); + if (await button.isVisible()) { + await button.evaluate(node => (node.style.display = 'none')); + } + } + const button = kernelsSection.locator('.jp-RunningSessions-shutdownAll'); + await button.evaluate( + node => ((node as HTMLButtonElement).disabled = true) + ); + expect( await page.screenshot({ clip: { y: 0, x: 0, width: 400, height: 420 } }) ).toMatchSnapshot('workspaces_sidebar.png');