mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-14 08:34:07 -08:00
Enhance test definition creation and editing with description support
• Add description to test definition interface • Include description in create/update params • Update UI to handle description field • Refactor types for better consistency • Add data-test-id for E2E testing
This commit is contained in:
parent
cdd3d84484
commit
9b5be7a691
|
@ -10,20 +10,17 @@ export interface ITestDefinitionBase {
|
|||
annotationTagId?: string;
|
||||
}
|
||||
|
||||
// Complete test definition with ID
|
||||
export interface ITestDefinition extends ITestDefinitionBase {
|
||||
id: number;
|
||||
}
|
||||
|
||||
// Create params - requires name and workflowId, optional evaluationWorkflowId
|
||||
export type CreateTestDefinitionParams = Pick<ITestDefinitionBase, 'name' | 'workflowId'> &
|
||||
Partial<Pick<ITestDefinitionBase, 'evaluationWorkflowId'>>;
|
||||
|
||||
// All fields optional except ID
|
||||
export type UpdateTestDefinitionParams = Partial<
|
||||
Pick<ITestDefinitionBase, 'name' | 'evaluationWorkflowId' | 'annotationTagId'>
|
||||
export type CreateTestDefinitionParams = Pick<
|
||||
ITestDefinitionBase,
|
||||
'name' | 'workflowId' | 'description' | 'evaluationWorkflowId'
|
||||
>;
|
||||
|
||||
export type UpdateTestDefinitionParams = Partial<ITestDefinitionBase>;
|
||||
|
||||
// Query options type
|
||||
export interface ITestDefinitionsQueryOptions {
|
||||
includeScopes?: boolean;
|
||||
|
@ -58,18 +55,15 @@ export function createTestDefinitionsApi(): ITestDefinitionsApi {
|
|||
getTestDefinitions: async (
|
||||
context: IRestApiContext,
|
||||
options?: ITestDefinitionsQueryOptions,
|
||||
): Promise<ITestDefinition[]> => {
|
||||
) => {
|
||||
return await makeRestApiRequest(context, 'GET', endpoint, options);
|
||||
},
|
||||
|
||||
getTestDefinition: async (context: IRestApiContext, id: number): Promise<ITestDefinition> => {
|
||||
getTestDefinition: async (context: IRestApiContext, id: number) => {
|
||||
return await makeRestApiRequest(context, 'GET', `${endpoint}/${id}`);
|
||||
},
|
||||
|
||||
createTestDefinition: async (
|
||||
context: IRestApiContext,
|
||||
params: CreateTestDefinitionParams,
|
||||
): Promise<ITestDefinition> => {
|
||||
createTestDefinition: async (context: IRestApiContext, params: CreateTestDefinitionParams) => {
|
||||
return await makeRestApiRequest(context, 'POST', endpoint, params);
|
||||
},
|
||||
|
||||
|
@ -77,14 +71,11 @@ export function createTestDefinitionsApi(): ITestDefinitionsApi {
|
|||
context: IRestApiContext,
|
||||
id: number,
|
||||
params: UpdateTestDefinitionParams,
|
||||
): Promise<ITestDefinition> => {
|
||||
) => {
|
||||
return await makeRestApiRequest(context, 'PATCH', `${endpoint}/${id}`, params);
|
||||
},
|
||||
|
||||
deleteTestDefinition: async (
|
||||
context: IRestApiContext,
|
||||
id: number,
|
||||
): Promise<{ success: boolean }> => {
|
||||
deleteTestDefinition: async (context: IRestApiContext, id: number) => {
|
||||
return await makeRestApiRequest(context, 'DELETE', `${endpoint}/${id}`);
|
||||
},
|
||||
};
|
||||
|
|
|
@ -42,13 +42,18 @@ function updateTags(tags: string[]) {
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<div :class="$style.formGroup">
|
||||
<div :class="$style.formGroup" data-test-id="workflow-tags-field">
|
||||
<n8n-input-label label="Tag name" :bold="false" size="small">
|
||||
<div v-if="!modelValue.isEditing" :class="$style.tagsRead" @click="startEditing('tags')">
|
||||
<n8n-text v-if="modelValue.appliedTagIds.length === 0" size="small">
|
||||
{{ locale.baseText('workflowEvaluation.edit.selectTag') }}
|
||||
</n8n-text>
|
||||
<n8n-tag v-for="tagId in modelValue.appliedTagIds" :key="tagId" :text="getTagName(tagId)" />
|
||||
<n8n-tag
|
||||
v-for="tagId in modelValue.appliedTagIds"
|
||||
:key="tagId"
|
||||
:text="getTagName(tagId)"
|
||||
data-test-id="evaluation-tag-field"
|
||||
/>
|
||||
<n8n-icon-button
|
||||
:class="$style.editInputButton"
|
||||
icon="pen"
|
||||
|
|
|
@ -69,7 +69,7 @@ export function useEvaluationForm() {
|
|||
|
||||
if (testDefinition) {
|
||||
state.value = {
|
||||
description: '',
|
||||
description: testDefinition.description ?? '',
|
||||
name: {
|
||||
value: testDefinition.name,
|
||||
isEditing: false,
|
||||
|
@ -113,6 +113,7 @@ export function useEvaluationForm() {
|
|||
// Prepare the base parameters for creating or updating a test
|
||||
const params: Record<string, string> = {
|
||||
name: state.value.name.value,
|
||||
description: state.value.description,
|
||||
};
|
||||
|
||||
// Add annotation tag ID only for PATH requests
|
||||
|
|
|
@ -95,6 +95,7 @@ export const useEvaluationsStore = defineStore(
|
|||
name: string;
|
||||
workflowId: string;
|
||||
evaluationWorkflowId?: string;
|
||||
description?: string;
|
||||
}) => {
|
||||
const createdDefinition = await testDefinitionsApi.createTestDefinition(
|
||||
rootStore.restApiContext,
|
||||
|
@ -107,6 +108,7 @@ export const useEvaluationsStore = defineStore(
|
|||
const update = async (params: {
|
||||
id: number;
|
||||
name?: string;
|
||||
description?: string;
|
||||
evaluationWorkflowId?: string;
|
||||
annotationTagId?: string;
|
||||
}) => {
|
||||
|
|
Loading…
Reference in a new issue