fix(lucene adapter and search tests): Improve range query parsing in Lucene adapter and expand search test coverage

This commit is contained in:
2025-04-22 18:24:26 +00:00
parent c5a44da975
commit 75aeb12e81
6 changed files with 47 additions and 3 deletions

View File

@@ -257,6 +257,26 @@ tap.test('should search hyphenated terms "E-reader"', async () => {
expect(ereaderResults[0].name).toEqual('Kindle Paperwhite');
});
// Additional robustness tests
tap.test('should return all products for empty search', async () => {
const searchResults = await Product.search('');
const allProducts = await Product.getInstances({});
expect(searchResults.length).toEqual(allProducts.length);
});
tap.test('should support wildcard plain term across all fields', async () => {
const results = await Product.search('*book*');
const names = results.map((r) => r.name).sort();
expect(names).toEqual(['Harry Potter', 'Kindle Paperwhite', 'MacBook Pro']);
});
tap.test('should support wildcard plain term with question mark pattern', async () => {
const results = await Product.search('?one?');
const names = results.map((r) => r.name).sort();
expect(names).toEqual(['Galaxy S21', 'iPhone 12']);
});
// Close database connection
tap.test('close database connection', async () => {
await testDb.mongoDb.dropDatabase();
await testDb.close();