@@ -77,11 +77,19 @@ let app: FastifyInstance;
7777let state : GraphQLTestingState ;
7878let client : GraphQLTestClient ;
7979let loggedUser : string | null = null ;
80+ let isTeamMember = false ;
8081
8182beforeAll ( async ( ) => {
8283 con = await createOrGetConnection ( ) ;
8384 state = await initializeGraphQLTesting (
84- ( ) => new MockContext ( con , loggedUser ) as unknown as Context ,
85+ ( req ) =>
86+ new MockContext (
87+ con ,
88+ loggedUser || undefined ,
89+ [ ] ,
90+ req ,
91+ isTeamMember ,
92+ ) as Context ,
8593 ) ;
8694 client = state . client ;
8795 app = state . app ;
@@ -304,6 +312,8 @@ describe('query opportunityById', () => {
304312 } ) ;
305313
306314 it ( 'should return null for non-live opportunity when user is not a recruiter' , async ( ) => {
315+ loggedUser = '2' ;
316+
307317 await con
308318 . getRepository ( Opportunity )
309319 . update (
@@ -317,7 +327,7 @@ describe('query opportunityById', () => {
317327 query : OPPORTUNITY_BY_ID_QUERY ,
318328 variables : { id : '550e8400-e29b-41d4-a716-446655440001' } ,
319329 } ,
320- 'NOT_FOUND ' ,
330+ 'FORBIDDEN ' ,
321331 ) ;
322332 } ) ;
323333
@@ -358,6 +368,28 @@ describe('query opportunityById', () => {
358368 '550e8400-e29b-41d4-a716-446655440001' ,
359369 ) ;
360370 } ) ;
371+
372+ it ( 'should return non-live opportunity if user is a team member' , async ( ) => {
373+ loggedUser = '2' ;
374+ isTeamMember = true ;
375+
376+ await con
377+ . getRepository ( Opportunity )
378+ . update (
379+ { id : '550e8400-e29b-41d4-a716-446655440001' } ,
380+ { state : OpportunityState . DRAFT } ,
381+ ) ;
382+
383+ const res = await client . query ( OPPORTUNITY_BY_ID_QUERY , {
384+ variables : { id : '550e8400-e29b-41d4-a716-446655440001' } ,
385+ } ) ;
386+
387+ expect ( res . errors ) . toBeFalsy ( ) ;
388+
389+ expect ( res . data . opportunityById . id ) . toEqual (
390+ '550e8400-e29b-41d4-a716-446655440001' ,
391+ ) ;
392+ } ) ;
361393} ) ;
362394
363395describe ( 'query getOpportunityMatch' , ( ) => {
0 commit comments