Skip to content

Commit

Permalink
filtering groups in class admin overview only with group type class
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinSchuhmacher committed Nov 6, 2024
1 parent afcb384 commit fcc50ea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
16 changes: 11 additions & 5 deletions apps/server/src/modules/group/uc/class-group.uc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
userFactory,
} from '@shared/testing';
import { ClassRequestContext, SchoolYearQueryType } from '../controller/dto/interface';
import { Group, GroupFilter } from '../domain';
import { Group, GroupFilter, GroupTypes } from '../domain';
import { UnknownQueryTypeLoggableException } from '../loggable';
import { GroupService } from '../service';
import { ClassInfoDto } from './dto';
Expand Down Expand Up @@ -407,12 +407,15 @@ describe('ClassGroupUc', () => {
});
});

it('should call group service with userId and no pagination', async () => {
it('should call group service with userId, group type class and no pagination', async () => {
const { teacherUser } = setup();

await uc.findAllClasses(teacherUser.id, teacherUser.school.id);

expect(groupService.findGroups).toHaveBeenCalledWith<[GroupFilter]>({ userId: teacherUser.id });
expect(groupService.findGroups).toHaveBeenCalledWith<[GroupFilter]>({
userId: teacherUser.id,
groupTypes: [GroupTypes.CLASS],
});
});
});

Expand Down Expand Up @@ -767,12 +770,15 @@ describe('ClassGroupUc', () => {
});
});

it('should call group service with schoolId and no pagination', async () => {
it('should call group service with schoolId, group type class and no pagination', async () => {
const { teacherUser } = setup();

await uc.findAllClasses(teacherUser.id, teacherUser.school.id);

expect(groupService.findGroups).toHaveBeenCalledWith<[GroupFilter]>({ schoolId: teacherUser.school.id });
expect(groupService.findGroups).toHaveBeenCalledWith<[GroupFilter]>({
schoolId: teacherUser.school.id,
groupTypes: [GroupTypes.CLASS],
});
});
});

Expand Down
6 changes: 3 additions & 3 deletions apps/server/src/modules/group/uc/class-group.uc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Pagination, Permission, SortOrder } from '@shared/domain/interface';
import { EntityId } from '@shared/domain/types';
import { System, SystemService } from '@src/modules/system';
import { ClassRequestContext, SchoolYearQueryType } from '../controller/dto/interface';
import { Group, GroupFilter } from '../domain';
import { Group, GroupFilter, GroupTypes } from '../domain';
import { UnknownQueryTypeLoggableException } from '../loggable';
import { GroupService } from '../service';
import { ClassInfoDto, ResolvedGroupUser } from './dto';
Expand Down Expand Up @@ -217,7 +217,7 @@ export class ClassGroupUc {
}

private async findGroupsForSchool(schoolId: EntityId): Promise<ClassInfoDto[]> {
const filter: GroupFilter = { schoolId };
const filter: GroupFilter = { schoolId, groupTypes: [GroupTypes.CLASS] };

const groups: Page<Group> = await this.groupService.findGroups(filter);

Expand All @@ -227,7 +227,7 @@ export class ClassGroupUc {
}

private async findGroupsForUser(userId: EntityId): Promise<ClassInfoDto[]> {
const filter: GroupFilter = { userId };
const filter: GroupFilter = { userId, groupTypes: [GroupTypes.CLASS] };

const groups: Page<Group> = await this.groupService.findGroups(filter);

Expand Down

0 comments on commit fcc50ea

Please sign in to comment.