Skip to content

Commit ef2921a

Browse files
authored
Merge branch 'main' into parse-cv-profile
2 parents 8e955e1 + f8c4192 commit ef2921a

File tree

8 files changed

+80
-29
lines changed

8 files changed

+80
-29
lines changed

__tests__/schema/autocompletes.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ describe('query autocompleteLocation', () => {
439439
.get('/search/geocode/v6/forward')
440440
.query({
441441
q: 'new york',
442-
types: 'country,place',
442+
types: 'country,region,place',
443443
limit: 5,
444444
access_token: process.env.MAPBOX_ACCESS_TOKEN,
445445
})
@@ -506,7 +506,7 @@ describe('query autocompleteLocation', () => {
506506
.get('/search/geocode/v6/forward')
507507
.query({
508508
q: 'united states',
509-
types: 'country,place',
509+
types: 'country,region,place',
510510
limit: 5,
511511
access_token: process.env.MAPBOX_ACCESS_TOKEN,
512512
})
@@ -611,7 +611,7 @@ describe('query autocompleteLocation', () => {
611611
.get('/search/geocode/v6/forward')
612612
.query({
613613
q: 'san',
614-
types: 'country,place',
614+
types: 'country,region,place',
615615
limit: 5,
616616
access_token: process.env.MAPBOX_ACCESS_TOKEN,
617617
})
@@ -647,7 +647,7 @@ describe('query autocompleteLocation', () => {
647647
.get('/search/geocode/v6/forward')
648648
.query({
649649
q: 'test',
650-
types: 'country,place',
650+
types: 'country,region,place',
651651
limit: 5,
652652
access_token: process.env.MAPBOX_ACCESS_TOKEN,
653653
})
@@ -676,7 +676,7 @@ describe('query autocompleteLocation', () => {
676676
.get('/search/geocode/v6/forward')
677677
.query({
678678
q: 'nonexistentlocation',
679-
types: 'country,place',
679+
types: 'country,region,place',
680680
limit: 5,
681681
access_token: process.env.MAPBOX_ACCESS_TOKEN,
682682
})
@@ -698,7 +698,7 @@ describe('query autocompleteLocation', () => {
698698
.get('/search/geocode/v6/forward')
699699
.query({
700700
q: 'test',
701-
types: 'country,place',
701+
types: 'country,region,place',
702702
limit: 5,
703703
access_token: process.env.MAPBOX_ACCESS_TOKEN,
704704
})
@@ -757,7 +757,7 @@ describe('query autocompleteLocation', () => {
757757
.get('/search/geocode/v6/forward')
758758
.query({
759759
q: 'berlin',
760-
types: 'country,place',
760+
types: 'country,region,place',
761761
limit: 5,
762762
access_token: process.env.MAPBOX_ACCESS_TOKEN,
763763
})
@@ -794,7 +794,7 @@ describe('query autocompleteLocation', () => {
794794
.get('/search/geocode/v6/forward')
795795
.query({
796796
q: 'San Francisco, CA',
797-
types: 'country,place',
797+
types: 'country,region,place',
798798
limit: 5,
799799
access_token: process.env.MAPBOX_ACCESS_TOKEN,
800800
})

__tests__/schema/opportunity.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,6 +1410,68 @@ describe('query userOpportunityMatches', () => {
14101410
period: 1, // ANNUAL
14111411
});
14121412
});
1413+
1414+
it('should include opportunity details when requested', async () => {
1415+
loggedUser = '1';
1416+
1417+
const GET_USER_MATCHES_WITH_OPPORTUNITY_QUERY = /* GraphQL */ `
1418+
query GetUserOpportunityMatchesWithOpportunity($first: Int) {
1419+
userOpportunityMatches(first: $first) {
1420+
edges {
1421+
node {
1422+
userId
1423+
opportunityId
1424+
status
1425+
updatedAt
1426+
opportunity {
1427+
id
1428+
title
1429+
state
1430+
location {
1431+
city
1432+
country
1433+
}
1434+
organization {
1435+
id
1436+
name
1437+
}
1438+
}
1439+
}
1440+
}
1441+
}
1442+
}
1443+
`;
1444+
1445+
const res = await client.query(GET_USER_MATCHES_WITH_OPPORTUNITY_QUERY, {
1446+
variables: {
1447+
first: 10,
1448+
},
1449+
});
1450+
1451+
expect(res.errors).toBeFalsy();
1452+
expect(res.data.userOpportunityMatches.edges).toHaveLength(2);
1453+
1454+
const matchWithOpportunity = res.data.userOpportunityMatches.edges.find(
1455+
(e: { node: { opportunityId: string } }) =>
1456+
e.node.opportunityId === '550e8400-e29b-41d4-a716-446655440001',
1457+
);
1458+
1459+
expect(matchWithOpportunity.node.opportunity).toEqual({
1460+
id: '550e8400-e29b-41d4-a716-446655440001',
1461+
title: 'Senior Full Stack Developer',
1462+
state: 2, // LIVE
1463+
location: [
1464+
{
1465+
city: null,
1466+
country: 'Norway',
1467+
},
1468+
],
1469+
organization: {
1470+
id: '550e8400-e29b-41d4-a716-446655440000',
1471+
name: 'Daily Dev Inc',
1472+
},
1473+
});
1474+
});
14131475
});
14141476

14151477
describe('query getCandidatePreferences', () => {

__tests__/schema/profile.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -185,17 +185,6 @@ describe('query userExperiences', () => {
185185
expect(res.data.userExperiences.pageInfo.hasNextPage).toBe(false);
186186
});
187187

188-
it('should return only 1 experience for non-logged-in user', async () => {
189-
loggedUser = null;
190-
191-
const res = await client.query(USER_EXPERIENCES_QUERY, {
192-
variables: { userId: '1' },
193-
});
194-
195-
expect(res.errors).toBeFalsy();
196-
expect(res.data.userExperiences.edges).toHaveLength(1);
197-
});
198-
199188
it('should return all fields for logged-in users', async () => {
200189
loggedUser = '1';
201190

__tests__/updateUserInfo.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
} from './helpers';
1111
import { User } from '../src/entity';
1212
import { clearFile, UploadPreset } from '../src/common/cloudinary';
13+
import { fallbackImages } from '../src/config';
1314

1415
let con: DataSource;
1516
let state: GraphQLTestingState;
@@ -254,7 +255,7 @@ describe('mutation updateUserInfo', () => {
254255
expect(res.errors).toBeFalsy();
255256

256257
const updatedUser = await repo.findOneBy({ id: loggedUser });
257-
expect(updatedUser?.image).toBeNull();
258+
expect(updatedUser?.image).toBe(fallbackImages.avatar);
258259
expect(clearFile).toHaveBeenCalledWith({
259260
referenceId: loggedUser,
260261
preset: UploadPreset.Avatar,
@@ -318,7 +319,7 @@ describe('mutation updateUserInfo', () => {
318319
expect(res.errors).toBeFalsy();
319320

320321
const updatedUser = await repo.findOneBy({ id: loggedUser });
321-
expect(updatedUser?.image).toBeNull();
322+
expect(updatedUser?.image).toBe(fallbackImages.avatar);
322323
expect(updatedUser?.cover).toBeNull();
323324

324325
expect(clearFile).toHaveBeenCalledTimes(2);

src/integrations/mapbox/clients.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class MapboxClient implements IMapboxClient {
3939

4040
async autocomplete(query: string): Promise<MapboxResponse> {
4141
return this.garmr.execute(async () => {
42-
const url = `${this.baseUrl}?q=${encodeURIComponent(query)}&types=country,place&limit=5&access_token=${this.accessToken}`;
42+
const url = `${this.baseUrl}?q=${encodeURIComponent(query)}&types=country,region,place&limit=5&access_token=${this.accessToken}`;
4343

4444
const response = await fetch(url);
4545

src/schema/opportunity.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ export const typeDefs = /* GraphQL */ `
221221
createdAt: DateTime!
222222
updatedAt: DateTime!
223223
user: User!
224+
opportunity: Opportunity
224225
candidatePreferences: UserCandidatePreference
225226
screening: [ScreeningAnswer!]!
226227
feedback: [ScreeningAnswer!]!

src/schema/profile.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,8 @@ export const resolvers = traceResolvers<unknown, AuthContext>({
236236
ctx,
237237
info,
238238
(nodeSize) =>
239-
!!ctx.userId &&
240239
userExperiencesPageGenerator.hasPreviousPage(page, nodeSize),
241-
(nodeSize) =>
242-
!!ctx.userId &&
243-
userExperiencesPageGenerator.hasNextPage(page, nodeSize),
240+
(nodeSize) => userExperiencesPageGenerator.hasNextPage(page, nodeSize),
244241
(node, index) =>
245242
userExperiencesPageGenerator.nodeToCursor(page, args, node, index),
246243
(builder) => {
@@ -259,8 +256,8 @@ export const resolvers = traceResolvers<unknown, AuthContext>({
259256
builder.queryBuilder
260257
.orderBy(`${builder.alias}."endedAt"`, 'DESC', 'NULLS FIRST')
261258
.addOrderBy(`${builder.alias}."startedAt"`, 'DESC')
262-
.limit(!ctx.userId ? 1 : getLimit({ limit: page.limit }))
263-
.offset(!ctx.userId ? 0 : page.offset);
259+
.limit(getLimit({ limit: page.limit }))
260+
.offset(page.offset);
264261

265262
return builder;
266263
},

src/schema/users.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ import {
115115
import { markdown } from '../common/markdown';
116116
import { deleteRedisKey, getRedisObject, RedisMagicValues } from '../redis';
117117
import {
118+
fallbackImages,
118119
generateStorageKey,
119120
RESUME_BUCKET_NAME,
120121
StorageKey,
@@ -2542,7 +2543,7 @@ export const resolvers: IResolvers<unknown, BaseContext> = traceResolvers<
25422543
const file = await upload;
25432544
return (await uploadAvatar(user.id, file.createReadStream())).url;
25442545
}
2545-
return data.image || null;
2546+
return data.image || fallbackImages.avatar;
25462547
})(),
25472548
(async () => {
25482549
if (coverUpload && cloudinaryUrl) {

0 commit comments

Comments
 (0)