mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
feat(core): Evaluations backend (no-changelog) (#15542)
Co-authored-by: Yiorgis Gozadinos <yiorgis@n8n.io> Co-authored-by: Mutasem Aldmour <4711238+mutdmour@users.noreply.github.com>
This commit is contained in:
66
packages/cli/test/integration/test-run.repository.ee.test.ts
Normal file
66
packages/cli/test/integration/test-run.repository.ee.test.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
import { TestRunRepository } from '@n8n/db';
|
||||
import type { IWorkflowDb, WorkflowEntity } from '@n8n/db';
|
||||
import { Container } from '@n8n/di';
|
||||
|
||||
import { createTestCaseExecution, createTestRun } from '@test-integration/db/evaluation';
|
||||
|
||||
import { createWorkflow } from './shared/db/workflows';
|
||||
import * as testDb from './shared/test-db';
|
||||
|
||||
describe('TestRunRepository', () => {
|
||||
let testRunRepository: TestRunRepository;
|
||||
|
||||
beforeAll(async () => {
|
||||
await testDb.init();
|
||||
|
||||
testRunRepository = Container.get(TestRunRepository);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await testDb.truncate(['User', 'WorkflowEntity', 'TestRun', 'TestCaseExecution']);
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await testDb.terminate();
|
||||
});
|
||||
|
||||
describe('getTestRunSummaryById', () => {
|
||||
let workflow: IWorkflowDb & WorkflowEntity;
|
||||
|
||||
beforeAll(async () => {
|
||||
workflow = await createWorkflow();
|
||||
});
|
||||
|
||||
it('should return the final result of a test run', async () => {
|
||||
const testRun = await createTestRun(workflow.id, {
|
||||
status: 'completed',
|
||||
runAt: new Date(),
|
||||
completedAt: new Date(),
|
||||
metrics: { total: 1, success: 1 },
|
||||
});
|
||||
|
||||
await Promise.all([
|
||||
createTestCaseExecution(testRun.id, {
|
||||
status: 'success',
|
||||
}),
|
||||
createTestCaseExecution(testRun.id, {
|
||||
status: 'success',
|
||||
}),
|
||||
]);
|
||||
|
||||
const result = await testRunRepository.getTestRunSummaryById(testRun.id);
|
||||
|
||||
expect(result).toEqual(
|
||||
expect.objectContaining({
|
||||
id: testRun.id,
|
||||
workflowId: workflow.id,
|
||||
status: 'completed',
|
||||
finalResult: 'success',
|
||||
runAt: expect.any(Date),
|
||||
completedAt: expect.any(Date),
|
||||
metrics: { total: 1, success: 1 },
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user