-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 프로젝트 설정페이지 init API에 프로젝트 참여요청 정보 추가
- 레포지토리 - 프로젝트 참여요청 목록 조회 메서드 추가 - 서비스 - 프로젝트 참여요청 목록 조회 메서드 추가 - 컨트롤러 - setting page join 메서드의 반환으로 참여요청 목록 데이터 추가 - DTO - 설정 페이지 init DTO에 프로젝트 참여요청 정보 추가 - E2E 테스트 - 프로젝트 참여요청 조회 E2E 테스트 추가
- Loading branch information
1 parent
f0f986c
commit 992cb75
Showing
5 changed files
with
163 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
backend/test/project/ws-setting-page/ws-join-request-setting-page.e2e-spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import { Socket } from 'socket.io-client'; | ||
import * as request from 'supertest'; | ||
import { | ||
app, | ||
appInit, | ||
connectServer, | ||
createMember, | ||
createProject, | ||
getMemberByAccessToken, | ||
getProjectLinkId, | ||
listenAppAndSetPortEnv, | ||
memberFixture, | ||
memberFixture2, | ||
projectPayload, | ||
} from 'test/setup'; | ||
import { Member } from 'src/member/entity/member.entity'; | ||
|
||
describe('WS Setting', () => { | ||
beforeEach(async () => { | ||
await app.close(); | ||
await appInit(); | ||
await listenAppAndSetPortEnv(app); | ||
}); | ||
|
||
it('should return join request data when leader enters setting page', async () => { | ||
const { accessToken: leaderAccessToken } = await createMember( | ||
memberFixture, | ||
app, | ||
); | ||
|
||
const { id: projectId } = await createProject( | ||
leaderAccessToken, | ||
projectPayload, | ||
app, | ||
); | ||
|
||
const { accessToken: requestingAccessToken } = await createMember( | ||
memberFixture2, | ||
app, | ||
); | ||
|
||
await submitJoinRequest( | ||
leaderAccessToken, | ||
projectId, | ||
requestingAccessToken, | ||
); | ||
const requestingMember = await getMemberByAccessToken( | ||
requestingAccessToken, | ||
); | ||
|
||
const leaderSocket = await enterSettingPage(projectId, leaderAccessToken); | ||
await expectJoinRequestList(leaderSocket, requestingMember); | ||
closePage(leaderSocket); | ||
}); | ||
|
||
async function enterSettingPage(projectId: number, accessToken: string) { | ||
const socket = connectServer(projectId, accessToken); | ||
socket.emit('joinSetting'); | ||
return socket; | ||
} | ||
|
||
async function expectJoinRequestList( | ||
socket: Socket, | ||
requestingMember: Member, | ||
) { | ||
return new Promise<void>((resolve) => { | ||
socket.on('setting', (data) => { | ||
const { action, domain, content } = data; | ||
expect(domain).toBe('setting'); | ||
expect(action).toBe('init'); | ||
expect(content.joinRequestList).toBeDefined(); | ||
expect(content.joinRequestList.length).toBe(1); | ||
expect(content.joinRequestList[0].id).toBeDefined(); | ||
expect(content.joinRequestList[0].memberId).toBe(requestingMember.id); | ||
expect(content.joinRequestList[0].username).toBe( | ||
requestingMember.username, | ||
); | ||
expect(content.joinRequestList[0].imageUrl).toBe( | ||
requestingMember.github_image_url, | ||
); | ||
resolve(); | ||
}); | ||
}); | ||
} | ||
|
||
function closePage(socket: Socket) { | ||
socket.close(); | ||
} | ||
}); | ||
|
||
async function submitJoinRequest( | ||
leaderAccessToken: string, | ||
projectId: number, | ||
requestingAccessToken: string, | ||
): Promise<request.Response> { | ||
const inviteLinkId = await getProjectLinkId(leaderAccessToken, projectId); | ||
return request(app.getHttpServer()) | ||
.post('/api/project/join-request') | ||
.set('Authorization', `Bearer ${requestingAccessToken}`) | ||
.send({ inviteLinkId }); | ||
} |