|
15 | 15 | */ |
16 | 16 | import { describe } from 'vitest'; |
17 | 17 |
|
| 18 | +import { ServerFeatures } from '@cbjsdev/http-client'; |
18 | 19 | import { waitForDocumentsInSearchIndex } from '@cbjsdev/http-client/dist/src/waitFor/waitForDocumentsInSearchIndex.js'; |
19 | 20 | import { getRandomId } from '@cbjsdev/shared'; |
20 | 21 | import { createCouchbaseTest } from '@cbjsdev/vitest'; |
21 | 22 |
|
| 23 | +import { serverSupportsFeatures } from '../../utils/serverFeature.js'; |
22 | 24 | import getIndexDefinition from './getIndexDefinition.js'; |
23 | 25 |
|
24 | | -describe('waitForDocumentsInSearchIndex', { timeout: 100_000 }, async () => { |
25 | | - const test = await createCouchbaseTest(); |
| 26 | +describe.runIf(serverSupportsFeatures(ServerFeatures.ScopeSearchIndexManagement))( |
| 27 | + 'waitForDocumentsInSearchIndex', |
| 28 | + { timeout: 100_000 }, |
| 29 | + async () => { |
| 30 | + const test = await createCouchbaseTest(); |
26 | 31 |
|
27 | | - test( |
28 | | - 'should return once the document are found', |
29 | | - async ({ |
30 | | - expect, |
31 | | - useScopedSearchIndex, |
32 | | - useDocumentKey, |
33 | | - useScope, |
34 | | - useCollection, |
35 | | - serverTestContext, |
36 | | - apiConfig, |
37 | | - }) => { |
38 | | - const scopeName = await useScope(); |
39 | | - const collectionName = await useCollection({ scopeName }); |
| 32 | + test( |
| 33 | + 'should return once the document are found', |
| 34 | + async ({ |
| 35 | + expect, |
| 36 | + useScopedSearchIndex, |
| 37 | + useDocumentKey, |
| 38 | + useScope, |
| 39 | + useCollection, |
| 40 | + serverTestContext, |
| 41 | + apiConfig, |
| 42 | + }) => { |
| 43 | + const scopeName = await useScope(); |
| 44 | + const collectionName = await useCollection({ scopeName }); |
40 | 45 |
|
41 | | - const searchIndexName = `searchIndex` + getRandomId(); |
42 | | - const def = getIndexDefinition(searchIndexName, { |
43 | | - bucket: serverTestContext.bucket.name, |
44 | | - scope: scopeName, |
45 | | - collection: collectionName, |
46 | | - }); |
| 46 | + const searchIndexName = `searchIndex` + getRandomId(); |
| 47 | + const def = getIndexDefinition(searchIndexName, { |
| 48 | + bucket: serverTestContext.bucket.name, |
| 49 | + scope: scopeName, |
| 50 | + collection: collectionName, |
| 51 | + }); |
47 | 52 |
|
48 | | - const indexName = await useScopedSearchIndex( |
49 | | - { |
50 | | - bucketName: serverTestContext.bucket.name, |
51 | | - scopeName, |
52 | | - collectionName, |
53 | | - ...def, |
54 | | - }, |
55 | | - { waitSearchIndexTimeout: 100_000, awaitMutations: true } |
56 | | - ); |
| 53 | + const indexName = await useScopedSearchIndex( |
| 54 | + { |
| 55 | + bucketName: serverTestContext.bucket.name, |
| 56 | + scopeName, |
| 57 | + collectionName, |
| 58 | + ...def, |
| 59 | + }, |
| 60 | + { waitSearchIndexTimeout: 100_000, awaitMutations: true } |
| 61 | + ); |
57 | 62 |
|
58 | | - const testDocKey = useDocumentKey(); |
59 | | - const testDocBody = { |
60 | | - title: 'Couchbase', |
61 | | - tagline: 'No Equal - The Cloud database for modern applications', |
62 | | - description: |
63 | | - 'Couchbase is a NoSQL, distributed database focused on performances at scale.', |
64 | | - }; |
| 63 | + const testDocKey = useDocumentKey(); |
| 64 | + const testDocBody = { |
| 65 | + title: 'Couchbase', |
| 66 | + tagline: 'No Equal - The Cloud database for modern applications', |
| 67 | + description: |
| 68 | + 'Couchbase is a NoSQL, distributed database focused on performances at scale.', |
| 69 | + }; |
65 | 70 |
|
66 | | - const testDocKey2 = useDocumentKey(); |
67 | | - const testDocBody2 = { |
68 | | - title: 'Magma', |
69 | | - description: 'The latest storage engine from Couchbase.', |
70 | | - }; |
| 71 | + const testDocKey2 = useDocumentKey(); |
| 72 | + const testDocBody2 = { |
| 73 | + title: 'Magma', |
| 74 | + description: 'The latest storage engine from Couchbase.', |
| 75 | + }; |
71 | 76 |
|
72 | | - const collection = serverTestContext.bucket |
73 | | - .scope(scopeName) |
74 | | - .collection(collectionName); |
75 | | - await collection.insert(testDocKey, testDocBody); |
76 | | - await collection.insert(testDocKey2, testDocBody2); |
| 77 | + const collection = serverTestContext.bucket |
| 78 | + .scope(scopeName) |
| 79 | + .collection(collectionName); |
| 80 | + await collection.insert(testDocKey, testDocBody); |
| 81 | + await collection.insert(testDocKey2, testDocBody2); |
77 | 82 |
|
78 | | - await waitForDocumentsInSearchIndex( |
79 | | - apiConfig, |
80 | | - { |
81 | | - bucket: serverTestContext.bucket.name, |
82 | | - scope: scopeName, |
83 | | - index: indexName, |
84 | | - }, |
85 | | - [testDocKey, testDocKey2], |
86 | | - { timeout: 60_000 } |
87 | | - ); |
88 | | - }, |
89 | | - { timeout: 100_000 } |
90 | | - ); |
91 | | -}); |
| 83 | + await waitForDocumentsInSearchIndex( |
| 84 | + apiConfig, |
| 85 | + { |
| 86 | + bucket: serverTestContext.bucket.name, |
| 87 | + scope: scopeName, |
| 88 | + index: indexName, |
| 89 | + }, |
| 90 | + [testDocKey, testDocKey2], |
| 91 | + { timeout: 60_000 } |
| 92 | + ); |
| 93 | + }, |
| 94 | + { timeout: 100_000 } |
| 95 | + ); |
| 96 | + } |
| 97 | +); |
0 commit comments