mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-05 17:53:12 +02:00
fix: add env metrics
This commit is contained in:
parent
7a91c5aaa1
commit
30c7e6f78e
@ -6,13 +6,14 @@ import { createTestConfig } from '../../../test/config/test-config';
|
||||
import { clientMetricsSchema } from '../../services/client-metrics/client-metrics-schema';
|
||||
import { createServices } from '../../services';
|
||||
import { IUnleashStores } from '../../types';
|
||||
import { IUnleashOptions } from '../../server-impl';
|
||||
|
||||
const eventBus = new EventEmitter();
|
||||
|
||||
function getSetup() {
|
||||
function getSetup(opts?: IUnleashOptions) {
|
||||
const stores = createStores();
|
||||
|
||||
const config = createTestConfig();
|
||||
const config = createTestConfig(opts);
|
||||
const services = createServices(stores, config);
|
||||
const app = getApp(config, stores, services, eventBus);
|
||||
|
||||
@ -84,6 +85,31 @@ test('should accept client metrics with yes/no', () => {
|
||||
.expect(202);
|
||||
});
|
||||
|
||||
test('should accept client metrics with yes/no with metricsV2', async () => {
|
||||
const testRunner = getSetup({
|
||||
experimental: { metricsV2: { enabled: true } },
|
||||
});
|
||||
await testRunner.request
|
||||
.post('/api/client/metrics')
|
||||
.send({
|
||||
appName: 'demo',
|
||||
instanceId: '1',
|
||||
bucket: {
|
||||
start: Date.now(),
|
||||
stop: Date.now(),
|
||||
toggles: {
|
||||
toggleA: {
|
||||
yes: 200,
|
||||
no: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
.expect(202);
|
||||
|
||||
testRunner.destroy();
|
||||
});
|
||||
|
||||
test('should accept client metrics with variants', () => {
|
||||
return request
|
||||
.post('/api/client/metrics')
|
||||
|
@ -12,7 +12,7 @@ export default class FakeClientMetricsStoreV2
|
||||
extends EventEmitter
|
||||
implements IClientMetricsStoreV2
|
||||
{
|
||||
metrics: IClientMetric[] = [];
|
||||
metrics: IClientMetricsEnv[] = [];
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
@ -31,7 +31,8 @@ export default class FakeClientMetricsStoreV2
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
batchInsertMetrics(metrics: IClientMetricsEnv[]): Promise<void> {
|
||||
throw new Error('Method not implemented.');
|
||||
metrics.forEach((m) => this.metrics.push(m));
|
||||
return Promise.resolve();
|
||||
}
|
||||
get(key: IClientMetricsEnvKey): Promise<IClientMetricsEnv> {
|
||||
throw new Error('Method not implemented.');
|
||||
|
Loading…
Reference in New Issue
Block a user