From 3a19fa7c4bdb732a36f25cd7496d15e0daa4546e Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Tue, 15 Apr 2025 12:40:52 -0600 Subject: [PATCH] fix broken unit tests --- .../helpers/assetParamsToRoute.test.ts | 6 +++--- .../helpers/assetParamsToRoute.ts | 21 +++++++++++++++++-- .../routes/busterRoutes/busterAppRoutes.ts | 11 +++++++++- web/src/routes/helpers.tsx | 6 ++---- 4 files changed, 34 insertions(+), 10 deletions(-) diff --git a/web/src/layouts/ChatLayout/ChatLayoutContext/helpers/assetParamsToRoute.test.ts b/web/src/layouts/ChatLayout/ChatLayoutContext/helpers/assetParamsToRoute.test.ts index 3bef0f0a1..6cdaf605e 100644 --- a/web/src/layouts/ChatLayout/ChatLayoutContext/helpers/assetParamsToRoute.test.ts +++ b/web/src/layouts/ChatLayout/ChatLayoutContext/helpers/assetParamsToRoute.test.ts @@ -384,7 +384,8 @@ describe('assetParamsToRoute', () => { expect(result).toBe( createBusterRoute({ route: BusterRoutes.APP_DASHBOARD_ID, - dashboardId: mockAssetId + dashboardId: mockAssetId, + secondaryView: 'version-history' }) ); }); @@ -443,8 +444,7 @@ describe('assetParamsToRoute', () => { expect(result).toBe( createBusterRoute({ route: BusterRoutes.APP_DASHBOARD_ID, - dashboardId: mockAssetId, - chatId: mockChatId + dashboardId: mockAssetId }) ); }); diff --git a/web/src/layouts/ChatLayout/ChatLayoutContext/helpers/assetParamsToRoute.ts b/web/src/layouts/ChatLayout/ChatLayoutContext/helpers/assetParamsToRoute.ts index f6edc279a..d6b2c5b8b 100644 --- a/web/src/layouts/ChatLayout/ChatLayoutContext/helpers/assetParamsToRoute.ts +++ b/web/src/layouts/ChatLayout/ChatLayoutContext/helpers/assetParamsToRoute.ts @@ -103,10 +103,28 @@ const createDashboardRoute = ({ versionNumber?: number; }) => { if (chatId) { + if (versionNumber) { + return createBusterRoute({ + route: BusterRoutes.APP_CHAT_ID_DASHBOARD_ID_VERSION_NUMBER, + chatId, + dashboardId, + versionNumber, + secondaryView + }); + } + return createBusterRoute({ - route: BusterRoutes.APP_CHAT_ID_DASHBOARD_ID_VERSION_NUMBER, + route: BusterRoutes.APP_CHAT_ID_DASHBOARD_ID, chatId, dashboardId, + secondaryView + }); + } + + if (versionNumber) { + return createBusterRoute({ + route: BusterRoutes.APP_DASHBOARD_ID_VERSION_NUMBER, + dashboardId, versionNumber, secondaryView }); @@ -115,7 +133,6 @@ const createDashboardRoute = ({ return createBusterRoute({ route: BusterRoutes.APP_DASHBOARD_ID, dashboardId, - versionNumber, secondaryView }); }; diff --git a/web/src/routes/busterRoutes/busterAppRoutes.ts b/web/src/routes/busterRoutes/busterAppRoutes.ts index 1770c4e5b..01ca5b3cc 100644 --- a/web/src/routes/busterRoutes/busterAppRoutes.ts +++ b/web/src/routes/busterRoutes/busterAppRoutes.ts @@ -10,7 +10,8 @@ export enum BusterAppRoutes { APP_METRIC_ID_FILE = '/app/metrics/:metricId/file', APP_METRIC_ID_RESULTS = '/app/metrics/:metricId/results?secondary_view=:secondaryView', APP_DASHBOARDS = '/app/dashboards', - APP_DASHBOARD_ID = '/app/dashboards/:dashboardId', + APP_DASHBOARD_ID = '/app/dashboards/:dashboardId?secondary_view=:secondaryView', + APP_DASHBOARD_ID_VERSION_NUMBER = '/app/dashboards/:dashboardId?dashboard_version_number=:versionNumber&secondary_view=:secondaryView', APP_DASHBOARD_ID_FILE = '/app/dashboards/:dashboardId/file', APP_LOGS = '/app/logs', APP_DATASETS = '/app/datasets', @@ -77,6 +78,7 @@ export type BusterAppRoutesWithArgs = { [BusterAppRoutes.APP_DASHBOARD_ID]: { route: BusterAppRoutes.APP_DASHBOARD_ID; dashboardId: string; + secondaryView?: DashboardFileViewSecondary; }; [BusterAppRoutes.APP_DASHBOARD_ID_FILE]: { route: BusterAppRoutes.APP_DASHBOARD_ID_FILE; @@ -158,6 +160,13 @@ export type BusterAppRoutesWithArgs = { route: BusterAppRoutes.APP_CHAT_ID_DASHBOARD_ID; chatId: string; dashboardId: string; + secondaryView?: DashboardFileViewSecondary; + }; + [BusterAppRoutes.APP_DASHBOARD_ID_VERSION_NUMBER]: { + route: BusterAppRoutes.APP_DASHBOARD_ID_VERSION_NUMBER; + dashboardId: string; + versionNumber: number; + secondaryView?: DashboardFileViewSecondary; }; [BusterAppRoutes.APP_CHAT_ID_DASHBOARD_ID_VERSION_NUMBER]: { route: BusterAppRoutes.APP_CHAT_ID_DASHBOARD_ID_VERSION_NUMBER; diff --git a/web/src/routes/helpers.tsx b/web/src/routes/helpers.tsx index 1e76f62ee..f35f17113 100644 --- a/web/src/routes/helpers.tsx +++ b/web/src/routes/helpers.tsx @@ -21,10 +21,8 @@ export const pathNameToRoute = (pathName: string, params: any): BusterRoutes => [BusterRoutes.APP_DATASETS_ID_OVERVIEW]: BusterRoutes.APP_DATASETS, [BusterRoutes.APP_DATASETS_ID_EDITOR]: BusterRoutes.APP_DATASETS, [BusterRoutes.APP_TERMS_ID]: BusterRoutes.APP_TERMS, - [BusterRoutes.APP_METRIC_ID_VERSION_HISTORY_NUMBER]: - BusterRoutes.APP_METRIC_ID_VERSION_HISTORY_NUMBER, - [BusterRoutes.APP_CHAT_ID_DASHBOARD_ID_VERSION_HISTORY_NUMBER]: - BusterRoutes.APP_CHAT_ID_DASHBOARD_ID_VERSION_HISTORY_NUMBER + [BusterRoutes.APP_METRIC_ID_VERSION_NUMBER]: BusterRoutes.APP_METRIC, + [BusterRoutes.APP_DASHBOARD_ID_VERSION_NUMBER]: BusterRoutes.APP_DASHBOARDS }; if (route && paramRoutesToParent[route as string]) {