-
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.
- 컨트롤러 - 프로젝트 초대 브리뷰 반환하는 메서드 구현 - 서비스 - 초대링크로 프로젝트의 일부 정보를 반환하는 메서드 구현 - 레포지토리 - 프로젝트, 프로젝트 회원을 조인해서 반환하는 메서드 구현 - 프로젝트 프리뷰 조회 E2E 테스트 추가
- Loading branch information
1 parent
f39bfed
commit a40ede1
Showing
6 changed files
with
193 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
backend/src/project/dto/ProjectInvitePreviewResponse.dto.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,20 @@ | ||
export class ProjectInvitePreviewResponseDto { | ||
id: number; | ||
title: string; | ||
subject: string; | ||
leaderUsername: string; | ||
|
||
static of( | ||
id: number, | ||
title: string, | ||
subject: string, | ||
leaderUsername: string, | ||
) { | ||
const dto = new ProjectInvitePreviewResponseDto(); | ||
dto.id = id; | ||
dto.title = title; | ||
dto.subject = subject; | ||
dto.leaderUsername = leaderUsername; | ||
return dto; | ||
} | ||
} |
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,20 @@ | ||
export class ProjectBriefInfoDto { | ||
id: number; | ||
title: string; | ||
subject: string; | ||
leaderUsername: string; | ||
|
||
static of( | ||
id: number, | ||
title: string, | ||
subject: string, | ||
leaderUsername: string, | ||
) { | ||
const dto = new ProjectBriefInfoDto(); | ||
dto.id = id; | ||
dto.title = title; | ||
dto.subject = subject; | ||
dto.leaderUsername = leaderUsername; | ||
return dto; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import * as request from 'supertest'; | ||
import { | ||
app, | ||
appInit, | ||
createMember, | ||
createProject, | ||
getProjectLinkId, | ||
listenAppAndSetPortEnv, | ||
memberFixture, | ||
memberFixture2, | ||
projectPayload, | ||
} from 'test/setup'; | ||
|
||
describe('GET /project/invite-preview', () => { | ||
beforeEach(async () => { | ||
await app.close(); | ||
await appInit(); | ||
await listenAppAndSetPortEnv(app); | ||
}); | ||
|
||
it('should return 200 when given valid invite link id', async () => { | ||
const { accessToken } = await createMember(memberFixture, app); | ||
const { id: projectId } = await createProject( | ||
accessToken, | ||
projectPayload, | ||
app, | ||
); | ||
const inviteLinkId = await getProjectLinkId(accessToken, projectId); | ||
const { accessToken: newAccessToken } = await createMember( | ||
memberFixture2, | ||
app, | ||
); | ||
|
||
const response = await request(app.getHttpServer()) | ||
.get(`/api/project/invite-preview/${inviteLinkId}`) | ||
.set('Authorization', `Bearer ${newAccessToken}`); | ||
|
||
expect(response.status).toBe(200); | ||
expect(typeof response.body.id).toBe('number'); | ||
expect(response.body.title).toBe(projectPayload.title); | ||
expect(response.body.subject).toBe(projectPayload.subject); | ||
expect(response.body.leaderUsername).toBe(memberFixture.username); | ||
}); | ||
|
||
it('should return 404 when project link ID is not found', async () => { | ||
const invalidUUID = 'c93a87e8-a0a4-4b55-bdf2-59bf691f5c37'; | ||
const { accessToken: newAccessToken } = await createMember( | ||
memberFixture2, | ||
app, | ||
); | ||
|
||
const response = await request(app.getHttpServer()) | ||
.get(`/api/project/invite-preview/${invalidUUID}`) | ||
.set('Authorization', `Bearer ${newAccessToken}`); | ||
|
||
expect(response.status).toBe(404); | ||
}); | ||
|
||
it('should return 401 (Bearer Token is missing)', async () => { | ||
const { accessToken } = await createMember(memberFixture, app); | ||
const { id: projectId } = await createProject( | ||
accessToken, | ||
projectPayload, | ||
app, | ||
); | ||
const projectLinkId = await getProjectLinkId(accessToken, projectId); | ||
|
||
const response = await request(app.getHttpServer()).get( | ||
`/api/project/invite-preview/${projectLinkId}`, | ||
); | ||
|
||
expect(response.status).toBe(401); | ||
}); | ||
|
||
it('should return 401 (Expired:accessToken) when given invalid access token', async () => { | ||
const { accessToken } = await createMember(memberFixture, app); | ||
const { id: projectId } = await createProject( | ||
accessToken, | ||
projectPayload, | ||
app, | ||
); | ||
const projectLinkId = await getProjectLinkId(accessToken, projectId); | ||
|
||
const response = await request(app.getHttpServer()) | ||
.get(`/api/project/invite-preview/${projectLinkId}`) | ||
.set('Authorization', `Bearer invalidToken`); | ||
|
||
expect(response.status).toBe(401); | ||
expect(response.body.message).toBe('Expired:accessToken'); | ||
}); | ||
}); |