Skip to content

fix: phase member tests #663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/routes/phaseMembers/delete.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,26 @@ describe('Delete phase member', () => {
.expect(204, done);
});

it('should return 403 for copilot', (done) => {
it('should return 204 for copilot which is member of project', (done) => {
request(server)
.delete(`/v5/projects/${id}/phases/${phaseId}/members/${copilotUser.userId}`)
.set({
Authorization: `Bearer ${testUtil.jwts.copilot}`,
})
.expect(403, done);
.expect(204, done);
});

it('should return 403 for copilot which is not member of project', (done) => {
models.ProjectMember.destroy({
where: { userId: testUtil.userIds.copilot, id },
}).then(() => {
request(server)
.delete(`/v5/projects/${id}/phases/${phaseId}/members/${copilotUser.userId}`)
.set({
Authorization: `Bearer ${testUtil.jwts.copilot}`,
})
.expect(403, done);
});
});
});
});
18 changes: 16 additions & 2 deletions src/routes/phaseMembers/update.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,28 @@ describe('Update phase members', () => {
});
});

it('should return 403 for copilot', (done) => {
it('should return 200 for copilot which is member of project', (done) => {
request(server)
.post(`/v5/projects/${id}/phases/${phaseId}/members`)
.set({
Authorization: `Bearer ${testUtil.jwts.copilot}`,
})
.send({ userIds: [copilotUser.userId, memberUser.userId] })
.expect(403, done);
.expect(200, done);
});

it('should return 403 for copilot which is not member of project', (done) => {
models.ProjectMember.destroy({
where: { userId: testUtil.userIds.copilot, id },
}).then(() => {
request(server)
.post(`/v5/projects/${id}/phases/${phaseId}/members`)
.set({
Authorization: `Bearer ${testUtil.jwts.copilot}`,
})
.send({ userIds: [copilotUser.userId, memberUser.userId] })
.expect(403, done);
});
});
});
});