@@ -26,7 +26,7 @@ describe('WorkspaceController', () => {
2626 getUserWorkspaces : jest . fn ( ) ,
2727 generateInviteUrl : jest . fn ( ) ,
2828 processInviteUrl : jest . fn ( ) ,
29- checkAccess : jest . fn ( ) ,
29+ getWorkspaceData : jest . fn ( ) ,
3030 updateVisibility : jest . fn ( ) ,
3131 } ,
3232 } ,
@@ -117,13 +117,15 @@ describe('WorkspaceController', () => {
117117 description : 'Description 1' ,
118118 thumbnailUrl : 'http://example.com/image1.png' ,
119119 role : 'owner' ,
120+ visibility : 'private' ,
120121 } ,
121122 {
122123 workspaceId : 'snowflake-id-2' ,
123124 title : 'Workspace 2' ,
124125 description : null ,
125126 thumbnailUrl : null ,
126127 role : 'guest' ,
128+ visibility : 'private' ,
127129 } ,
128130 ] as UserWorkspaceDto [ ] ;
129131
@@ -188,32 +190,45 @@ describe('WorkspaceController', () => {
188190 } ) ;
189191 } ) ;
190192
191- describe ( 'checkWorkspaceAccess ' , ( ) => {
192- it ( '워크스페이스에 접근 가능한 경우 메시지를 반환한다.' , async ( ) => {
193+ describe ( 'getWorkspace ' , ( ) => {
194+ it ( '워크스페이스에 접근 가능한 경우 워크스페이스 정보를 반환한다.' , async ( ) => {
193195 const workspaceId = 'workspace-snowflake-id' ;
194196 const userId = 'user-snowflake-id' ;
195197
196- jest . spyOn ( service , 'checkAccess' ) . mockResolvedValue ( undefined ) ;
198+ const mockWorkspace = {
199+ workspaceId : 'snowflake-id-1' ,
200+ title : 'Workspace 1' ,
201+ description : 'Description 1' ,
202+ thumbnailUrl : 'http://example.com/image1.png' ,
203+ role : 'owner' ,
204+ visibility : 'public' ,
205+ } as UserWorkspaceDto ;
197206
198- const result = await controller . checkWorkspaceAccess ( workspaceId , userId ) ;
207+ jest . spyOn ( service , 'getWorkspaceData' ) . mockResolvedValue ( mockWorkspace ) ;
199208
200- expect ( service . checkAccess ) . toHaveBeenCalledWith ( userId , workspaceId ) ;
209+ const result = await controller . getWorkspace ( workspaceId , userId ) ;
210+
211+ expect ( service . getWorkspaceData ) . toHaveBeenCalledWith (
212+ userId ,
213+ workspaceId ,
214+ ) ;
201215 expect ( result ) . toEqual ( {
202- message : WorkspaceResponseMessage . WORKSPACE_ACCESS_CHECKED ,
216+ message : WorkspaceResponseMessage . WORKSPACE_DATA_RETURNED ,
217+ workspace : mockWorkspace ,
203218 } ) ;
204219 } ) ;
205220
206221 it ( '로그인하지 않은 사용자의 경우 null로 처리하고 접근 가능한 경우 메시지를 반환한다.' , async ( ) => {
207222 const workspaceId = 'workspace-snowflake-id' ;
208223 const userId = 'null' ; // 로그인되지 않은 상태를 나타냄
209224
210- jest . spyOn ( service , 'checkAccess ' ) . mockResolvedValue ( undefined ) ;
225+ jest . spyOn ( service , 'getWorkspaceData ' ) . mockResolvedValue ( undefined ) ;
211226
212- const result = await controller . checkWorkspaceAccess ( workspaceId , userId ) ;
227+ const result = await controller . getWorkspace ( workspaceId , userId ) ;
213228
214- expect ( service . checkAccess ) . toHaveBeenCalledWith ( null , workspaceId ) ;
229+ expect ( service . getWorkspaceData ) . toHaveBeenCalledWith ( null , workspaceId ) ;
215230 expect ( result ) . toEqual ( {
216- message : WorkspaceResponseMessage . WORKSPACE_ACCESS_CHECKED ,
231+ message : WorkspaceResponseMessage . WORKSPACE_DATA_RETURNED ,
217232 } ) ;
218233 } ) ;
219234
@@ -223,14 +238,17 @@ describe('WorkspaceController', () => {
223238
224239 // 권한 없음
225240 jest
226- . spyOn ( service , 'checkAccess ' )
241+ . spyOn ( service , 'getWorkspaceData ' )
227242 . mockRejectedValue ( new ForbiddenAccessException ( ) ) ;
228243
229244 await expect (
230- controller . checkWorkspaceAccess ( workspaceId , userId ) ,
245+ controller . getWorkspace ( workspaceId , userId ) ,
231246 ) . rejects . toThrow ( ForbiddenAccessException ) ;
232247
233- expect ( service . checkAccess ) . toHaveBeenCalledWith ( userId , workspaceId ) ;
248+ expect ( service . getWorkspaceData ) . toHaveBeenCalledWith (
249+ userId ,
250+ workspaceId ,
251+ ) ;
234252 } ) ;
235253
236254 it ( '워크스페이스가 존재하지 않는 경우 WorkspaceNotFoundException을 던진다.' , async ( ) => {
@@ -239,14 +257,17 @@ describe('WorkspaceController', () => {
239257
240258 // 워크스페이스 없음
241259 jest
242- . spyOn ( service , 'checkAccess ' )
260+ . spyOn ( service , 'getWorkspaceData ' )
243261 . mockRejectedValue ( new WorkspaceNotFoundException ( ) ) ;
244262
245263 await expect (
246- controller . checkWorkspaceAccess ( workspaceId , userId ) ,
264+ controller . getWorkspace ( workspaceId , userId ) ,
247265 ) . rejects . toThrow ( WorkspaceNotFoundException ) ;
248266
249- expect ( service . checkAccess ) . toHaveBeenCalledWith ( userId , workspaceId ) ;
267+ expect ( service . getWorkspaceData ) . toHaveBeenCalledWith (
268+ userId ,
269+ workspaceId ,
270+ ) ;
250271 } ) ;
251272 } ) ;
252273} ) ;
0 commit comments