diff --git a/src/pages/administration/ClassOverview.page.unit.ts b/src/pages/administration/ClassOverview.page.unit.ts index 2ee0c1e986..5b9a24a22c 100644 --- a/src/pages/administration/ClassOverview.page.unit.ts +++ b/src/pages/administration/ClassOverview.page.unit.ts @@ -1,6 +1,6 @@ import GroupModule from "@/store/group"; import { createModuleMocks } from "@/utils/mock-store-module"; -import { classInfoResponseFactory, i18nMock } from "@@/tests/test-utils"; +import { classInfoFactory, i18nMock } from "@@/tests/test-utils"; import { MountOptions, Wrapper, mount } from "@vue/test-utils"; import ClassOverview from "./ClassOverview.page.vue"; import { GROUP_MODULE_KEY, I18N_KEY } from "@/utils/inject"; @@ -14,7 +14,7 @@ describe("ClassOverview", () => { document.body.setAttribute("data-app", "true"); const groupModule = createModuleMocks(GroupModule, { - getClasses: [classInfoResponseFactory.build()], + getClasses: [classInfoFactory.build()], getPagination: { limit: 10, skip: 0, diff --git a/src/serverApi/v3/api.ts b/src/serverApi/v3/api.ts index 1c90b03ca0..9eb2f0fcf6 100644 --- a/src/serverApi/v3/api.ts +++ b/src/serverApi/v3/api.ts @@ -365,6 +365,18 @@ export enum ChangeLanguageParamsLanguageEnum { * @interface ClassInfoResponse */ export interface ClassInfoResponse { + /** + * + * @type {string} + * @memberof ClassInfoResponse + */ + id: string; + /** + * + * @type {string} + * @memberof ClassInfoResponse + */ + type: ClassInfoResponseTypeEnum; /** * * @type {string} @@ -383,7 +395,23 @@ export interface ClassInfoResponse { * @memberof ClassInfoResponse */ teachers: Array; + /** + * + * @type {string} + * @memberof ClassInfoResponse + */ + schoolYear?: string; } + +/** + * @export + * @enum {string} + */ +export enum ClassInfoResponseTypeEnum { + Class = 'class', + Group = 'group' +} + /** * * @export diff --git a/src/store/group.unit.ts b/src/store/group.unit.ts index 16ec637a3c..074411b43b 100644 --- a/src/store/group.unit.ts +++ b/src/store/group.unit.ts @@ -10,11 +10,11 @@ import { classInfoResponseFactory, classInfoSearchListResponseFactory, } from "@@/tests/test-utils"; -import { ClassInfo } from "./types/class-info"; +import { ClassInfo, ClassRootType } from "./types/class-info"; import { BusinessError, Pagination } from "./types/commons"; import { SortOrder } from "./types/sort-order.enum"; import GroupModule from "./group"; -import { DeepMocked, createMock } from "@golevelup/ts-jest"; +import { createMock, DeepMocked } from "@golevelup/ts-jest"; import { mockApiResponse } from "@@/tests/test-utils/mockApiResponse"; import { mapAxiosErrorToResponseError } from "@/utils/api"; @@ -86,7 +86,13 @@ describe("GroupModule", () => { it("should return the changed state", () => { const classes: ClassInfo[] = [ - { name: "3a", externalSourceName: "Klasse", teachers: ["Carlie"] }, + { + name: "3a", + externalSourceName: "Klasse", + teachers: ["Carlie"], + type: ClassRootType.Class, + id: "id", + }, ]; module.setClasses(classes); diff --git a/src/store/group/group.mapper.ts b/src/store/group/group.mapper.ts index 5649b10a3b..8335273cfd 100644 --- a/src/store/group/group.mapper.ts +++ b/src/store/group/group.mapper.ts @@ -1,5 +1,13 @@ -import { ClassInfoResponse } from "@/serverApi/v3"; -import { ClassInfo } from "../types/class-info"; +import { ClassInfoResponse, ClassInfoResponseTypeEnum } from "@/serverApi/v3"; +import { ClassInfo, ClassRootType } from "../types/class-info"; + +export const ClassRootTypeMapping: Record< + ClassInfoResponseTypeEnum, + ClassRootType +> = { + [ClassInfoResponseTypeEnum.Class]: ClassRootType.Class, + [ClassInfoResponseTypeEnum.Group]: ClassRootType.Group, +}; export class GroupMapper { static mapToClassInfo(response: ClassInfoResponse[]): ClassInfo[] { @@ -8,6 +16,8 @@ export class GroupMapper { name: classInfoResponse.name, externalSourceName: classInfoResponse.externalSourceName, teachers: classInfoResponse.teachers, + type: ClassRootTypeMapping[classInfoResponse.type], + id: classInfoResponse.id, }) ); diff --git a/src/store/types/class-info.ts b/src/store/types/class-info.ts index cf4fd99f00..22080dd13a 100644 --- a/src/store/types/class-info.ts +++ b/src/store/types/class-info.ts @@ -2,4 +2,11 @@ export type ClassInfo = { name: string; externalSourceName?: string; teachers: string[]; + type: ClassRootType; + id: string; }; + +export enum ClassRootType { + Class = "class", + Group = "group", +} diff --git a/tests/test-utils/factory/classInfoFactory.ts b/tests/test-utils/factory/classInfoFactory.ts new file mode 100644 index 0000000000..adbaf1b509 --- /dev/null +++ b/tests/test-utils/factory/classInfoFactory.ts @@ -0,0 +1,10 @@ +import { Factory } from "fishery"; +import { ClassInfo, ClassRootType } from "@/store/types/class-info"; + +export const classInfoFactory = Factory.define(({ sequence }) => ({ + name: `className${sequence}`, + externalSourceName: "Source", + teachers: ["TestTeacher"], + type: ClassRootType.Class, + id: `id-${sequence}`, +})); diff --git a/tests/test-utils/factory/classInfoResponseFactory.ts b/tests/test-utils/factory/classInfoResponseFactory.ts index 97183c1ad9..5a18efe7e8 100644 --- a/tests/test-utils/factory/classInfoResponseFactory.ts +++ b/tests/test-utils/factory/classInfoResponseFactory.ts @@ -1,10 +1,12 @@ -import { ClassInfoResponse } from "@/serverApi/v3"; +import { ClassInfoResponse, ClassInfoResponseTypeEnum } from "@/serverApi/v3"; import { Factory } from "fishery"; export const classInfoResponseFactory = Factory.define( - () => ({ - name: "className", + ({ sequence }) => ({ + name: `className${sequence}`, externalSourceName: "Source", teachers: ["TestTeacher"], + type: ClassInfoResponseTypeEnum.Class, + id: `id-${sequence}`, }) ); diff --git a/tests/test-utils/factory/index.ts b/tests/test-utils/factory/index.ts index 94f3919fbe..ee4a7ab727 100644 --- a/tests/test-utils/factory/index.ts +++ b/tests/test-utils/factory/index.ts @@ -7,6 +7,7 @@ export * from "./businessErrorFactory"; export * from "./cardSkeletonResponseFactory"; export * from "./classInfoSearchListResponseFactory"; export * from "./classInfoResponseFactory"; +export * from "./classInfoFactory"; export * from "./columnResponseFactory"; export * from "./contextExternalToolConfigurationTemplate.factory"; export * from "./contextExternalToolConfigurationTemplateResponseFactory";