Skip to content

Commit a8518d8

Browse files
committed
Remove frontend import from backend files
1 parent b67a087 commit a8518d8

File tree

7 files changed

+34
-20
lines changed

7 files changed

+34
-20
lines changed

__mocks__/svgrMock.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = 'icon-mock';
1+
module.exports = 'IconMock';

__snapshots__/client/components/Sidebar/Sidebar.test.tsx.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ exports[`Test Sidebar Sidebar renders correctly 1`] = `
1212
>
1313
<img
1414
alt="VH graphic"
15-
src="icon-mock"
15+
src="IconMock"
1616
/>
1717
</div>
1818
<hr

__snapshots__/client/routes/dashboard/Frame.test.tsx.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ exports[`Test Frame Frame renders correctly 1`] = `
4848
>
4949
<img
5050
alt="VH graphic"
51-
src="icon-mock"
51+
src="IconMock"
5252
/>
5353
</div>
5454
<hr

__snapshots__/client/routes/login/Login.test.tsx.snap

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
exports[`Login renders properly 1`] = `
44
<div
5-
className="sc-fjdhpX ebOgGV"
5+
className="sc-fjdhpX dmItWC"
66
>
77
<div
88
className="sc-bdVaJa sc-bwzfXH sc-ifAKCX sc-jzJRlG hPKjIj"
@@ -34,7 +34,7 @@ exports[`Login renders properly 1`] = `
3434
<img
3535
alt="Google logo"
3636
className="sc-iwsKbI kXBzef"
37-
src={[Function]}
37+
src="IconMock"
3838
/>
3939
</div>
4040
<div
@@ -63,7 +63,7 @@ exports[`Login renders properly 1`] = `
6363
<img
6464
alt="GitHub logo"
6565
className="sc-iwsKbI kXBzef"
66-
src={[Function]}
66+
src="IconMock"
6767
/>
6868
</div>
6969
<div

jest.config.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ module.exports = {
2121
testEnvironment: 'jsdom',
2222
snapshotResolver: './__mocks__/snapshotResolver',
2323
moduleNameMapper: {
24-
'../../assets/img/square_hackathon_logo.svg': '<rootDir>/__mocks__/svgrMock.js',
25-
'../../assets/img/unchecked_box.svg': '<rootDir>/__mocks__/svgrMock.js',
26-
'../../assets/img/checked_box.svg': '<rootDir>/__mocks__/svgrMock.js',
27-
'.+\\.svg?.+$': '@svgr/webpack', // see https://github.com/smooth-code/svgr/issues/83
24+
// '../../assets/img/square_hackathon_logo.svg': '<rootDir>/__mocks__/svgrMock.js',
25+
// '../../assets/img/unchecked_box.svg': '<rootDir>/__mocks__/svgrMock.js',
26+
// '../../assets/img/checked_box.svg': '<rootDir>/__mocks__/svgrMock.js',
27+
'\\.svg': '<rootDir>/__mocks__/svgrMock.js', // see https://github.com/smooth-code/svgr/issues/83
2828
'\\.(css|less)$': 'jest-transform-css',
29-
3029
'\\.(jpg|jpeg|png|gif)$': '<rootDir>/__mocks__/svgrMock.js',
3130
},
3231
transform: {

src/client/assets/application.js

-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ export const questions = [
9898
Component: Slider,
9999
default: '2019',
100100
fieldName: 'gradYear',
101-
optional: true,
102101
options: ['2019', '2020', '2021', '2022', '2023', 'Other'],
103102
other: true,
104103
title: 'Graduation Year',

src/server/resolvers/index.ts

+24-8
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,27 @@ import Context from '../context';
1414
import { fetchUser, query, queryById, toEnum, updateUser, checkIsAuthorized } from './helpers';
1515
import { checkInUserToEvent, removeUserFromEvent, registerNFCUIDWithUser } from '../nfc';
1616
import { getSignedUploadUrl, getSignedReadUrl } from '../storage/gcp';
17-
import appConfig from '../../client/assets/application';
18-
import { ConfigField } from '../../client/routes/application/Application';
17+
18+
// TODO: Cannot import frontend files so this is ugly workaround. Fix this.
19+
const requiredFields = [
20+
'firstName',
21+
'lastName',
22+
'shirtSize',
23+
'gender',
24+
'phoneNumber',
25+
'dateOfBirth',
26+
'school',
27+
'major',
28+
'gradYear',
29+
'race',
30+
'favArtPiece',
31+
'essay1',
32+
'volunteer',
33+
'resume',
34+
'codeOfConduct',
35+
'infoSharingConsent',
36+
];
37+
1938
/**
2039
* Used to define a __resolveType function on the User resolver that doesn't take in a promise. This is important as it
2140
*/
@@ -240,12 +259,9 @@ export const resolvers: CustomResolvers<Context> = {
240259
* Finds the first element that is required (not optional) but does not have any input.
241260
* If this element exists, the application is not finished.
242261
*/
243-
const appFinished = !appConfig
244-
.flatMap(section => section.fields as ConfigField[])
245-
.some(
246-
field =>
247-
!field.optional && !args.input.find(el => el.question === field.fieldName && el.answer)
248-
);
262+
const appFinished = !requiredFields.some(
263+
field => !args.input.find(el => el.question === field && el.answer)
264+
);
249265

250266
// Update the fields of the hacker object with application data.
251267
// TODO: Improve the quality of this resolver by removing this hack.

0 commit comments

Comments
 (0)