-
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.
- 게이트웨이 - 프로젝트 삭제관련 라우팅 로직 추가 - 프로젝트 삭제시 해당 프로젝트의 네임스페이스 Map 삭제하도록 구현 - 컨트롤러 - 프로젝트 삭제 메서드 추가 - 삭제 알림 보내고 1초 후 프로젝트 삭제하는 로직 구현 - 서비스 - 프로젝트 삭제 메서드 추가 - 레포지토리 - 프로젝트 삭제 메서드 추가 - 프로젝트 삭제 E2E 테스트 추가
- Loading branch information
1 parent
3916432
commit 6dfc523
Showing
7 changed files
with
188 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
backend/src/project/dto/project-info/ProjectDeleteNotify.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,13 @@ | ||
export class ProjectDeleteNotifyDto { | ||
domain: string; | ||
action: string; | ||
content: Record<string, string>; | ||
|
||
static of() { | ||
const dto = new ProjectDeleteNotifyDto(); | ||
dto.domain = 'projectInfo'; | ||
dto.action = 'delete'; | ||
dto.content = {}; | ||
return dto; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
backend/src/project/dto/project-info/ProjectDeleteRequest.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,9 @@ | ||
import { IsNotEmpty, Matches } from 'class-validator'; | ||
|
||
export class ProjectDeleteRequestDto { | ||
@Matches(/^delete$/) | ||
action: string; | ||
|
||
@IsNotEmpty() | ||
content: Record<string, string>; | ||
} |
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
109 changes: 109 additions & 0 deletions
109
backend/test/project/ws-setting-page/ws-delete-project.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,109 @@ | ||
import { | ||
app, | ||
appInit, | ||
connectServer, | ||
createMember, | ||
createProject, | ||
getProjectLinkId, | ||
joinProject, | ||
listenAppAndSetPortEnv, | ||
memberFixture, | ||
memberFixture2, | ||
projectPayload, | ||
} from 'test/setup'; | ||
import { handleConnectErrorWithReject } from '../ws-common'; | ||
import { Socket } from 'socket.io-client'; | ||
|
||
describe('WS project', () => { | ||
beforeEach(async () => { | ||
await app.close(); | ||
await appInit(); | ||
await listenAppAndSetPortEnv(app); | ||
}); | ||
describe('delete project', () => { | ||
it('should return deleted project event when leader request', async () => { | ||
let socket1: Socket; | ||
let socket2: Socket; | ||
|
||
await new Promise<void>(async (resolve, reject) => { | ||
const accessToken1 = (await createMember(memberFixture, app)) | ||
.accessToken; | ||
const project = await createProject(accessToken1, projectPayload, app); | ||
const projectLinkId = await getProjectLinkId(accessToken1, project.id); | ||
|
||
const accessToken2 = (await createMember(memberFixture2, app)) | ||
.accessToken; | ||
await joinProject(accessToken2, projectLinkId); | ||
|
||
socket1 = connectServer(project.id, accessToken1); | ||
handleConnectErrorWithReject(socket1, reject); | ||
await joinSettingPage(socket1); | ||
|
||
socket2 = connectServer(project.id, accessToken2); | ||
handleConnectErrorWithReject(socket2, reject); | ||
await joinLandingPage(socket2); | ||
|
||
socket1.emit('projectInfo', { | ||
action: 'delete', | ||
content: {}, | ||
}); | ||
|
||
await Promise.all([ | ||
expectDeleteProject(socket1, 'main'), | ||
expectDeleteProject(socket2, 'main'), | ||
]); | ||
|
||
await Promise.all([ | ||
expectCloseSocket(socket1), | ||
expectCloseSocket(socket2), | ||
]); | ||
resolve(); | ||
}).finally(() => { | ||
socket1.close(); | ||
socket2.close(); | ||
}); | ||
}); | ||
|
||
const expectDeleteProject = (socket: Socket, eventPage: string) => { | ||
return new Promise<void>((resolve) => { | ||
socket.on(eventPage, (data) => { | ||
const { action, domain } = data; | ||
if (domain === 'projectInfo' && action === 'delete') { | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
}; | ||
const expectCloseSocket = (socket: Socket) => { | ||
return new Promise<void>((resolve) => { | ||
socket.on('disconnect', () => { | ||
resolve(); | ||
}); | ||
}); | ||
}; | ||
}); | ||
}); | ||
|
||
const joinSettingPage = (socket: Socket) => { | ||
return new Promise<void>((resolve) => { | ||
socket.emit('joinSetting'); | ||
socket.once('setting', (data) => { | ||
const { action, domain } = data; | ||
if (domain === 'setting' && action === 'init') { | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
}; | ||
|
||
const joinLandingPage = (socket: Socket) => { | ||
return new Promise<void>((resolve) => { | ||
socket.emit('joinLanding'); | ||
socket.once('landing', (data) => { | ||
const { action, domain } = data; | ||
if (domain === 'landing' && action === 'init') { | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
}; |