From fcde31d871c4894cae9eedb08f737f23d1ffd048 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Thu, 21 May 2026 15:49:36 +0200 Subject: [PATCH] Address review: remove fallback route, handle trailing splat, extract shared path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove the path="*" fallback Route so mismatches between mountPath and initialRouteEntries surface as test failures instead of silently rendering without params - Handle mountPath values that already end with /* to avoid double splat - Extract repeated entity path string into a shared constant Co-Authored-By: Claude Opus 4.6 (1M context) Signed-off-by: Fredrik Adelöw --- .../src/app/renderInTestApp.tsx | 5 +- plugins/catalog/src/alpha/pages.test.tsx | 74 +++++++------------ 2 files changed, 29 insertions(+), 50 deletions(-) diff --git a/packages/frontend-test-utils/src/app/renderInTestApp.tsx b/packages/frontend-test-utils/src/app/renderInTestApp.tsx index 1344fc612e..82b9619566 100644 --- a/packages/frontend-test-utils/src/app/renderInTestApp.tsx +++ b/packages/frontend-test-utils/src/app/renderInTestApp.tsx @@ -157,11 +157,12 @@ export function renderInTestApp( if (mountPath) { const routePath = - mountPath === '/' ? mountPath : `${mountPath.replace(/\/$/, '')}/*`; + mountPath === '/' || mountPath.endsWith('/*') + ? mountPath + : `${mountPath.replace(/\/$/, '')}/*`; content = ( - ); } diff --git a/plugins/catalog/src/alpha/pages.test.tsx b/plugins/catalog/src/alpha/pages.test.tsx index bea98edf09..6807817967 100644 --- a/plugins/catalog/src/alpha/pages.test.tsx +++ b/plugins/catalog/src/alpha/pages.test.tsx @@ -107,6 +107,8 @@ describe('Entity page', () => { ], }; + const entityPath = '/catalog/default/component/artist-lookup'; + const mockCatalogApi = catalogApiMock({ entities: [entityMock] }); const mockStarredEntitiesApi = new MockStarredEntitiesApi(); @@ -151,7 +153,7 @@ describe('Entity page', () => { await renderInTestApp(tester.reactElement(), { apis: [mockCatalogApi, [starredEntitiesApiRef, mockStarredEntitiesApi]], mountPath: '/catalog/:namespace/:kind/:name', - initialRouteEntries: ['/catalog/default/component/artist-lookup'], + initialRouteEntries: [entityPath], config: { app: { title: 'Custom app', @@ -171,17 +173,11 @@ describe('Entity page', () => { await expect( screen.findByRole('button', { name: /TechDocs/ }), - ).resolves.toHaveAttribute( - 'href', - '/catalog/default/component/artist-lookup/techdocs', - ); + ).resolves.toHaveAttribute('href', `${entityPath}/techdocs`); await expect( screen.findByRole('button', { name: /ApiDocs/ }), - ).resolves.toHaveAttribute( - 'href', - '/catalog/default/component/artist-lookup/apidocs', - ); + ).resolves.toHaveAttribute('href', `${entityPath}/apidocs`); }); it('Should rename a default group', async () => { @@ -203,7 +199,7 @@ describe('Entity page', () => { await renderInTestApp(tester.reactElement(), { apis: [mockCatalogApi, [starredEntitiesApiRef, mockStarredEntitiesApi]], mountPath: '/catalog/:namespace/:kind/:name', - initialRouteEntries: ['/catalog/default/component/artist-lookup'], + initialRouteEntries: [entityPath], config: { app: { title: 'Custom app', @@ -221,17 +217,11 @@ describe('Entity page', () => { await expect( screen.findByRole('button', { name: /TechDocs/ }), - ).resolves.toHaveAttribute( - 'href', - '/catalog/default/component/artist-lookup/techdocs', - ); + ).resolves.toHaveAttribute('href', `${entityPath}/techdocs`); await expect( screen.findByRole('button', { name: /ApiDocs/ }), - ).resolves.toHaveAttribute( - 'href', - '/catalog/default/component/artist-lookup/apidocs', - ); + ).resolves.toHaveAttribute('href', `${entityPath}/apidocs`); }); it('Should disassociate a content with a default group', async () => { @@ -248,7 +238,7 @@ describe('Entity page', () => { await renderInTestApp(tester.reactElement(), { apis: [mockCatalogApi, [starredEntitiesApiRef, mockStarredEntitiesApi]], mountPath: '/catalog/:namespace/:kind/:name', - initialRouteEntries: ['/catalog/default/component/artist-lookup'], + initialRouteEntries: [entityPath], config: { app: { title: 'Custom app', @@ -300,7 +290,7 @@ describe('Entity page', () => { await renderInTestApp(tester.reactElement(), { apis: [mockCatalogApi, [starredEntitiesApiRef, mockStarredEntitiesApi]], mountPath: '/catalog/:namespace/:kind/:name', - initialRouteEntries: ['/catalog/default/component/artist-lookup'], + initialRouteEntries: [entityPath], config: { app: { title: 'Custom app', @@ -318,17 +308,11 @@ describe('Entity page', () => { await expect( screen.findByRole('button', { name: /TechDocs/ }), - ).resolves.toHaveAttribute( - 'href', - '/catalog/default/component/artist-lookup/techdocs', - ); + ).resolves.toHaveAttribute('href', `${entityPath}/techdocs`); await expect( screen.findByRole('button', { name: /ApiDocs/ }), - ).resolves.toHaveAttribute( - 'href', - '/catalog/default/component/artist-lookup/apidocs', - ); + ).resolves.toHaveAttribute('href', `${entityPath}/apidocs`); }); it('Should render a single-content groups as a normal tab', async () => { @@ -346,7 +330,7 @@ describe('Entity page', () => { await renderInTestApp(tester.reactElement(), { apis: [mockCatalogApi, [starredEntitiesApiRef, mockStarredEntitiesApi]], mountPath: '/catalog/:namespace/:kind/:name', - initialRouteEntries: ['/catalog/default/component/artist-lookup'], + initialRouteEntries: [entityPath], config: { app: { title: 'Custom app', @@ -379,7 +363,7 @@ describe('Entity page', () => { await renderInTestApp(tester.reactElement(), { apis: [mockCatalogApi, [starredEntitiesApiRef, mockStarredEntitiesApi]], mountPath: '/catalog/:namespace/:kind/:name', - initialRouteEntries: ['/catalog/default/component/artist-lookup'], + initialRouteEntries: [entityPath], config: { app: { title: 'Custom app', @@ -424,7 +408,7 @@ describe('Entity page', () => { await renderInTestApp(tester.reactElement(), { apis: [mockCatalogApi, [starredEntitiesApiRef, mockStarredEntitiesApi]], mountPath: '/catalog/:namespace/:kind/:name', - initialRouteEntries: ['/catalog/default/component/artist-lookup'], + initialRouteEntries: [entityPath], config: { app: { title: 'Custom app', @@ -442,17 +426,11 @@ describe('Entity page', () => { await expect( screen.findByRole('button', { name: /TechDocs/ }), - ).resolves.toHaveAttribute( - 'href', - '/catalog/default/component/artist-lookup/techdocs', - ); + ).resolves.toHaveAttribute('href', `${entityPath}/techdocs`); await expect( screen.findByRole('button', { name: /ApiDocs/ }), - ).resolves.toHaveAttribute( - 'href', - '/catalog/default/component/artist-lookup/apidocs', - ); + ).resolves.toHaveAttribute('href', `${entityPath}/apidocs`); }); it('Should sort content by title by default', async () => { @@ -465,7 +443,7 @@ describe('Entity page', () => { await renderInTestApp(tester.reactElement(), { apis: [mockCatalogApi, [starredEntitiesApiRef, mockStarredEntitiesApi]], mountPath: '/catalog/:namespace/:kind/:name', - initialRouteEntries: ['/catalog/default/component/artist-lookup'], + initialRouteEntries: [entityPath], config: { app: { title: 'Custom app', @@ -505,7 +483,7 @@ describe('Entity page', () => { await renderInTestApp(tester.reactElement(), { apis: [mockCatalogApi, [starredEntitiesApiRef, mockStarredEntitiesApi]], mountPath: '/catalog/:namespace/:kind/:name', - initialRouteEntries: ['/catalog/default/component/artist-lookup'], + initialRouteEntries: [entityPath], config: { app: { title: 'Custom app', @@ -553,7 +531,7 @@ describe('Entity page', () => { await renderInTestApp(tester.reactElement(), { apis: [mockCatalogApi, [starredEntitiesApiRef, mockStarredEntitiesApi]], mountPath: '/catalog/:namespace/:kind/:name', - initialRouteEntries: ['/catalog/default/component/artist-lookup'], + initialRouteEntries: [entityPath], config: { app: { title: 'Custom app', @@ -601,7 +579,7 @@ describe('Entity page', () => { await renderInTestApp(tester.reactElement(), { apis: [mockCatalogApi, [starredEntitiesApiRef, mockStarredEntitiesApi]], mountPath: '/catalog/:namespace/:kind/:name', - initialRouteEntries: ['/catalog/default/component/artist-lookup'], + initialRouteEntries: [entityPath], config: { app: { title: 'Custom app', @@ -637,7 +615,7 @@ describe('Entity page', () => { await renderInTestApp(tester.reactElement(), { apis: [mockCatalogApi, [starredEntitiesApiRef, mockStarredEntitiesApi]], mountPath: '/catalog/:namespace/:kind/:name', - initialRouteEntries: ['/catalog/default/component/artist-lookup'], + initialRouteEntries: [entityPath], config: { app: { title: 'Custom app', @@ -675,7 +653,7 @@ describe('Entity page', () => { await renderInTestApp(tester.reactElement(), { apis: [mockCatalogApi, [starredEntitiesApiRef, mockStarredEntitiesApi]], mountPath: '/catalog/:namespace/:kind/:name', - initialRouteEntries: ['/catalog/default/component/artist-lookup'], + initialRouteEntries: [entityPath], config: { app: { title: 'Custom app', @@ -733,7 +711,7 @@ describe('Entity page', () => { await renderInTestApp(tester.reactElement(), { apis: [mockCatalogApi, [starredEntitiesApiRef, mockStarredEntitiesApi]], mountPath: '/catalog/:namespace/:kind/:name', - initialRouteEntries: ['/catalog/default/component/artist-lookup'], + initialRouteEntries: [entityPath], config: { app: { title: 'Custom app', @@ -787,7 +765,7 @@ describe('Entity page', () => { await renderInTestApp(tester.reactElement(), { apis: [mockCatalogApi, [starredEntitiesApiRef, mockStarredEntitiesApi]], mountPath: '/catalog/:namespace/:kind/:name', - initialRouteEntries: ['/catalog/default/component/artist-lookup'], + initialRouteEntries: [entityPath], config: { app: { title: 'Custom app', @@ -877,7 +855,7 @@ describe('Entity page', () => { await renderInTestApp(tester.reactElement(), { mountPath: '/catalog/:namespace/:kind/:name', - initialRouteEntries: ['/catalog/default/component/artist-lookup'], + initialRouteEntries: [entityPath], config: { app: { title: 'Custom app',