From 42d57bb94321a302eb8adc520bc12ad26a8551ae Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Mon, 26 Feb 2024 12:15:50 +0000 Subject: [PATCH] Fix flaky mobile UI tests --- ui-tests/test/mobile.spec.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ui-tests/test/mobile.spec.ts b/ui-tests/test/mobile.spec.ts index 4bbf0951c2..507f44b3ae 100644 --- a/ui-tests/test/mobile.spec.ts +++ b/ui-tests/test/mobile.spec.ts @@ -25,29 +25,29 @@ test.describe('Mobile', () => { test('The layout should be more compact on the notebook page', async ({ page, - tmpPath, browserName, }) => { - const notebook = 'empty.ipynb'; - await page.contents.uploadFile( - path.resolve(__dirname, `./notebooks/${notebook}`), - `${tmpPath}/${notebook}` - ); - await page.goto(`notebooks/${tmpPath}/${notebook}`); + // Create a new notebook + const [notebook] = await Promise.all([ + page.waitForEvent('popup'), + page.click('text="New"'), + page.click('text="Python 3 (ipykernel)"'), + ]); // wait for the kernel status animations to be finished - await waitForKernelReady(page); + await waitForKernelReady(notebook); // force switching back to command mode to avoid capturing the cursor in the screenshot - await page.evaluate(async () => { + await notebook.evaluate(async () => { await window.jupyterapp.commands.execute('notebook:enter-command-mode'); }); // TODO: remove if (browserName === 'firefox') { - await hideAddCellButton(page); + await hideAddCellButton(notebook); } - expect(await page.screenshot()).toMatchSnapshot('notebook.png'); + expect(await notebook.screenshot()).toMatchSnapshot('notebook.png'); + await notebook.close(); }); });