diff --git a/apps/server/src/modules/room/api/dto/response/room-member-list.response.ts b/apps/server/src/modules/room/api/dto/response/room-member-list.response.ts new file mode 100644 index 0000000000..b474102953 --- /dev/null +++ b/apps/server/src/modules/room/api/dto/response/room-member-list.response.ts @@ -0,0 +1,11 @@ +import { ApiProperty } from '@nestjs/swagger'; +import { RoomMemberResponse } from './room-member.response'; + +export class RoomMemberListResponse { + constructor(data: RoomMemberResponse[]) { + this.data = data; + } + + @ApiProperty({ type: [RoomMemberResponse] }) + public data: RoomMemberResponse[]; +} diff --git a/apps/server/src/modules/room/api/dto/response/room-member.response.ts b/apps/server/src/modules/room/api/dto/response/room-member.response.ts index de1ba51e01..a0d8275d11 100644 --- a/apps/server/src/modules/room/api/dto/response/room-member.response.ts +++ b/apps/server/src/modules/room/api/dto/response/room-member.response.ts @@ -3,34 +3,29 @@ import { RoleName } from '@shared/domain/interface'; export class RoomMemberResponse { @ApiProperty() - firstName!: string; + public firstName!: string; @ApiProperty() - lastName!: string; + public lastName!: string; @ApiProperty() - roleName!: RoleName; + public roomRoleName!: RoleName; @ApiProperty() - schoolName!: string; + public schoolRoleName!: RoleName; @ApiProperty() - userId!: string; + public schoolName!: string; + + @ApiProperty() + public userId!: string; constructor(props: RoomMemberResponse) { this.userId = props.userId; this.firstName = props.firstName; this.lastName = props.lastName; - this.roleName = props.roleName; + this.roomRoleName = props.roomRoleName; + this.schoolRoleName = props.schoolRoleName; this.schoolName = props.schoolName; } } - -export class RoomMemberListResponse { - constructor(data: RoomMemberResponse[]) { - this.data = data; - } - - @ApiProperty({ type: [RoomMemberResponse] }) - data: RoomMemberResponse[]; -} diff --git a/apps/server/src/modules/room/api/room.controller.ts b/apps/server/src/modules/room/api/room.controller.ts index b130516f93..b430e3f736 100644 --- a/apps/server/src/modules/room/api/room.controller.ts +++ b/apps/server/src/modules/room/api/room.controller.ts @@ -30,9 +30,9 @@ import { RoomBoardListResponse } from './dto/response/room-board-list.response'; import { RoomDetailsResponse } from './dto/response/room-details.response'; import { RoomItemResponse } from './dto/response/room-item.response'; import { RoomListResponse } from './dto/response/room-list.response'; -import { RoomMemberListResponse } from './dto/response/room-member.response'; import { RoomMapper } from './mapper/room.mapper'; import { RoomUc } from './room.uc'; +import { RoomMemberListResponse } from './dto/response/room-member-list.response'; @ApiTags('Room') @JwtAuthentication() diff --git a/apps/server/src/modules/room/api/room.uc.ts b/apps/server/src/modules/room/api/room.uc.ts index 39ed7379be..2e57810f92 100644 --- a/apps/server/src/modules/room/api/room.uc.ts +++ b/apps/server/src/modules/room/api/room.uc.ts @@ -136,7 +136,8 @@ export class RoomUc { userId: member.userId, firstName: user.firstName, lastName: user.lastName, - roleName: member.roles[0].name, + roomRoleName: member.roles[0].name, + schoolRoleName: user.roles[0].name, schoolName: user.schoolName ?? '', }); } diff --git a/apps/server/src/modules/room/api/test/room-members.api.spec.ts b/apps/server/src/modules/room/api/test/room-members.api.spec.ts index 9ae1c37305..e9fc66bb83 100644 --- a/apps/server/src/modules/room/api/test/room-members.api.spec.ts +++ b/apps/server/src/modules/room/api/test/room-members.api.spec.ts @@ -14,7 +14,7 @@ import { UserAndAccountTestFactory } from '@testing/factory/user-and-account.tes import { userFactory } from '@testing/factory/user.factory'; import { TestApiClient } from '@testing/test-api-client'; import { roomEntityFactory } from '../../testing/room-entity.factory'; -import { RoomMemberListResponse } from '../dto/response/room-member.response'; +import { RoomMemberListResponse } from '../dto/response/room-member-list.response'; describe('Room Controller (API)', () => { let app: INestApplication; @@ -57,8 +57,10 @@ describe('Room Controller (API)', () => { name: RoleName.ROOMVIEWER, permissions: [Permission.ROOM_VIEW], }); - const students = userFactory.buildList(2, { school }); - const teachers = userFactory.buildList(2, { school }); + const teacherRole = teacherUser.roles[0]; + const studentRole = roleFactory.buildWithId({ name: RoleName.STUDENT }); + const students = userFactory.buildList(2, { school, roles: [studentRole] }); + const teachers = userFactory.buildList(2, { school, roles: [teacherRole] }); const userGroupEntity = groupEntityFactory.buildWithId({ users: [ { role: editRole, user: teacherUser }, @@ -138,12 +140,30 @@ describe('Room Controller (API)', () => { expect(response.status).toBe(HttpStatus.OK); const body = response.body as RoomMemberListResponse; expect(body.data.length).toEqual(5); - expect(body.data).toContainEqual(expect.objectContaining({ userId: teacherUser.id, roleName: editRole.name })); + expect(body.data).toContainEqual( + expect.objectContaining({ + userId: teacherUser.id, + roomRoleName: editRole.name, + schoolRoleName: RoleName.TEACHER, + }) + ); students.forEach((student) => { - expect(body.data).toContainEqual(expect.objectContaining({ userId: student.id, roleName: viewerRole.name })); + expect(body.data).toContainEqual( + expect.objectContaining({ + userId: student.id, + roomRoleName: viewerRole.name, + schoolRoleName: RoleName.STUDENT, + }) + ); }); teachers.forEach((teacher) => { - expect(body.data).toContainEqual(expect.objectContaining({ userId: teacher.id, roleName: editRole.name })); + expect(body.data).toContainEqual( + expect.objectContaining({ + userId: teacher.id, + roomRoleName: editRole.name, + schoolRoleName: RoleName.TEACHER, + }) + ); }); }); });