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