Skip to content
Open
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 @@ -166,6 +166,35 @@ describe('MetricDetectorTriggeredSection', () => {
expect(screen.getByRole('cell', {name: '150'})).toBeInTheDocument();
});

it('renders evaluated value correctly when value is an object (anomaly detector)', async () => {
const event = EventFixture({
occurrence: {
id: '1',
eventId: 'event-1',
fingerprint: ['fingerprint'],
issueTitle: 'Test Issue',
subtitle: 'Subtitle',
resourceId: 'resource-1',
evidenceData: {
conditions: [condition],
dataSources: [dataSource],
value: {value: 250},
},
evidenceDisplay: [],
type: 8001,
detectionTime: '2024-01-01T00:00:00Z',
},
});

render(<MetricDetectorTriggeredSection {...defaultProps} event={event} />);

expect(
await screen.findByRole('region', {name: 'Triggered Condition'})
).toBeInTheDocument();
expect(screen.getByRole('cell', {name: 'Evaluated Value'})).toBeInTheDocument();
expect(screen.getByRole('cell', {name: '250'})).toBeInTheDocument();
});

it('renders contributing issues section for errors dataset', async () => {
// Start date is eventDateCreated minus the timeWindow (60 seconds) minus 1 extra minute
const startDate = '2023-12-31T23:58:00.000Z';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ interface MetricDetectorEvidenceData {
/**
* The evaluated value when the occurrence was created
*/
value: number;
value:
| number
// XXX: Anomaly detectors will store an object here with other data necessary for processing
| {value: number};
}

interface MetricDetectorTriggeredSectionProps {
Expand Down Expand Up @@ -305,7 +308,7 @@ function TriggeredConditionDetails({
const isErrorsDataset = detectorDataset === DetectorDataset.ERRORS;
const issueSearchQuery = datasetConfig.toSnubaQueryString?.(snubaQuery) ?? '';
const formattedEvaluatedValue = getFormattedEvaluatedValue({
value,
value: defined(value) && typeof value === 'object' ? value.value : value,
aggregate: snubaQuery.aggregate,
detectionType,
});
Expand Down
Loading