11import { describe , it , beforeEach , afterEach , expect , afterAll } from 'vitest'
22import type { ConceptProps , CreateConceptProps } from '../../lib/entities/concept'
33import type { ConceptSchemeProps , CreateConceptSchemeProps } from '../../lib/export-types'
4- import { getTestOrganizationId , initPlainClient , timeoutToCalmRateLimiting } from '../helpers'
4+ import {
5+ getTestOrganizationId ,
6+ initPlainClient ,
7+ promiseAllSequential ,
8+ timeoutToCalmRateLimiting ,
9+ } from '../helpers'
510
611let conceptsToDelete : ConceptProps [ ] = [ ]
712let conceptSchemesToDelete : ConceptSchemeProps [ ] = [ ]
@@ -214,7 +219,7 @@ describe('Taxonomy Integration', () => {
214219 } )
215220
216221 it ( 'concept getTotal' , async ( ) => {
217- await Promise . all (
222+ await promiseAllSequential (
218223 Array ( 3 )
219224 . fill ( null )
220225 . map ( async ( i ) => {
@@ -235,7 +240,7 @@ describe('Taxonomy Integration', () => {
235240 } )
236241
237242 it ( 'gets a list of all concepts' , async ( ) => {
238- await Promise . all (
243+ await promiseAllSequential (
239244 Array ( 3 )
240245 . fill ( null )
241246 . map ( async ( i ) => {
@@ -255,7 +260,7 @@ describe('Taxonomy Integration', () => {
255260 } )
256261
257262 it ( 'gets a list of all paginated concepts' , async ( ) => {
258- await Promise . all (
263+ await promiseAllSequential (
259264 Array ( 3 )
260265 . fill ( null )
261266 . map ( async ( i ) => {
@@ -526,7 +531,7 @@ describe('Taxonomy Integration', () => {
526531 } )
527532
528533 it ( 'conceptScheme getTotal' , async ( ) => {
529- await Promise . all (
534+ const results = await promiseAllSequential (
530535 Array ( 3 )
531536 . fill ( null )
532537 . map ( async ( i ) => {
@@ -536,18 +541,19 @@ describe('Taxonomy Integration', () => {
536541 } ,
537542 }
538543
539- const result = await client . conceptScheme . create ( { } , conceptScheme )
540- conceptSchemesToDelete . push ( result )
544+ return client . conceptScheme . create ( { } , conceptScheme )
541545 } ) ,
542546 )
543547
548+ conceptSchemesToDelete . push ( ...results )
549+
544550 const { total } = await client . conceptScheme . getTotal ( { } )
545551
546552 expect ( total ) . toBe ( 3 )
547553 } )
548554
549555 it ( 'gets a list of all concept schemes' , async ( ) => {
550- await Promise . all (
556+ const results = await promiseAllSequential (
551557 Array ( 3 )
552558 . fill ( null )
553559 . map ( async ( i ) => {
@@ -557,17 +563,18 @@ describe('Taxonomy Integration', () => {
557563 } ,
558564 }
559565
560- const result = await client . conceptScheme . create ( { } , conceptScheme )
561- conceptSchemesToDelete . push ( result )
566+ return client . conceptScheme . create ( { } , conceptScheme )
562567 } ) ,
563568 )
564569
570+ conceptSchemesToDelete . push ( ...results )
571+
565572 const { items } = await client . conceptScheme . getMany ( { } )
566573 expect ( items . length ) . toBe ( 3 )
567574 } )
568575
569576 it ( 'gets a list of all paginated concept schemes' , async ( ) => {
570- await Promise . all (
577+ const results = await promiseAllSequential (
571578 Array ( 3 )
572579 . fill ( null )
573580 . map ( async ( i ) => {
@@ -577,11 +584,12 @@ describe('Taxonomy Integration', () => {
577584 } ,
578585 }
579586
580- const result = await client . conceptScheme . create ( { } , conceptScheme )
581- conceptSchemesToDelete . push ( result )
587+ return client . conceptScheme . create ( { } , conceptScheme )
582588 } ) ,
583589 )
584590
591+ conceptSchemesToDelete . push ( ...results )
592+
585593 const { items, pages } = await client . conceptScheme . getMany ( {
586594 query : {
587595 limit : 2 ,
0 commit comments