@@ -60,6 +60,7 @@ import {
6060 OpportunityType ,
6161 SalaryPeriod ,
6262 SeniorityLevel ,
63+ Location ,
6364} from '@dailydotdev/schema' ;
6465import { UserCandidatePreference } from '../../src/entity/user/UserCandidatePreference' ;
6566import { QuestionScreening } from '../../src/entity/questions/QuestionScreening' ;
@@ -5625,8 +5626,6 @@ describe('mutation parseOpportunity', () => {
56255626
56265627 deleteFileFromBucketSpy . mockResolvedValue ( true ) ;
56275628
5628- console . log ( await con . getRepository ( OpportunityUserRecruiter ) . find ( ) ) ;
5629-
56305629 // Execute the mutation with a file upload
56315630 const res = await authorizeRequest (
56325631 request ( app . server )
@@ -5664,6 +5663,106 @@ describe('mutation parseOpportunity', () => {
56645663 '550e8400-e29b-41d4-a716-446655440000' ,
56655664 ) ;
56665665 } ) ;
5666+
5667+ it ( 'should assign opportunity location to Europe when no country specified' , async ( ) => {
5668+ loggedUser = '1' ;
5669+
5670+ fileTypeFromBuffer . mockResolvedValue ( {
5671+ ext : 'pdf' ,
5672+ mime : 'application/pdf' ,
5673+ } ) ;
5674+
5675+ const uploadResumeFromBufferSpy = jest . spyOn (
5676+ googleCloud ,
5677+ 'uploadResumeFromBuffer' ,
5678+ ) ;
5679+
5680+ uploadResumeFromBufferSpy . mockResolvedValue (
5681+ `https://storage.cloud.google.com/${ RESUME_BUCKET_NAME } /file` ,
5682+ ) ;
5683+
5684+ const deleteFileFromBucketSpy = jest . spyOn (
5685+ googleCloud ,
5686+ 'deleteFileFromBucket' ,
5687+ ) ;
5688+
5689+ deleteFileFromBucketSpy . mockResolvedValue ( true ) ;
5690+
5691+ const transport = createMockBrokkrTransport ( {
5692+ opportunity : {
5693+ location : [
5694+ new Location ( {
5695+ continent : 'Europe' ,
5696+ type : 1 ,
5697+ } ) ,
5698+ ] ,
5699+ } ,
5700+ } ) ;
5701+
5702+ const serviceClient = {
5703+ instance : createClient ( BrokkrService , transport ) ,
5704+ garmr : createGarmrMock ( ) ,
5705+ } ;
5706+
5707+ jest
5708+ . spyOn ( brokkrCommon , 'getBrokkrClient' )
5709+ . mockImplementation ( ( ) : ServiceClient < typeof BrokkrService > => {
5710+ return serviceClient ;
5711+ } ) ;
5712+
5713+ await saveFixtures ( con , DatasetLocation , [
5714+ {
5715+ country : 'Europe' ,
5716+ iso2 : 'EU' ,
5717+ iso3 : 'EUR' ,
5718+ } ,
5719+ ] ) ;
5720+
5721+ // Execute the mutation with a file upload
5722+ const res = await authorizeRequest (
5723+ request ( app . server )
5724+ . post ( '/graphql' )
5725+ . field (
5726+ 'operations' ,
5727+ JSON . stringify ( {
5728+ query : MUTATION ,
5729+ variables : {
5730+ payload : {
5731+ file : null ,
5732+ } ,
5733+ } ,
5734+ } ) ,
5735+ )
5736+ . field ( 'map' , JSON . stringify ( { '0' : [ 'variables.payload.file' ] } ) )
5737+ . attach ( '0' , './__tests__/fixture/screen.pdf' ) ,
5738+ ) . expect ( 200 ) ;
5739+
5740+ const body = res . body ;
5741+ expect ( body . errors ) . toBeFalsy ( ) ;
5742+
5743+ expect ( body . data . parseOpportunity ) . toMatchObject ( {
5744+ locations : [
5745+ {
5746+ location : {
5747+ city : null ,
5748+ country : 'Europe' ,
5749+ subdivision : null ,
5750+ } ,
5751+ type : 1 ,
5752+ } ,
5753+ ] ,
5754+ } ) ;
5755+
5756+ const opportunity = await con . getRepository ( OpportunityJob ) . findOne ( {
5757+ where : {
5758+ id : body . data . parseOpportunity . id ,
5759+ } ,
5760+ } ) ;
5761+
5762+ expect ( opportunity ! . organizationId ) . toBe (
5763+ '550e8400-e29b-41d4-a716-446655440000' ,
5764+ ) ;
5765+ } ) ;
56675766} ) ;
56685767
56695768describe ( 'mutation createSharedSlackChannel' , ( ) => {
0 commit comments