mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-13 16:14:07 -08:00
wip: add description to test-definitions API
This commit is contained in:
parent
75970bffdd
commit
d2798f07cc
|
@ -35,6 +35,9 @@ export class TestDefinition extends WithTimestamps {
|
|||
})
|
||||
name: string;
|
||||
|
||||
@Column('text')
|
||||
description: string;
|
||||
|
||||
/**
|
||||
* Relation to the workflow under test
|
||||
*/
|
||||
|
|
|
@ -4,13 +4,16 @@ export const testDefinitionCreateRequestBodySchema = z
|
|||
.object({
|
||||
name: z.string().min(1).max(255),
|
||||
workflowId: z.string().min(1),
|
||||
description: z.string().optional(),
|
||||
evaluationWorkflowId: z.string().min(1).optional(),
|
||||
annotationTagId: z.string().min(1).optional(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
export const testDefinitionPatchRequestBodySchema = z
|
||||
.object({
|
||||
name: z.string().min(1).max(255).optional(),
|
||||
description: z.string().optional(),
|
||||
evaluationWorkflowId: z.string().min(1).optional(),
|
||||
annotationTagId: z.string().min(1).optional(),
|
||||
})
|
||||
|
|
|
@ -26,6 +26,7 @@ export class TestDefinitionService {
|
|||
|
||||
private toEntityLike(attrs: {
|
||||
name?: string;
|
||||
description?: string;
|
||||
workflowId?: string;
|
||||
evaluationWorkflowId?: string;
|
||||
annotationTagId?: string;
|
||||
|
@ -41,6 +42,10 @@ export class TestDefinitionService {
|
|||
entity.name = attrs.name?.trim();
|
||||
}
|
||||
|
||||
if (attrs.description) {
|
||||
entity.description = attrs.description.trim();
|
||||
}
|
||||
|
||||
if (attrs.workflowId) {
|
||||
entity.workflow = {
|
||||
id: attrs.workflowId,
|
||||
|
|
|
@ -163,9 +163,36 @@ describe('POST /evaluation/test-definitions', () => {
|
|||
});
|
||||
|
||||
expect(resp.statusCode).toBe(200);
|
||||
expect(resp.body.data.name).toBe('test');
|
||||
expect(resp.body.data.workflowId).toBe(workflowUnderTest.id);
|
||||
expect(resp.body.data.evaluationWorkflowId).toBe(evaluationWorkflow.id);
|
||||
expect(resp.body.data).toEqual(
|
||||
expect.objectContaining({
|
||||
name: 'test',
|
||||
workflowId: workflowUnderTest.id,
|
||||
evaluationWorkflowId: evaluationWorkflow.id,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
test('should create test definition with all fields', async () => {
|
||||
const resp = await authOwnerAgent.post('/evaluation/test-definitions').send({
|
||||
name: 'test',
|
||||
description: 'test description',
|
||||
workflowId: workflowUnderTest.id,
|
||||
evaluationWorkflowId: evaluationWorkflow.id,
|
||||
annotationTagId: annotationTag.id,
|
||||
});
|
||||
|
||||
expect(resp.statusCode).toBe(200);
|
||||
expect(resp.body.data).toEqual(
|
||||
expect.objectContaining({
|
||||
name: 'test',
|
||||
description: 'test description',
|
||||
workflowId: workflowUnderTest.id,
|
||||
evaluationWorkflowId: evaluationWorkflow.id,
|
||||
annotationTag: expect.objectContaining({
|
||||
id: annotationTag.id,
|
||||
}),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
test('should return error if name is empty', async () => {
|
||||
|
|
Loading…
Reference in a new issue