update routes

This commit is contained in:
Nate Kelley 2025-04-01 13:16:56 -06:00
parent e83229a974
commit d255c5a719
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
3 changed files with 15 additions and 58 deletions

View File

@ -22,17 +22,29 @@ export const MetricContainerHeaderSegment: React.FC<FileContainerSegmentProps> =
{
label: 'Chart',
value: 'chart',
link: createBusterRoute({ route: BusterRoutes.APP_CHAT_ID_QUERY, chatId, metricId })
link: createBusterRoute({
route: BusterRoutes.APP_CHAT_ID_METRIC_ID_CHART,
chatId,
metricId
})
},
{
label: 'Results',
value: 'results',
link: createBusterRoute({ route: BusterRoutes.APP_CHAT_ID_QUERY, chatId, metricId })
link: createBusterRoute({
route: BusterRoutes.APP_CHAT_ID_METRIC_ID_RESULTS,
chatId,
metricId
})
},
{
label: 'File',
value: 'file',
link: createBusterRoute({ route: BusterRoutes.APP_CHAT_ID_QUERY, chatId, metricId })
link: createBusterRoute({
route: BusterRoutes.APP_CHAT_ID_METRIC_ID_FILE,
chatId,
metricId
})
}
];
}

View File

@ -27,7 +27,6 @@ export enum BusterAppRoutes {
//NEW CHAT
APP_CHAT = '/app/chats',
APP_CHAT_ID = '/app/chats/:chatId',
APP_CHAT_ID_QUERY = '/app/chats/:chatId?metricId=:metricId&dashboardId=:dashboardId&messageId=:messageId',
APP_CHAT_ID_REASONING_ID = '/app/chats/:chatId/reasoning/:messageId',
APP_CHAT_ID_METRIC_ID = '/app/chats/:chatId/metrics/:metricId',
APP_CHAT_ID_METRIC_ID_CHART = '/app/chats/:chatId/metrics/:metricId/chart',
@ -110,13 +109,6 @@ export type BusterAppRoutesWithArgs = {
[BusterAppRoutes.NEW_USER]: { route: BusterAppRoutes.NEW_USER };
[BusterAppRoutes.APP_CHAT]: { route: BusterAppRoutes.APP_CHAT };
[BusterAppRoutes.APP_CHAT_ID]: { route: BusterAppRoutes.APP_CHAT_ID; chatId: string };
[BusterAppRoutes.APP_CHAT_ID_QUERY]: {
route: BusterAppRoutes.APP_CHAT_ID_QUERY;
chatId: string;
metricId?: string;
dashboardId?: string;
messageId?: string;
};
[BusterAppRoutes.APP_CHAT_ID_REASONING_ID]: {
route: BusterAppRoutes.APP_CHAT_ID_REASONING_ID;
chatId: string;

View File

@ -28,41 +28,6 @@ describe('createBusterRoute', () => {
const result = createBusterRoute(input);
expect(result).toBe('/app/settings/permission-groups/group123/datasets');
});
test('should handle query parameters in route', () => {
// Test with all query parameters
const input = {
route: BusterAppRoutes.APP_CHAT_ID_QUERY,
chatId: '123',
metricId: 'metric456',
dashboardId: 'dash789',
messageId: 'reason101'
} as const;
const result = createBusterRoute(input);
expect(result).toBe(
'/app/chats/123?metricId=metric456&dashboardId=dash789&messageId=reason101'
);
// Test with some undefined parameters
const partialInput: any = {
route: BusterAppRoutes.APP_CHAT_ID_QUERY,
chatId: '123',
metricId: 'metric456',
dashboardId: undefined,
reasoningId: null,
yourMom: 'yourMom'
};
const result2 = createBusterRoute(partialInput);
expect(result2).toBe('/app/chats/123?metricId=metric456');
// Test with all query parameters undefined
const minimalInput: any = {
route: BusterAppRoutes.APP_CHAT_ID_QUERY,
chatId: '123'
};
const result3 = createBusterRoute(minimalInput);
expect(result3).toBe('/app/chats/123');
});
});
describe('createPathnameToBusterRoute', () => {
@ -84,18 +49,6 @@ describe('createPathnameToBusterRoute', () => {
expect(result).toEqual(BusterSettingsRoutes.SETTINGS_PERMISSION_GROUPS_ID_DATASETS);
});
test('should convert chat route with query parameters', () => {
const pathname = '/app/chats/123?metricId=metric456&dashboardId=dash789&messageId=msg101';
const result = createPathnameToBusterRoute(pathname);
expect(result).toEqual(BusterAppRoutes.APP_CHAT_ID_QUERY);
});
test('should handle partial query parameters', () => {
const pathname = '/app/chats/123?metricId=metric456';
const result = createPathnameToBusterRoute(pathname);
expect(result).toEqual(BusterAppRoutes.APP_CHAT_ID_QUERY);
});
test('should convert dataset route with ID', () => {
const pathname = '/app/datasets/dataset123';
const result = createPathnameToBusterRoute(pathname);