Skip to content

Commit b9d0422

Browse files
committed
Update LinkCollection.test.ts
1 parent 8d47d04 commit b9d0422

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

test/functional/collections/LinkCollection.test.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import { createCollectionDTO } from '../../testHelpers/collections/collectionHel
1414
describe('execute', () => {
1515
const firstCollectionAlias = 'linkCollection-functional-test-first'
1616
const secondCollectionAlias = 'linkCollection-functional-test-second'
17-
17+
let firstCollectionId: number
18+
let secondCollectionId: number
1819
beforeEach(async () => {
1920
ApiConfig.init(
2021
TestConstants.TEST_API_URL,
@@ -23,34 +24,25 @@ describe('execute', () => {
2324
)
2425
const firstCollection = createCollectionDTO(firstCollectionAlias)
2526
const secondCollection = createCollectionDTO(secondCollectionAlias)
26-
await createCollection.execute(firstCollection)
27-
await createCollection.execute(secondCollection)
27+
firstCollectionId = await createCollection.execute(firstCollection)
28+
secondCollectionId = await createCollection.execute(secondCollection)
2829
})
2930

3031
afterEach(async () => {
3132
await Promise.all([
32-
getCollection
33-
.execute(firstCollectionAlias)
34-
.then((collection) =>
35-
collection && collection.id ? deleteCollection.execute(collection.id) : null
36-
),
37-
getCollection
38-
.execute(secondCollectionAlias)
39-
.then((collection) =>
40-
collection && collection.id ? deleteCollection.execute(collection.id) : null
41-
)
33+
deleteCollection.execute(firstCollectionId),
34+
deleteCollection.execute(secondCollectionId)
4235
])
4336
})
4437

4538
test('should successfully link two collections', async () => {
46-
const firstCollection = await getCollection.execute(firstCollectionAlias)
47-
const secondCollection = await getCollection.execute(secondCollectionAlias)
4839
expect.assertions(1)
4940
try {
50-
await linkCollection.execute(secondCollection.alias, firstCollection.alias)
41+
await linkCollection.execute(secondCollectionAlias, firstCollectionAlias)
5142
} catch (error) {
5243
throw new Error('Collections should be linked successfully')
5344
} finally {
45+
// Wait for the linking to be processed by Solr
5446
await new Promise((resolve) => setTimeout(resolve, 5000))
5547
const collectionItemSubset = await getCollectionItems.execute(firstCollectionAlias)
5648

0 commit comments

Comments
 (0)