@@ -1394,6 +1394,49 @@ describe('datasets and entities', () => {
1394
1394
] ) ;
1395
1395
} ) ) ;
1396
1396
1397
+ it ( 'should not return a form draft as a linked form' , testService ( async ( service ) => {
1398
+ const asAlice = await service . login ( 'alice' ) ;
1399
+ await asAlice . post ( '/v1/projects/1/forms' )
1400
+ . send ( testData . forms . withAttachments
1401
+ . replace ( 'goodone.csv' , 'people.csv' ) )
1402
+ . set ( 'Content-Type' , 'application/xml' )
1403
+ . expect ( 200 ) ;
1404
+ await asAlice . post ( '/v1/projects/1/forms/withAttachments/draft/attachments/people.csv' )
1405
+ . send ( 'test,csv\n1,2' )
1406
+ . set ( 'Content-Type' , 'text/csv' )
1407
+ . expect ( 200 ) ;
1408
+ await asAlice . post ( '/v1/projects/1/forms/withAttachments/draft/publish' )
1409
+ . expect ( 200 ) ;
1410
+ await asAlice . post ( '/v1/projects/1/forms?publish=true' )
1411
+ . send ( testData . forms . simpleEntity )
1412
+ . set ( 'Content-Type' , 'application/xml' )
1413
+ . expect ( 200 ) ;
1414
+ await asAlice . post ( '/v1/projects/1/forms/withAttachments/draft' )
1415
+ . expect ( 200 ) ;
1416
+ await asAlice . patch ( '/v1/projects/1/forms/withAttachments/draft/attachments/people.csv' )
1417
+ . send ( { dataset : true } )
1418
+ . expect ( 200 ) ;
1419
+ const { body : publishedAttachments } = await asAlice . get ( '/v1/projects/1/forms/withAttachments/attachments' )
1420
+ . expect ( 200 ) ;
1421
+ const publishedCSV = publishedAttachments . find ( attachment =>
1422
+ attachment . name === 'people.csv' ) ;
1423
+ publishedCSV . should . containEql ( {
1424
+ blobExists : true ,
1425
+ datasetExists : false
1426
+ } ) ;
1427
+ const { body : draftAttachments } = await asAlice . get ( '/v1/projects/1/forms/withAttachments/draft/attachments' )
1428
+ . expect ( 200 ) ;
1429
+ const draftCSV = draftAttachments . find ( attachment =>
1430
+ attachment . name === 'people.csv' ) ;
1431
+ draftCSV . should . containEql ( {
1432
+ blobExists : false ,
1433
+ datasetExists : true
1434
+ } ) ;
1435
+ const { body : dataset } = await asAlice . get ( '/v1/projects/1/datasets/people' )
1436
+ . expect ( 200 ) ;
1437
+ dataset . linkedForms . length . should . equal ( 0 ) ;
1438
+ } ) ) ;
1439
+
1397
1440
it ( 'should return properties of a dataset in order' , testService ( async ( service ) => {
1398
1441
const asAlice = await service . login ( 'alice' ) ;
1399
1442
0 commit comments