mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
feat: implement dynamic create DTO for Label
This commit is contained in:
24
api/src/utils/test/fixtures/label.ts
vendored
24
api/src/utils/test/fixtures/label.ts
vendored
@@ -8,13 +8,23 @@
|
||||
|
||||
import mongoose from 'mongoose';
|
||||
|
||||
import { LabelCreateDto } from '@/chat/dto/label.dto';
|
||||
import { Label, LabelModel } from '@/chat/schemas/label.schema';
|
||||
import { BaseSchema } from '@/utils/generics/base-schema';
|
||||
|
||||
import { getFixturesWithDefaultValues } from '../defaultValues';
|
||||
import { TFixturesDefaultValues } from '../types';
|
||||
|
||||
export const labels: LabelCreateDto[] = [
|
||||
export const fieldsWithDefaultValues = {
|
||||
builtin: false,
|
||||
} satisfies Partial<Label>;
|
||||
|
||||
type TFieldWithDefaultValues =
|
||||
| keyof typeof fieldsWithDefaultValues
|
||||
| keyof BaseSchema;
|
||||
type TTransformedField<T> = Omit<T, TFieldWithDefaultValues> &
|
||||
Partial<Pick<Label, TFieldWithDefaultValues>>;
|
||||
type TLabel = TTransformedField<Label>;
|
||||
|
||||
export const labels: TLabel[] = [
|
||||
{
|
||||
description: 'test description 1',
|
||||
label_id: {
|
||||
@@ -39,13 +49,9 @@ export const labels: LabelCreateDto[] = [
|
||||
},
|
||||
];
|
||||
|
||||
export const labelDefaultValues: TFixturesDefaultValues<Label> = {
|
||||
builtin: false,
|
||||
};
|
||||
|
||||
export const labelFixtures = getFixturesWithDefaultValues<Label>({
|
||||
export const labelFixtures = getFixturesWithDefaultValues<TLabel>({
|
||||
fixtures: labels,
|
||||
defaultValues: labelDefaultValues,
|
||||
defaultValues: fieldsWithDefaultValues,
|
||||
});
|
||||
|
||||
export const installLabelFixtures = async () => {
|
||||
|
||||
Reference in New Issue
Block a user