11import nock from 'nock'
22
3- import graphDbDatasource from '../graphDb '
3+ import graphDbRelatedCollectionsDatasource from '../graphDbRelatedCollections '
44
55import relatedCollectionsGraphDbPlatformInstrumentGraphdbResponseMocks from './__mocks__/relatedCollections.graphDbPlatformInstrument.graphdbResponse.mocks'
66import relatedCollectionsGraphDbPlatformInstrumentResponseMocks from './__mocks__/relatedCollections.graphDbPlatformInstrument.response.mocks'
@@ -168,7 +168,7 @@ describe('graphDb', () => {
168168 } )
169169 . reply ( 200 , relatedCollectionsRelatedUrlTypeGraphdbResponseMocks )
170170
171- const response = await graphDbDatasource (
171+ const response = await graphDbRelatedCollectionsDatasource (
172172 { conceptId : 'C100000-EDSC' } ,
173173 {
174174 limit : 1 ,
@@ -207,7 +207,7 @@ describe('graphDb', () => {
207207 } )
208208 . reply ( 200 , relatedCollectionsRelatedUrlSubtypeGraphdbResponseMocks )
209209
210- const response = await graphDbDatasource (
210+ const response = await graphDbRelatedCollectionsDatasource (
211211 { conceptId : 'C100000-EDSC' } ,
212212 {
213213 limit : 1 ,
@@ -251,7 +251,7 @@ describe('graphDb', () => {
251251 } )
252252 . reply ( 200 , relatedCollectionsRelatedUrlTypeAndSubtypeGraphdbResponseMocks )
253253
254- const response = await graphDbDatasource (
254+ const response = await graphDbRelatedCollectionsDatasource (
255255 { conceptId : 'C100000-EDSC' } ,
256256 {
257257 limit : 1 ,
@@ -354,7 +354,7 @@ describe('graphDb', () => {
354354 } )
355355 . reply ( 200 , relatedCollectionsGraphDbProjectGraphdbResponseMocks )
356356
357- const response = await graphDbDatasource (
357+ const response = await graphDbRelatedCollectionsDatasource (
358358 { conceptId : 'C100000-EDSC' } ,
359359 {
360360 limit : 1
@@ -459,7 +459,7 @@ describe('graphDb', () => {
459459 } )
460460 . reply ( 200 , relatedCollectionsGraphDbPlatformInstrumentGraphdbResponseMocks )
461461
462- const response = await graphDbDatasource (
462+ const response = await graphDbRelatedCollectionsDatasource (
463463 { conceptId : 'C100000-EDSC' } ,
464464 {
465465 limit : 1
@@ -576,7 +576,7 @@ describe('graphDb', () => {
576576 } )
577577 . reply ( 200 , relatedCollectionsGraphDbRelatedUrlGraphdbResponseMocks )
578578
579- const response = await graphDbDatasource (
579+ const response = await graphDbRelatedCollectionsDatasource (
580580 { conceptId : 'C100000-EDSC' } ,
581581 {
582582 limit : 1
@@ -696,7 +696,7 @@ describe('graphDb', () => {
696696 } )
697697 . reply ( 200 , relatedCollectionsGraphDbRelatedUrlGraphdbResponseMocks )
698698
699- const response = await graphDbDatasource (
699+ const response = await graphDbRelatedCollectionsDatasource (
700700 { conceptId : 'C100000-EDSC' } ,
701701 {
702702 limit : 1 ,
@@ -827,7 +827,7 @@ describe('graphDb', () => {
827827 } )
828828 . reply ( 200 , relatedCollectionsGraphDbRelatedUrlProjectGraphdbResponseMocks )
829829
830- const response = await graphDbDatasource (
830+ const response = await graphDbRelatedCollectionsDatasource (
831831 { conceptId : 'C100000-EDSC' } ,
832832 {
833833 limit : 1 ,
@@ -957,7 +957,7 @@ describe('graphDb', () => {
957957 } )
958958 . reply ( 200 , relatedCollectionsGraphDbRelatedUrlRelationshipTypeGraphdbResponseMocks )
959959
960- const response = await graphDbDatasource (
960+ const response = await graphDbRelatedCollectionsDatasource (
961961 { conceptId : 'C100000-EDSC' } ,
962962 {
963963 limit : 1 ,
@@ -1063,7 +1063,7 @@ describe('graphDb', () => {
10631063 } )
10641064 . reply ( 200 , relatedCollectionsGraphDbCitationGraphdbResponseMocks )
10651065
1066- const response = await graphDbDatasource (
1066+ const response = await graphDbRelatedCollectionsDatasource (
10671067 { conceptId : 'C100000-EDSC' } ,
10681068 {
10691069 limit : 1
@@ -1174,7 +1174,7 @@ describe('graphDb', () => {
11741174 } )
11751175 . reply ( 200 , relatedCollectionsGraphDbScienceKeywordGraphdbResponseMocks )
11761176
1177- const response = await graphDbDatasource (
1177+ const response = await graphDbRelatedCollectionsDatasource (
11781178 { conceptId : 'C100000-EDSC' } ,
11791179 {
11801180 limit : 1
@@ -1305,7 +1305,7 @@ describe('graphDb', () => {
13051305 } )
13061306 . reply ( 200 , relatedCollectionsGraphDbRelatedUrlCitationGraphdbResponseMocks )
13071307
1308- const response = await graphDbDatasource (
1308+ const response = await graphDbRelatedCollectionsDatasource (
13091309 { conceptId : 'C100000-EDSC' } ,
13101310 {
13111311 limit : 1
@@ -1403,7 +1403,7 @@ describe('graphDb', () => {
14031403 } )
14041404 . reply ( 200 , relatedCollectionsRelationshipTypeGraphdbResponseMocks )
14051405
1406- const response = await graphDbDatasource (
1406+ const response = await graphDbRelatedCollectionsDatasource (
14071407 { conceptId : 'C100000-EDSC' } ,
14081408 {
14091409 limit : 1
@@ -1480,7 +1480,7 @@ describe('graphDb', () => {
14801480 } )
14811481 . reply ( 200 , relatedCollectionsNoRelationshipsGraphDbResponseMock )
14821482
1483- const response = await graphDbDatasource (
1483+ const response = await graphDbRelatedCollectionsDatasource (
14841484 { conceptId : 'C100000-EDSC' } ,
14851485 {
14861486 limit : 1
@@ -1500,8 +1500,8 @@ describe('graphDb', () => {
15001500 } )
15011501 } )
15021502
1503- describe ( 'Testing permitted groups on related collections' , ( ) => {
1504- test ( 'Testing that permitted groups is in the post request' , async ( ) => {
1503+ describe ( 'When the related collections are behind permitted groups ' , ( ) => {
1504+ test ( 'Testing that permitted groups are in the gremlin request' , async ( ) => {
15051505 nock ( / e x a m p l e - g r a p h d b / )
15061506 . post ( '/' , ( body ) => {
15071507 const parsedBody = typeof body === 'string' ? JSON . parse ( body ) : body
@@ -1539,7 +1539,7 @@ describe('graphDb', () => {
15391539 ]
15401540 } )
15411541
1542- const response = await graphDbDatasource (
1542+ const response = await graphDbRelatedCollectionsDatasource (
15431543 { conceptId : 'C100000-EDSC' } ,
15441544 {
15451545 limit : 1
@@ -1556,40 +1556,42 @@ describe('graphDb', () => {
15561556 expect ( response ) . toEqual ( relatedCollectionsRelationshipTypeResponseMocks )
15571557 } )
15581558
1559- test ( 'Mocking the response for a client not being in any groups, and retrieving no related collections' , async ( ) => {
1560- nock ( / e x a m p l e - g r a p h d b / )
1561- . post ( '/' , ( body ) => {
1562- const parsedBody = typeof body === 'string' ? JSON . parse ( body ) : body
1563- const gremlinQuery = parsedBody ?. gremlin || ''
1559+ describe ( 'when the user is in no groups' , ( ) => {
1560+ test ( 'the response contains no related collections' , async ( ) => {
1561+ nock ( / e x a m p l e - g r a p h d b / )
1562+ . post ( '/' , ( body ) => {
1563+ const parsedBody = typeof body === 'string' ? JSON . parse ( body ) : body
1564+ const gremlinQuery = parsedBody ?. gremlin || ''
15641565
1565- const hasCorrectPermittedGroups = gremlinQuery . includes ( 'within(\'registered\',\'guest\')' )
1566- const hasOtherV = gremlinQuery . includes ( '.otherV()' )
1566+ const hasCorrectPermittedGroups = gremlinQuery . includes ( 'within(\'registered\',\'guest\')' )
1567+ const hasOtherV = gremlinQuery . includes ( '.otherV()' )
15671568
1568- return hasCorrectPermittedGroups && hasOtherV
1569- } )
1570- . reply ( 200 , relatedCollectionsResponseEmptyMocks )
1569+ return hasCorrectPermittedGroups && hasOtherV
1570+ } )
1571+ . reply ( 200 , relatedCollectionsResponseEmptyMocks )
15711572
1572- nock ( / e x a m p l e - u r s / )
1573- . get ( / g r o u p s _ f o r _ u s e r / )
1574- . reply ( 200 , { } )
1573+ nock ( / e x a m p l e - u r s / )
1574+ . get ( / g r o u p s _ f o r _ u s e r / )
1575+ . reply ( 200 , { } )
15751576
1576- const response = await graphDbDatasource (
1577- { conceptId : 'C100000-EDSC' } ,
1578- {
1579- limit : 1
1580- } ,
1581- {
1582- headers : {
1583- 'Client-Id' : 'eed-test-graphql' ,
1584- 'CMR-Request-Id' : 'abcd-1234-efgh-5678'
1577+ const response = await graphDbRelatedCollectionsDatasource (
1578+ { conceptId : 'C100000-EDSC' } ,
1579+ {
1580+ limit : 1
15851581 } ,
1586- edlUsername : 'someEdlUsername'
1587- } ,
1588- parsedInfo
1589- )
1590- expect ( response ) . toEqual ( {
1591- count : 0 ,
1592- items : [ ]
1582+ {
1583+ headers : {
1584+ 'Client-Id' : 'eed-test-graphql' ,
1585+ 'CMR-Request-Id' : 'abcd-1234-efgh-5678'
1586+ } ,
1587+ edlUsername : 'someEdlUsername'
1588+ } ,
1589+ parsedInfo
1590+ )
1591+ expect ( response ) . toEqual ( {
1592+ count : 0 ,
1593+ items : [ ]
1594+ } )
15931595 } )
15941596 } )
15951597 } )
0 commit comments