mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-05 17:53:12 +02:00
fix: add additional test case
This commit is contained in:
parent
58932ddd17
commit
844d6e0f44
@ -94,7 +94,7 @@ test('should return raw metrics, aggregated on key', async () => {
|
||||
expect(t2.data[0].no).toBe(104);
|
||||
});
|
||||
|
||||
test('should toggle summary', async () => {
|
||||
test('should return toggle summary', async () => {
|
||||
const date = new Date();
|
||||
const metrics: IClientMetricsEnv[] = [
|
||||
{
|
||||
@ -164,3 +164,68 @@ test('should toggle summary', async () => {
|
||||
expect(demo.lastHourUsage[1].no).toBe(6);
|
||||
expect(demo.seenApplications).toStrictEqual(['backend-api', 'web']);
|
||||
});
|
||||
|
||||
test('should only include last hour of metrics return toggle summary', async () => {
|
||||
const date = new Date();
|
||||
const dateHoneHourAgo = new Date();
|
||||
dateHoneHourAgo.setHours(-1);
|
||||
const metrics: IClientMetricsEnv[] = [
|
||||
{
|
||||
featureName: 'demo',
|
||||
appName: 'web',
|
||||
environment: 'default',
|
||||
timestamp: date,
|
||||
yes: 2,
|
||||
no: 2,
|
||||
},
|
||||
{
|
||||
featureName: 'demo',
|
||||
appName: 'web',
|
||||
environment: 'default',
|
||||
timestamp: date,
|
||||
yes: 3,
|
||||
no: 2,
|
||||
},
|
||||
{
|
||||
featureName: 'demo',
|
||||
appName: 'web',
|
||||
environment: 'test',
|
||||
timestamp: date,
|
||||
yes: 1,
|
||||
no: 3,
|
||||
},
|
||||
{
|
||||
featureName: 'demo',
|
||||
appName: 'backend-api',
|
||||
environment: 'test',
|
||||
timestamp: date,
|
||||
yes: 1,
|
||||
no: 3,
|
||||
},
|
||||
{
|
||||
featureName: 'demo',
|
||||
appName: 'backend-api',
|
||||
environment: 'test',
|
||||
timestamp: dateHoneHourAgo,
|
||||
yes: 55,
|
||||
no: 55,
|
||||
},
|
||||
];
|
||||
|
||||
await db.stores.clientMetricsStoreV2.batchInsertMetrics(metrics);
|
||||
|
||||
const { body: demo } = await app.request
|
||||
.get('/api/admin/client-metrics/features/demo')
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200);
|
||||
|
||||
expect(demo.featureName).toBe('demo');
|
||||
expect(demo.lastHourUsage).toHaveLength(2);
|
||||
expect(demo.lastHourUsage[0].environment).toBe('default');
|
||||
expect(demo.lastHourUsage[0].yes).toBe(5);
|
||||
expect(demo.lastHourUsage[0].no).toBe(4);
|
||||
expect(demo.lastHourUsage[1].environment).toBe('test');
|
||||
expect(demo.lastHourUsage[1].yes).toBe(2);
|
||||
expect(demo.lastHourUsage[1].no).toBe(6);
|
||||
expect(demo.seenApplications).toStrictEqual(['backend-api', 'web']);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user