Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2573,6 +2573,66 @@ describe('External API v2 Dashboards - new format', () => {
);
});

it('persists where as empty string when omitted from heatmap tile', async () => {
const heatmapNoWhere = {
name: 'Heatmap Without Where',
x: 0,
y: 0,
w: 6,
h: 3,
config: {
displayType: 'heatmap',
sourceId: traceSource._id.toString(),
select: [{ valueExpression: 'Duration' }],
},
};

const response = await authRequest('post', BASE_URL)
.send({
name: 'Dashboard Heatmap No Where',
tiles: [heatmapNoWhere],
tags: [],
})
.expect(200);

const dashboardInDb = await Dashboard.findById(
response.body.data.id,
).lean();

expect((dashboardInDb!.tiles[0].config as any).where).toBe('');
});

it('persists select-item where as empty string when omitted', async () => {
const lineChartNoWhere = {
name: 'Line Chart Without Where',
x: 0,
y: 0,
w: 6,
h: 3,
config: {
displayType: 'line',
sourceId: traceSource._id.toString(),
select: [{ aggFn: 'count' }],
},
};

const response = await authRequest('post', BASE_URL)
.send({
name: 'Dashboard Line No Where',
tiles: [lineChartNoWhere],
tags: [],
})
.expect(200);

const dashboardInDb = await Dashboard.findById(
response.body.data.id,
).lean();

expect(
(dashboardInDb!.tiles[0].config as any).select[0].aggCondition,
).toBe('');
});

it('does not silently downgrade a corrupted heatmap to line on GET', async () => {
// Seed a Dashboard directly via Mongo with a heatmap tile whose
// select[0] lacks a non-empty valueExpression. The current API
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/routers/external-api/v2/dashboards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { z } from 'zod';

import { deleteDashboard } from '@/controllers/dashboard';
import Dashboard, { IDashboard } from '@/models/dashboard';
import { validateRequestWithEnhancedErrors as validateRequest } from '@/utils/enhancedErrors';
import { processRequestWithEnhancedErrors as validateRequest } from '@/utils/enhancedErrors';
import { ExternalDashboardTileWithId, objectIdSchema } from '@/utils/zod';

import {
Expand Down
Loading