Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GQL-85: Cannot view collection when a revision doesn't have UMM #146

Merged
merged 4 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cmr/concepts/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
104 changes: 104 additions & 0 deletions src/resolvers/__tests__/collection.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
]
}
}]
}
})
})
})
})
})
})
Expand Down