mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
feat(editor): Evaluations frontend (no-changelog) (#15550)
Co-authored-by: Yiorgis Gozadinos <yiorgis@n8n.io> Co-authored-by: JP van Oosten <jp@n8n.io> Co-authored-by: Giulio Andreini <g.andreini@gmail.com> Co-authored-by: Michael Kret <michael.k@radency.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { WorkflowRepository } from '@n8n/db';
|
||||
import { Container } from '@n8n/di';
|
||||
|
||||
import { createTestRun } from '../../shared/db/evaluation';
|
||||
import {
|
||||
createWorkflowWithTrigger,
|
||||
createWorkflow,
|
||||
@@ -115,4 +116,73 @@ describe('WorkflowRepository', () => {
|
||||
expect(activeIds).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getWorkflowsWithEvaluationCount', () => {
|
||||
it('should return 0 when no workflows have test runs', async () => {
|
||||
//
|
||||
// ARRANGE
|
||||
//
|
||||
const workflowRepository = Container.get(WorkflowRepository);
|
||||
await createWorkflow();
|
||||
await createWorkflow();
|
||||
|
||||
//
|
||||
// ACT
|
||||
//
|
||||
const count = await workflowRepository.getWorkflowsWithEvaluationCount();
|
||||
|
||||
//
|
||||
// ASSERT
|
||||
//
|
||||
expect(count).toBe(0);
|
||||
});
|
||||
|
||||
it('should return correct count when some workflows have test runs', async () => {
|
||||
//
|
||||
// ARRANGE
|
||||
//
|
||||
const workflowRepository = Container.get(WorkflowRepository);
|
||||
const workflow1 = await createWorkflow();
|
||||
await createWorkflow();
|
||||
const workflow3 = await createWorkflow();
|
||||
|
||||
await createTestRun(workflow1.id);
|
||||
await createTestRun(workflow3.id);
|
||||
|
||||
//
|
||||
// ACT
|
||||
//
|
||||
const count = await workflowRepository.getWorkflowsWithEvaluationCount();
|
||||
|
||||
//
|
||||
// ASSERT
|
||||
//
|
||||
expect(count).toBe(2);
|
||||
});
|
||||
|
||||
it('should count each workflow only once even with multiple test runs', async () => {
|
||||
//
|
||||
// ARRANGE
|
||||
//
|
||||
const workflowRepository = Container.get(WorkflowRepository);
|
||||
const workflow1 = await createWorkflow();
|
||||
const workflow2 = await createWorkflow();
|
||||
|
||||
await createTestRun(workflow1.id);
|
||||
await createTestRun(workflow1.id);
|
||||
await createTestRun(workflow1.id);
|
||||
await createTestRun(workflow2.id);
|
||||
await createTestRun(workflow2.id);
|
||||
|
||||
//
|
||||
// ACT
|
||||
//
|
||||
const count = await workflowRepository.getWorkflowsWithEvaluationCount();
|
||||
|
||||
//
|
||||
// ASSERT
|
||||
//
|
||||
expect(count).toBe(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -83,6 +83,7 @@ describe('LicenseMetricsRepository', () => {
|
||||
productionExecutions: 3,
|
||||
productionRootExecutions: 3,
|
||||
manualExecutions: 2,
|
||||
evaluations: 0,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -100,6 +101,7 @@ describe('LicenseMetricsRepository', () => {
|
||||
productionExecutions: 0, // not NaN
|
||||
productionRootExecutions: 0, // not NaN
|
||||
manualExecutions: 0, // not NaN
|
||||
evaluations: 0,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -119,6 +119,10 @@ const DEFAULT_LICENSE_RESPONSE: { data: ILicenseReadResponse } = {
|
||||
limit: -1,
|
||||
warningThreshold: 0.8,
|
||||
},
|
||||
workflowsHavingEvaluations: {
|
||||
value: 0,
|
||||
limit: 0,
|
||||
},
|
||||
},
|
||||
license: {
|
||||
planId: '',
|
||||
@@ -135,6 +139,10 @@ const DEFAULT_POST_RESPONSE: { data: ILicensePostResponse } = {
|
||||
limit: -1,
|
||||
warningThreshold: 0.8,
|
||||
},
|
||||
workflowsHavingEvaluations: {
|
||||
value: 0,
|
||||
limit: 0,
|
||||
},
|
||||
},
|
||||
license: {
|
||||
planId: '',
|
||||
|
||||
Reference in New Issue
Block a user