Skip to content

Commit

Permalink
MMT-3702: Removes the collection conceptId check for publish variable…
Browse files Browse the repository at this point in the history
… draft (#125)
  • Loading branch information
dmistry1 authored Jun 12, 2024
1 parent f10a930 commit 3e61d39
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 118 deletions.
106 changes: 1 addition & 105 deletions src/resolvers/__tests__/draft.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1330,58 +1330,6 @@ describe('Draft', () => {
}
})
})

test('returns an error when collection concept id not provided', async () => {
nock(/example-cmr/, {
reqheaders: {
accept: 'application/json',
'client-id': 'eed-test-graphql',
'content-type': 'application/vnd.nasa.cmr.umm+json; version=1.0.0',
'cmr-request-id': 'abcd-1234-efgh-5678'
}
})
.defaultReplyHeaders({
'CMR-Took': 7,
'CMR-Request-Id': 'abcd-1234-efgh-5678'
})
.put(/ingest\/publish\/TD100000-EDSC\/tool-1/)
.reply(201, {
'concept-id': 'T100000-EDSC',
'revision-id': '1'
})

const response = await server.executeOperation({
variables: {
draftConceptId: 'TD100000-EDSC',
nativeId: 'tool-1',
ummVersion: '1.0.0',
collectionConceptId: 'C100000-EDSC'
},
query: `mutation PublishDraft(
$draftConceptId: String!
$nativeId: String!
$ummVersion: String!
$collectionConceptId: String
) {
publishDraft(
draftConceptId: $draftConceptId
nativeId: $nativeId
ummVersion: $ummVersion
collectionConceptId: $collectionConceptId
) {
conceptId
revisionId
warnings
existingErrors
}
}`
}, {
contextValue
})
const { errors } = response.body.singleResult
const { message } = errors[0]
expect(message).toEqual('Invalid Argument, collectionConceptId. Collection Concept ID is only required when publishing a Variable Draft.')
})
})
})
})
Expand Down Expand Up @@ -1784,20 +1732,17 @@ describe('Draft', () => {
variables: {
draftConceptId: 'VD100000-EDSC',
nativeId: 'variable-1',
ummVersion: '1.0.0',
collectionConceptId: 'C100000-EDSC'
ummVersion: '1.0.0'
},
query: `mutation PublishDraft(
$draftConceptId: String!
$nativeId: String!
$ummVersion: String!
$collectionConceptId: String
) {
publishDraft(
draftConceptId: $draftConceptId
nativeId: $nativeId
ummVersion: $ummVersion
collectionConceptId: $collectionConceptId
) {
conceptId
revisionId
Expand All @@ -1820,55 +1765,6 @@ describe('Draft', () => {
}
})
})

test('returns an error when collection concept id not provided', async () => {
nock(/example-cmr/, {
reqheaders: {
accept: 'application/json',
'client-id': 'eed-test-graphql',
'content-type': 'application/vnd.nasa.cmr.umm+json; version=1.0.0',
'cmr-request-id': 'abcd-1234-efgh-5678'
}
})
.defaultReplyHeaders({
'CMR-Took': 7,
'CMR-Request-Id': 'abcd-1234-efgh-5678'
})
.put(/ingest\/publish\/VD100000-EDSC\/variable-1/)
.reply(201, {
'concept-id': 'V100000-EDSC',
'revision-id': '1'
})

const response = await server.executeOperation({
variables: {
draftConceptId: 'VD100000-EDSC',
nativeId: 'variable-1',
ummVersion: '1.0.0'
},
query: `mutation PublishDraft(
$draftConceptId: String!
$nativeId: String!
$ummVersion: String!
) {
publishDraft(
draftConceptId: $draftConceptId
nativeId: $nativeId
ummVersion: $ummVersion
) {
conceptId
revisionId
warnings
existingErrors
}
}`
}, {
contextValue
})
const { errors } = response.body.singleResult
const { message } = errors[0]
expect(message).toEqual('collectionConceptId required. When publishing a Variable Draft, an associated Collection Concept Id is required')
})
})
})
})
Expand Down
11 changes: 0 additions & 11 deletions src/resolvers/draft.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,6 @@ export default {
},
publishDraft: async (source, args, context, info) => {
const { dataSources } = context
const { draftConceptId, collectionConceptId } = args

// Checks if collectionConceptId is present when publishing a Variable Draft
if (isDraftConceptId(draftConceptId, 'variable') && !collectionConceptId) {
throw new Error('collectionConceptId required. When publishing a Variable Draft, an associated Collection Concept Id is required')
}

// Checks if collectionConcept is present when publishing a non Variable draft
if (!isDraftConceptId(draftConceptId, 'variable') && collectionConceptId) {
throw new Error('Invalid Argument, collectionConceptId. Collection Concept ID is only required when publishing a Variable Draft.')
}

const result = await dataSources.draftSourcePublish(
args,
Expand Down
2 changes: 0 additions & 2 deletions src/types/draft.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ type Mutation {
nativeId: String!
"UMM Version of the record being published."
ummVersion: String!
"Associated Collection concept-id "
collectionConceptId: String
): PublishDraftMutationResponse
}

Expand Down

0 comments on commit 3e61d39

Please sign in to comment.