Skip to content

Commit 0120187

Browse files
authored
GQL-135: Add collectionProgress as search parameter for collections (#179)
* GQL-135: Add collectionProgress as search parameter for collections * GQL-135: Npm audit fix * GQL-135: Add search for array of collectionProgress * GQL-135: Revert changes, update packages in a separated ticket * GQL-135: Fix tests, add providers * GQL-135: Fix test * GQL-135: Update field comments
1 parent 881c63e commit 0120187

5 files changed

Lines changed: 372 additions & 0 deletions

File tree

src/cmr/concepts/collection.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export default class Collection extends Concept {
5252
'cloud_hosted',
5353
'collection_concept_id',
5454
'collection_data_type',
55+
'collection_progress',
5556
'consortium',
5657
'data_center',
5758
'data_center_h',
@@ -112,6 +113,7 @@ export default class Collection extends Concept {
112113
'cloud_hosted',
113114
'collection_concept_id',
114115
'collection_data_type',
116+
'collection_progress',
115117
'consortium',
116118
'data_center',
117119
'data_center_h',
@@ -167,6 +169,7 @@ export default class Collection extends Concept {
167169
'bounding_box',
168170
'circle',
169171
'collection_data_type',
172+
'collection_progress',
170173
'concept_id',
171174
'consortium',
172175
'data_center',

src/cmr/concepts/concept.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@ export default class Concept {
4848

4949
this.arrayifiableKeys = {
5050
collectionConceptIds: 'collectionConceptId',
51+
collectionProgresses: 'collectionProgress',
5152
conceptIds: 'conceptId',
5253
dataCenters: 'dataCenter',
54+
providers: 'provider',
5355
providerIds: 'providerId',
5456
permittedGroups: 'permittedGroup',
5557
shortNames: 'shortName'

src/datasources/__tests__/collection.test.js

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,206 @@ describe('collection', () => {
321321
})
322322
})
323323

324+
describe('with collectionProgress param', () => {
325+
beforeEach(() => {
326+
// Overwrite default requestInfo to include collectionProgress
327+
requestInfo = {
328+
name: 'collections',
329+
alias: 'collections',
330+
args: {},
331+
fieldsByTypeName: {
332+
CollectionList: {
333+
items: {
334+
name: 'items',
335+
alias: 'items',
336+
args: {},
337+
fieldsByTypeName: {
338+
Collection: {
339+
conceptId: {
340+
name: 'conceptId',
341+
alias: 'conceptId',
342+
args: {},
343+
fieldsByTypeName: {}
344+
},
345+
collectionProgress: {
346+
name: 'collectionProgress',
347+
alias: 'collectionProgress',
348+
args: {},
349+
fieldsByTypeName: {}
350+
}
351+
}
352+
}
353+
}
354+
}
355+
}
356+
}
357+
})
358+
359+
test('returns the parsed collection results', async () => {
360+
nock(/example-cmr/)
361+
.defaultReplyHeaders({
362+
'CMR-Hits': 1,
363+
'CMR-Took': 7,
364+
'CMR-Request-Id': 'abcd-1234-efgh-5678'
365+
})
366+
.get(/collections\.json/)
367+
.query({ collection_progress: 'COMPLETE' })
368+
.reply(200, {
369+
feed: {
370+
entry: [{
371+
id: 'C100000-EDSC'
372+
}]
373+
}
374+
})
375+
376+
nock(/example-cmr/)
377+
.defaultReplyHeaders({
378+
'CMR-Hits': 1,
379+
'CMR-Took': 7,
380+
'CMR-Request-Id': 'abcd-1234-efgh-5678'
381+
})
382+
.get(/collections\.umm_json/)
383+
.query({ collection_progress: 'COMPLETE' })
384+
.reply(200, {
385+
hits: 1,
386+
items: [{
387+
meta: {
388+
'concept-id': 'C100000-EDSC'
389+
},
390+
umm: {
391+
CollectionProgress: 'COMPLETE'
392+
}
393+
}]
394+
})
395+
396+
const response = await collectionSourceFetch({
397+
params: {
398+
collectionProgress: 'COMPLETE'
399+
}
400+
}, {
401+
headers: {
402+
'Client-Id': 'eed-test-graphql',
403+
'CMR-Request-Id': 'abcd-1234-efgh-5678'
404+
}
405+
}, requestInfo)
406+
407+
expect(response).toEqual({
408+
count: 1,
409+
cursor: null,
410+
items: [{
411+
conceptId: 'C100000-EDSC',
412+
collectionProgress: 'COMPLETE'
413+
}]
414+
})
415+
})
416+
})
417+
418+
describe('with collectionProgresses param', () => {
419+
beforeEach(() => {
420+
// Overwrite default requestInfo to include collectionProgress
421+
requestInfo = {
422+
name: 'collections',
423+
alias: 'collections',
424+
args: {},
425+
fieldsByTypeName: {
426+
CollectionList: {
427+
items: {
428+
name: 'items',
429+
alias: 'items',
430+
args: {},
431+
fieldsByTypeName: {
432+
Collection: {
433+
conceptId: {
434+
name: 'conceptId',
435+
alias: 'conceptId',
436+
args: {},
437+
fieldsByTypeName: {}
438+
},
439+
collectionProgress: {
440+
name: 'collectionProgress',
441+
alias: 'collectionProgress',
442+
args: {},
443+
fieldsByTypeName: {}
444+
}
445+
}
446+
}
447+
}
448+
}
449+
}
450+
}
451+
})
452+
453+
test('returns the parsed collection results', async () => {
454+
nock(/example-cmr/)
455+
.defaultReplyHeaders({
456+
'CMR-Hits': 2,
457+
'CMR-Took': 7,
458+
'CMR-Request-Id': 'abcd-1234-efgh-5678'
459+
})
460+
.get(/collections\.json/)
461+
.query({ 'collection_progress[]': ['COMPLETE', 'ACTIVE'] })
462+
.reply(200, {
463+
feed: {
464+
entry: [{
465+
id: 'C100000-EDSC'
466+
}, {
467+
id: 'C100001-EDSC'
468+
}]
469+
}
470+
})
471+
472+
nock(/example-cmr/)
473+
.defaultReplyHeaders({
474+
'CMR-Hits': 2,
475+
'CMR-Took': 7,
476+
'CMR-Request-Id': 'abcd-1234-efgh-5678'
477+
})
478+
.get(/collections\.umm_json/)
479+
.query({ 'collection_progress[]': ['COMPLETE', 'ACTIVE'] })
480+
.reply(200, {
481+
hits: 2,
482+
items: [{
483+
meta: {
484+
'concept-id': 'C100000-EDSC'
485+
},
486+
umm: {
487+
CollectionProgress: 'COMPLETE'
488+
}
489+
}, {
490+
meta: {
491+
'concept-id': 'C100001-EDSC'
492+
},
493+
umm: {
494+
CollectionProgress: 'ACTIVE'
495+
}
496+
}]
497+
})
498+
499+
const response = await collectionSourceFetch({
500+
params: {
501+
collectionProgresses: ['COMPLETE', 'ACTIVE']
502+
}
503+
}, {
504+
headers: {
505+
'Client-Id': 'eed-test-graphql',
506+
'CMR-Request-Id': 'abcd-1234-efgh-5678'
507+
}
508+
}, requestInfo)
509+
510+
expect(response).toEqual({
511+
count: 2,
512+
cursor: null,
513+
items: [{
514+
conceptId: 'C100000-EDSC',
515+
collectionProgress: 'COMPLETE'
516+
}, {
517+
conceptId: 'C100001-EDSC',
518+
collectionProgress: 'ACTIVE'
519+
}]
520+
})
521+
})
522+
})
523+
324524
describe('with json and umm keys', () => {
325525
beforeEach(() => {
326526
// Overwrite default requestInfo

0 commit comments

Comments
 (0)