Skip to content

Commit f4f11ce

Browse files
authored
GQL-130: Exposing associated citations from CMR on Collection and disable associatedCitations from graphdb for now (#176)
* GQL-130: Exposing associated citations from CMR on Collection * GQL-130: Removing .only test * GQL-130: Removing associatedCitations * GQL-130: Test coverage and comment fixing
1 parent 62c4584 commit f4f11ce

File tree

5 files changed

+691
-299
lines changed

5 files changed

+691
-299
lines changed

src/datasources/__tests__/graphDbAssociatedCitations.test.js

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,4 +1018,75 @@ describe('graphDbAssociatedCitations', () => {
10181018
expect(response).toEqual(associatedCitationsResponseMocks)
10191019
})
10201020
})
1021+
1022+
describe('when no limit is specified', () => {
1023+
beforeEach(() => {
1024+
parsedInfo = {
1025+
fieldsByTypeName: {
1026+
CitationList: {
1027+
items: {
1028+
fieldsByTypeName: {
1029+
Citation: {
1030+
conceptId: {
1031+
name: 'conceptId',
1032+
alias: 'conceptId',
1033+
args: {},
1034+
fieldsByTypeName: {}
1035+
}
1036+
}
1037+
}
1038+
}
1039+
}
1040+
}
1041+
}
1042+
})
1043+
1044+
test('uses default limit of 20', async () => {
1045+
const getUserGroups = vi.spyOn(getUserPermittedGroups, 'getUserPermittedGroups')
1046+
getUserGroups.mockImplementationOnce(() => '"guest","registered"')
1047+
1048+
nock(/example-graphdb/)
1049+
.post('/', (body) => {
1050+
const { gremlin } = body
1051+
1052+
return gremlin
1053+
&& gremlin.includes("hasLabel('citation')")
1054+
&& gremlin.includes("has('collection', 'id', 'C1200000035-PROV2')")
1055+
&& gremlin.includes('.range(0, 20)') // Check for default limit
1056+
})
1057+
.reply(200, {
1058+
result: {
1059+
data: {
1060+
'@value': [
1061+
{
1062+
'@type': 'g:Map',
1063+
'@value': ['citations', {
1064+
'@type': 'g:List',
1065+
'@value': []
1066+
}, 'totalCount', {
1067+
'@type': 'g:Int64',
1068+
'@value': 0
1069+
}]
1070+
}
1071+
]
1072+
}
1073+
}
1074+
})
1075+
1076+
await graphDbAssociatedCitations(
1077+
{ conceptId: 'C1200000035-PROV2' },
1078+
{}, // Empty params object
1079+
{
1080+
headers: {
1081+
'Client-Id': 'eed-test-graphql',
1082+
'CMR-Request-Id': 'abcd-1234-efgh-5678'
1083+
},
1084+
edlUsername: 'testUser'
1085+
},
1086+
parsedInfo
1087+
)
1088+
1089+
expect(nock.isDone()).toBe(true)
1090+
})
1091+
})
10211092
})

0 commit comments

Comments
 (0)