diff --git a/src/cmr/concepts/collection.js b/src/cmr/concepts/collection.js index 66a4845cc..251a8b4c4 100644 --- a/src/cmr/concepts/collection.js +++ b/src/cmr/concepts/collection.js @@ -334,7 +334,7 @@ export default class Collection extends Concept { * @param {Object} item The item returned from the CMR umm endpoint */ normalizeUmmItem(item) { - const { umm } = item + const { umm = {} } = item const { ArchiveAndDistributionInformation: archiveAndDistributionInformation = {} } = umm diff --git a/src/resolvers/__tests__/collection.test.js b/src/resolvers/__tests__/collection.test.js index dde96affb..461aec7e9 100644 --- a/src/resolvers/__tests__/collection.test.js +++ b/src/resolvers/__tests__/collection.test.js @@ -708,6 +708,110 @@ describe('Collection', () => { collection: null }) }) + + describe('when retrieving revisions that contain tombstones', () => { + test('includes them in the results', async () => { + nock(/example-cmr/) + .defaultReplyHeaders({ + 'CMR-Hits': 1, + 'CMR-Took': 7, + 'CMR-Request-Id': 'abcd-1234-efgh-5678' + }) + .get(/collections\.json/) + .reply(200, { + feed: { + entry: [{ + id: 'C100001-EDSC' + }], + facets: {} + } + }) + + nock(/example-cmr/) + .defaultReplyHeaders({ + 'CMR-Hits': 3, + 'CMR-Took': 7, + 'CMR-Request-Id': 'abcd-1234-efgh-5678' + }) + .get('/search/collections.umm_json?all_revisions=true&concept_id=C100001-EDSC') + .reply(200, { + items: [{ + meta: { + 'concept-id': 'C100001-EDSC', + 'revision-id': '3', + deleted: false + }, + umm: { + Abstract: 'Cras mattis consectetur purus sit amet fermentum.' + } + }, { + meta: { + 'concept-id': 'C100001-EDSC', + 'revision-id': '2', + deleted: true + } + }, { + meta: { + 'concept-id': 'C100001-EDSC', + 'revision-id': '1', + deleted: false + }, + umm: { + Abstract: 'Cras mattis consectetur purus sit amet fermentum.' + } + }] + }) + + const response = await server.executeOperation({ + variables: {}, + query: `{ + collections { + count + facets + items { + conceptId + revisions { + count + items { + revisionId + } + } + } + } + }` + }, { + contextValue + }) + + const { data, errors } = response.body.singleResult + + expect(errors).toBeUndefined() + + expect(data).toEqual({ + collections: { + count: 1, + facets: {}, + items: [{ + conceptId: 'C100001-EDSC', + revisions: { + count: 3, + items: [ + { + revisionId: '3' + }, + { + revisionId: '2' + }, + { + revisionId: '1' + } + ] + } + }] + } + }) + }) + }) }) }) })