From dba89984ea07480b26822fc7a1d93878dcb3a8a6 Mon Sep 17 00:00:00 2001 From: The-Peacemaker Date: Sun, 24 May 2026 15:06:22 +0530 Subject: [PATCH] fix(application): anchor opener route regex for tree paths Avoid false matches when a tree URL contains a directory named 'notebooks'. Adds a UI regression test for nested tree paths containing /notebooks/ and ensures tests wait for breadcrumb navigation to avoid networkidle timeouts in Chromium. --- packages/application-extension/src/index.ts | 2 +- ui-tests/test/tree.spec.ts | 22 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/packages/application-extension/src/index.ts b/packages/application-extension/src/index.ts index 6a347d92e4..98a578ecbe 100644 --- a/packages/application-extension/src/index.ts +++ b/packages/application-extension/src/index.ts @@ -73,7 +73,7 @@ import { Menu, Widget } from '@lumino/widgets'; /** * A regular expression to match path to notebooks and documents */ -const TREE_PATTERN = new RegExp('/(notebooks|edit)/(.*)'); +const TREE_PATTERN = new RegExp('^/(notebooks|edit)/(.*)$'); /** * A regular expression to suppress the file extension from display for .ipynb files. diff --git a/ui-tests/test/tree.spec.ts b/ui-tests/test/tree.spec.ts index 74eba32df9..66f8bcf405 100644 --- a/ui-tests/test/tree.spec.ts +++ b/ui-tests/test/tree.spec.ts @@ -53,6 +53,28 @@ test('Should redirect from notebooks route to tree route for directories', async expect(url.pathname).toEqual(`/tree/${dir}`); }); +test('should not show a file load error when path contains notebooks', async ({ + page, + tmpPath, +}) => { + const nestedPath = `${tmpPath}/test/notebooks/test`; + await page.contents.createDirectory(`${tmpPath}/test`); + await page.contents.createDirectory(`${tmpPath}/test/notebooks`); + await page.contents.createDirectory(nestedPath); + + await page.goto(`tree/${nestedPath}`); + await page.waitForSelector('.jp-FileBrowser-crumbs >> text=/test/'); + await page.waitForSelector('.jp-FileBrowser-crumbs >> text=/notebooks/'); + expect(new URL(page.url()).pathname).toEqual(`/tree/${nestedPath}`); + + await page.reload({ waitUntil: 'networkidle' }); + await page.waitForSelector('.jp-FileBrowser-crumbs >> text=/test/'); + await page.waitForSelector('.jp-FileBrowser-crumbs >> text=/notebooks/'); + expect(new URL(page.url()).pathname).toEqual(`/tree/${nestedPath}`); + + await expect(page.locator('text=File Load Error')).toHaveCount(0); +}); + test('Should activate file browser tab', async ({ page, tmpPath }) => { await page.goto(`tree/${tmpPath}`); await page.locator('.jp-TreePanel >> text="Running"').click();