mirror of
https://github.com/Unleash/unleash.git
synced 2025-08-27 13:49:10 +02:00
parent
42e68734c8
commit
9ceb88ca0e
@ -2,7 +2,7 @@ import { SelectProjectInput } from './SelectProjectInput/SelectProjectInput';
|
||||
import { TokenType } from '../../../../../interfaces/token';
|
||||
import React from 'react';
|
||||
import { StyledInputDescription } from '../ApiTokenForm.styles';
|
||||
import useProjects from '../../../../../hooks/api/getters/useProjects/useProjects';
|
||||
import useProjects from 'hooks/api/getters/useProjects/useProjects';
|
||||
import { ApiTokenFormErrorType } from '../useApiTokenForm';
|
||||
import { useOptionalPathParam } from '../../../../../hooks/useOptionalPathParam';
|
||||
|
||||
|
@ -108,3 +108,54 @@ test('collapseHourlyMetrics', () => {
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
test('collapseHourlyMetrics variants', () => {
|
||||
const timestamp = startOfHour(new Date());
|
||||
|
||||
const metricsWithoutVariant: IClientMetricsEnv = {
|
||||
featureName: 'a',
|
||||
appName: 'x',
|
||||
environment: 'x',
|
||||
timestamp: addMinutes(timestamp, 1),
|
||||
yes: 1,
|
||||
no: 11,
|
||||
};
|
||||
|
||||
const metricsWithVariant1: IClientMetricsEnv = {
|
||||
featureName: 'a',
|
||||
appName: 'x',
|
||||
environment: 'x',
|
||||
timestamp: addMinutes(timestamp, 2),
|
||||
yes: 2,
|
||||
no: 12,
|
||||
variants: { disabled: 3, red: 2 },
|
||||
};
|
||||
|
||||
const metricsWithVariant2: IClientMetricsEnv = {
|
||||
featureName: 'a',
|
||||
appName: 'x',
|
||||
environment: 'x',
|
||||
timestamp: addMinutes(timestamp, 2),
|
||||
yes: 2,
|
||||
no: 12,
|
||||
variants: { disabled: 1, red: 3 },
|
||||
};
|
||||
|
||||
expect(
|
||||
collapseHourlyMetrics([
|
||||
metricsWithoutVariant,
|
||||
metricsWithVariant1,
|
||||
metricsWithVariant2,
|
||||
]),
|
||||
).toEqual([
|
||||
{
|
||||
featureName: 'a',
|
||||
appName: 'x',
|
||||
environment: 'x',
|
||||
timestamp,
|
||||
yes: 5,
|
||||
no: 35,
|
||||
variants: { disabled: 4, red: 5 },
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
@ -51,7 +51,7 @@ export const collapseHourlyMetrics = (
|
||||
if (metric.variants) {
|
||||
grouped[key].variants = mergeRecords(
|
||||
metric.variants,
|
||||
grouped[key].variants,
|
||||
grouped[key].variants ?? {},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user