diff --git a/backend/src/graphql/resolvers/RoomResolver.spec.ts b/backend/src/graphql/resolvers/RoomResolver.spec.ts index dad52cac58..af19571e04 100644 --- a/backend/src/graphql/resolvers/RoomResolver.spec.ts +++ b/backend/src/graphql/resolvers/RoomResolver.spec.ts @@ -573,7 +573,17 @@ describe('RoomResolver', () => { }) }) - describe('one attendee', () => { + describe('one attendee and meeting in DB', () => { + beforeAll(async () => { + await prisma.meeting.create({ + data: { + name: 'Dreammall Entwicklung', + meetingID: 'Dreammall-Entwicklung', + attendeePW: '1234', + }, + }) + }) + beforeEach(() => { getMeetingsMock.mockResolvedValue([ { @@ -617,7 +627,8 @@ describe('RoomResolver', () => { ]) }) - it('returns empty array', async () => { + it('returns room with attendee', async () => { + jest.clearAllMocks() await expect( testServer.executeOperation( { @@ -655,6 +666,14 @@ describe('RoomResolver', () => { }, }) }) + + it('calls joinMeetingLink with correct PW', () => { + expect(joinMeetingLinkMock).toBeCalledWith({ + fullName: 'User', + meetingID: 'Dreammall-Entwicklung', + password: '1234', + }) + }) }) describe('some attendee', () => { diff --git a/backend/src/graphql/resolvers/RoomResolver.ts b/backend/src/graphql/resolvers/RoomResolver.ts index 3363b00429..ad62e009b8 100644 --- a/backend/src/graphql/resolvers/RoomResolver.ts +++ b/backend/src/graphql/resolvers/RoomResolver.ts @@ -135,17 +135,31 @@ export class RoomResolver { const { user } = context if (!user) return [] const meetings = await getMeetings() - return meetings.map( - (m: MeetingInfo) => - new OpenRoom( + + if (meetings.length) { + const dbMeetingsPwMap = await prisma.meeting.findMany({ + where: { + meetingID: { in: meetings.map((m: MeetingInfo) => m.meetingID) }, + }, + select: { + meetingID: true, + attendeePW: true, + }, + }) + + return meetings.map((m: MeetingInfo) => { + const pw = dbMeetingsPwMap.find((pw) => pw.meetingID === m.meetingID) + return new OpenRoom( m, joinMeetingLink({ fullName: user.name, meetingID: m.meetingID, - password: '', + password: pw?.attendeePW ? pw.attendeePW : '', }), - ), - ) + ) + }) + } + return [] } @Query(() => String, { nullable: true })