Skip to content

Commit 3b6878c

Browse files
authored
Cleaning Up Dkim Results and Code Base (canada-ca#1323)
* refactor name * update related tests * prettier ran on code base
1 parent 7587717 commit 3b6878c

26 files changed

Lines changed: 123 additions & 150 deletions

api-js/src/__tests__/server.test.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,14 @@ describe('parse server', () => {
9393
)
9494
.post('/graphql')
9595
.set('Accept', 'application/json')
96-
.send({ query: '{findVerifiedDomains (first: 5) { edges { node { id }}}}' })
96+
.send({
97+
query: '{findVerifiedDomains (first: 5) { edges { node { id }}}}',
98+
})
9799

98100
expect(response.status).toEqual(400)
99-
expect(response.text).toEqual(expect.stringContaining('exceeds maximum operation depth'))
101+
expect(response.text).toEqual(
102+
expect.stringContaining('exceeds maximum operation depth'),
103+
)
100104
})
101105
})
102106
})

api-js/src/auth/__tests__/check-domain-permission.test.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,9 @@ describe('given the check domain permission function', () => {
187187
await testCheckDomainPermission({ domainId: domain._id })
188188
} catch (err) {
189189
expect(err).toEqual(
190-
new Error('Permission check error. Unable to request domain information.'),
190+
new Error(
191+
'Permission check error. Unable to request domain information.',
192+
),
191193
)
192194
expect(consoleOutput).toEqual([
193195
`Database error when retrieving super admin claims for user: ${user._id} and domain: ${domain._id}: Error: Database error occurred.`,
@@ -211,7 +213,9 @@ describe('given the check domain permission function', () => {
211213
await testCheckDomainPermission({ domainId: domain._id })
212214
} catch (err) {
213215
expect(err).toEqual(
214-
new Error('Permission check error. Unable to request domain information.'),
216+
new Error(
217+
'Permission check error. Unable to request domain information.',
218+
),
215219
)
216220
expect(consoleOutput).toEqual([
217221
`Database error when retrieving affiliated organization claims for user: ${user._id} and domain: ${domain._id}: Error: Database error occurred.`,
@@ -240,7 +244,9 @@ describe('given the check domain permission function', () => {
240244
await testCheckDomainPermission({ domainId: domain._id })
241245
} catch (err) {
242246
expect(err).toEqual(
243-
new Error('Permission check error. Unable to request domain information.'),
247+
new Error(
248+
'Permission check error. Unable to request domain information.',
249+
),
244250
)
245251
expect(consoleOutput).toEqual([
246252
`Cursor error when retrieving affiliated organization claims for user: ${user._id} and domain: ${domain._id}: Error: Cursor error occurred.`,
@@ -275,9 +281,7 @@ describe('given the check domain permission function', () => {
275281
})
276282
await testCheckDomainPermission({ domainId: domain._id })
277283
} catch (err) {
278-
expect(err).toEqual(
279-
new Error('todo'),
280-
)
284+
expect(err).toEqual(new Error('todo'))
281285
expect(consoleOutput).toEqual([
282286
`Database error when retrieving super admin claims for user: ${user._id} and domain: ${domain._id}: Error: Database error occurred.`,
283287
])
@@ -299,9 +303,7 @@ describe('given the check domain permission function', () => {
299303
})
300304
await testCheckDomainPermission({ domainId: domain._id })
301305
} catch (err) {
302-
expect(err).toEqual(
303-
new Error('todo'),
304-
)
306+
expect(err).toEqual(new Error('todo'))
305307
expect(consoleOutput).toEqual([
306308
`Database error when retrieving affiliated organization claims for user: ${user._id} and domain: ${domain._id}: Error: Database error occurred.`,
307309
])
@@ -328,9 +330,7 @@ describe('given the check domain permission function', () => {
328330
})
329331
await testCheckDomainPermission({ domainId: domain._id })
330332
} catch (err) {
331-
expect(err).toEqual(
332-
new Error('todo'),
333-
)
333+
expect(err).toEqual(new Error('todo'))
334334
expect(consoleOutput).toEqual([
335335
`Cursor error when retrieving affiliated organization claims for user: ${user._id} and domain:${domain._id}: Error: Cursor error occurred.`,
336336
])

api-js/src/create-context.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,11 @@ module.exports.createContext = ({ context, req: request, res: response }) => {
103103
checkDomainOwnership: checkDomainOwnership({ i18n, userKey, query }),
104104
checkDomainPermission: checkDomainPermission({ i18n, userKey, query }),
105105
checkPermission: checkPermission({ i18n, userKey, query }),
106-
checkUserIsAdminForUser: checkUserIsAdminForUser({ i18n, userKey, query }),
106+
checkUserIsAdminForUser: checkUserIsAdminForUser({
107+
i18n,
108+
userKey,
109+
query,
110+
}),
107111
tokenize,
108112
userRequired: userRequired({
109113
i18n,

api-js/src/loaders/dmarc-report/__tests__/generate-detail-table-fields.test.js

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,12 @@ describe('given the generateDetailTableFields function', () => {
123123
const variables = {
124124
first: 5,
125125
}
126-
127-
const detailTableField = generateDetailTableFields({ subField, variables })
128-
126+
127+
const detailTableField = generateDetailTableFields({
128+
subField,
129+
variables,
130+
})
131+
129132
expect(detailTableField).toEqual({
130133
edgeSelection: '',
131134
pageInfoSelection: '',
@@ -154,9 +157,12 @@ describe('given the generateDetailTableFields function', () => {
154157
const variables = {
155158
last: 5,
156159
}
157-
158-
const detailTableField = generateDetailTableFields({ subField, variables })
159-
160+
161+
const detailTableField = generateDetailTableFields({
162+
subField,
163+
variables,
164+
})
165+
160166
expect(detailTableField).toEqual({
161167
edgeSelection: '',
162168
pageInfoSelection: '',
@@ -185,9 +191,12 @@ describe('given the generateDetailTableFields function', () => {
185191
const variables = {
186192
before: 'SGVsbG8xMjM0',
187193
}
188-
189-
const detailTableField = generateDetailTableFields({ subField, variables })
190-
194+
195+
const detailTableField = generateDetailTableFields({
196+
subField,
197+
variables,
198+
})
199+
191200
expect(detailTableField).toEqual({
192201
edgeSelection: '',
193202
pageInfoSelection: '',
@@ -216,9 +225,12 @@ describe('given the generateDetailTableFields function', () => {
216225
const variables = {
217226
after: 'SGVsbG8xMjM0',
218227
}
219-
220-
const detailTableField = generateDetailTableFields({ subField, variables })
221-
228+
229+
const detailTableField = generateDetailTableFields({
230+
subField,
231+
variables,
232+
})
233+
222234
expect(detailTableField).toEqual({
223235
edgeSelection: '',
224236
pageInfoSelection: '',

api-js/src/loaders/dmarc-report/generate-gql-query.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,14 @@ const generateGqlQuery = ({ generateDetailTableFields }) => ({
5353
if (arg.value.kind === 'Variable')
5454
if (arg.value.name.value === 'month') {
5555
queryArgs.push(
56-
`${arg.name.value}: ${
57-
String(info.variableValues[arg.value.name.value]).toUpperCase()
58-
}`,
56+
`${arg.name.value}: ${String(
57+
info.variableValues[arg.value.name.value],
58+
).toUpperCase()}`,
5959
)
6060
} else {
61-
if (typeof info.variableValues[arg.value.name.value] === 'string') {
61+
if (
62+
typeof info.variableValues[arg.value.name.value] === 'string'
63+
) {
6264
queryArgs.push(
6365
`${arg.name.value}: "${
6466
info.variableValues[arg.value.name.value]

api-js/src/loaders/domains/__tests__/load-domain-conn-org-id.test.js

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ const englishMessages = require('../../../locale/en/messages')
88
const frenchMessages = require('../../../locale/fr/messages')
99
const { makeMigrations } = require('../../../../migrations')
1010
const { cleanseInput } = require('../../../validators')
11-
const {
12-
domainLoaderConnectionsByOrgId,
13-
domainLoaderByKey,
14-
} = require('../..')
11+
const { domainLoaderConnectionsByOrgId, domainLoaderByKey } = require('../..')
1512
const { toGlobalId } = require('graphql-relay')
1613

1714
describe('given the load domain connection using org id function', () => {
@@ -29,7 +26,7 @@ describe('given the load domain connection using org id function', () => {
2926
let consoleOutput = []
3027
const mockedError = (output) => consoleOutput.push(output)
3128
const mockedWarn = (output) => consoleOutput.push(output)
32-
29+
3330
beforeAll(async () => {
3431
console.error = mockedError
3532
console.warn = mockedWarn
@@ -393,14 +390,14 @@ describe('given the load domain connection using org id function', () => {
393390
user._key,
394391
cleanseInput,
395392
)
396-
393+
397394
const domainLoader = domainLoaderByKey(query)
398395
const expectedDomains = await domainLoader.loadMany([
399396
domainThree._key,
400397
])
401-
398+
402399
expectedDomains[0].id = expectedDomains[0]._key
403-
400+
404401
const connectionArgs = {
405402
first: 5,
406403
}
@@ -409,7 +406,7 @@ describe('given the load domain connection using org id function', () => {
409406
ownership: true,
410407
...connectionArgs,
411408
})
412-
409+
413410
const expectedStructure = {
414411
edges: [
415412
{
@@ -427,7 +424,7 @@ describe('given the load domain connection using org id function', () => {
427424
},
428425
totalCount: 1,
429426
}
430-
427+
431428
expect(domains).toEqual(expectedStructure)
432429
})
433430
})
@@ -438,14 +435,14 @@ describe('given the load domain connection using org id function', () => {
438435
user._key,
439436
cleanseInput,
440437
)
441-
438+
442439
const domainLoader = domainLoaderByKey(query)
443440
const expectedDomains = await domainLoader.loadMany([
444441
domain._key,
445442
domainTwo._key,
446443
domainThree._key,
447444
])
448-
445+
449446
const connectionArgs = {
450447
first: 5,
451448
}
@@ -454,7 +451,7 @@ describe('given the load domain connection using org id function', () => {
454451
ownership: false,
455452
...connectionArgs,
456453
})
457-
454+
458455
const expectedStructure = {
459456
edges: [
460457
{
@@ -484,7 +481,7 @@ describe('given the load domain connection using org id function', () => {
484481
},
485482
totalCount: 3,
486483
}
487-
484+
488485
expect(domains).toEqual(expectedStructure)
489486
})
490487
})

api-js/src/loaders/email-scan/__tests__/load-dkim-connections-by-domain-id.test.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ const englishMessages = require('../../../locale/en/messages')
99
const frenchMessages = require('../../../locale/fr/messages')
1010
const { makeMigrations } = require('../../../../migrations')
1111
const { cleanseInput } = require('../../../validators')
12-
const {
13-
dkimLoaderConnectionsByDomainId,
14-
dkimLoaderByKey,
15-
} = require('../..')
12+
const { dkimLoaderConnectionsByDomainId, dkimLoaderByKey } = require('../..')
1613

1714
describe('when given the load dkim connection function', () => {
1815
let query, drop, truncate, migrate, collections, user, domain, i18n

api-js/src/loaders/email-scan/__tests__/load-dmarc-connections-by-domain-id.test.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ const englishMessages = require('../../../locale/en/messages')
99
const frenchMessages = require('../../../locale/fr/messages')
1010
const { makeMigrations } = require('../../../../migrations')
1111
const { cleanseInput } = require('../../../validators')
12-
const {
13-
dmarcLoaderConnectionsByDomainId,
14-
dmarcLoaderByKey,
15-
} = require('../..')
12+
const { dmarcLoaderConnectionsByDomainId, dmarcLoaderByKey } = require('../..')
1613

1714
describe('when given the load dmarc connection function', () => {
1815
let query, drop, truncate, migrate, collections, user, domain, i18n

api-js/src/loaders/organizations/__tests__/load-organization-connections-by-domain-id.test.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ const englishMessages = require('../../../locale/en/messages')
99
const frenchMessages = require('../../../locale/fr/messages')
1010
const { makeMigrations } = require('../../../../migrations')
1111
const { cleanseInput } = require('../../../validators')
12-
const {
13-
orgLoaderConnectionArgsByDomainId,
14-
orgLoaderByKey,
15-
} = require('../..')
12+
const { orgLoaderConnectionArgsByDomainId, orgLoaderByKey } = require('../..')
1613

1714
describe('given the load organizations connection function', () => {
1815
let query,

api-js/src/loaders/verified-domains/__tests__/load-verified-domain-connections.test.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ const englishMessages = require('../../../locale/en/messages')
88
const frenchMessages = require('../../../locale/fr/messages')
99
const { makeMigrations } = require('../../../../migrations')
1010
const { cleanseInput } = require('../../../validators')
11-
const {
12-
verifiedDomainLoaderConnections,
13-
domainLoaderByKey,
14-
} = require('../..')
11+
const { verifiedDomainLoaderConnections, domainLoaderByKey } = require('../..')
1512
const { toGlobalId } = require('graphql-relay')
1613

1714
describe('given the load domain connection using org id function', () => {

0 commit comments

Comments
 (0)