fix(ci & formatting): Minor fixes: update CI workflow image and npmci package references, adjust package.json and readme URLs, and apply consistent code formatting.

This commit is contained in:
2025-04-06 18:18:39 +00:00
parent 4fac974fc9
commit 9426a21a2a
19 changed files with 437 additions and 354 deletions

View File

@@ -56,14 +56,14 @@ tap.test('should create test products with searchable fields', async () => {
new Product('Kindle Paperwhite', 'E-reader with built-in light', 'Books', 129),
new Product('Harry Potter', 'Fantasy book series about wizards', 'Books', 49),
new Product('Coffee Maker', 'Automatic drip coffee machine', 'Kitchen', 89),
new Product('Blender', 'High-speed blender for smoothies', 'Kitchen', 129)
new Product('Blender', 'High-speed blender for smoothies', 'Kitchen', 129),
];
// Save all products to the database
for (const product of products) {
await product.save();
}
// Verify that we can get all products
const allProducts = await Product.getInstances({});
expect(allProducts.length).toEqual(products.length);
@@ -74,7 +74,7 @@ tap.test('should retrieve searchable fields for a class', async () => {
// Use the getSearchableFields function to verify our searchable fields
const searchableFields = getSearchableFields('Product');
console.log('Searchable fields:', searchableFields);
expect(searchableFields.length).toEqual(3);
expect(searchableFields).toContain('name');
expect(searchableFields).toContain('description');
@@ -85,7 +85,7 @@ tap.test('should search products by exact field match', async () => {
// Basic field exact match search
const electronicsProducts = await Product.getInstances({ category: 'Electronics' });
console.log(`Found ${electronicsProducts.length} products in Electronics category`);
expect(electronicsProducts.length).toEqual(4);
});
@@ -94,7 +94,7 @@ tap.test('should search products by basic search method', async () => {
try {
const iPhoneResults = await Product.search('iPhone');
console.log(`Found ${iPhoneResults.length} products matching 'iPhone' using basic search`);
expect(iPhoneResults.length).toEqual(1);
expect(iPhoneResults[0].name).toEqual('iPhone 12');
} catch (error) {
@@ -107,8 +107,10 @@ tap.test('should search products by basic search method', async () => {
tap.test('should search products with searchWithLucene method', async () => {
// Using the robust searchWithLucene method
const wirelessResults = await Product.searchWithLucene('wireless');
console.log(`Found ${wirelessResults.length} products matching 'wireless' using searchWithLucene`);
console.log(
`Found ${wirelessResults.length} products matching 'wireless' using searchWithLucene`,
);
expect(wirelessResults.length).toEqual(1);
expect(wirelessResults[0].name).toEqual('AirPods');
});
@@ -117,7 +119,7 @@ tap.test('should search products by category with searchWithLucene', async () =>
// Using field-specific search with searchWithLucene
const kitchenResults = await Product.searchWithLucene('category:Kitchen');
console.log(`Found ${kitchenResults.length} products in Kitchen category using searchWithLucene`);
expect(kitchenResults.length).toEqual(2);
expect(kitchenResults[0].category).toEqual('Kitchen');
expect(kitchenResults[1].category).toEqual('Kitchen');
@@ -127,7 +129,7 @@ tap.test('should search products with partial word matches', async () => {
// Testing partial word matches
const proResults = await Product.searchWithLucene('Pro');
console.log(`Found ${proResults.length} products matching 'Pro'`);
// Should match both "MacBook Pro" and "professionals" in description
expect(proResults.length).toBeGreaterThan(0);
});
@@ -136,7 +138,7 @@ tap.test('should search across multiple searchable fields', async () => {
// Test searching across all searchable fields
const bookResults = await Product.searchWithLucene('book');
console.log(`Found ${bookResults.length} products matching 'book' across all fields`);
// Should match "MacBook" in name and "Books" in category
expect(bookResults.length).toBeGreaterThan(1);
});
@@ -145,10 +147,10 @@ tap.test('should handle case insensitive searches', async () => {
// Test case insensitivity
const electronicsResults = await Product.searchWithLucene('electronics');
const ElectronicsResults = await Product.searchWithLucene('Electronics');
console.log(`Found ${electronicsResults.length} products matching lowercase 'electronics'`);
console.log(`Found ${ElectronicsResults.length} products matching capitalized 'Electronics'`);
// Both searches should return the same results
expect(electronicsResults.length).toEqual(ElectronicsResults.length);
});
@@ -161,19 +163,19 @@ tap.test('should demonstrate search fallback mechanisms', async () => {
console.log('3. As last resort, perform in-memory filtering');
console.log('This ensures robust search even with complex queries');
console.log('==============================================\n');
// Use a simpler term that should be found in descriptions
// Avoid using "OR" operator which requires a text index
const results = await Product.searchWithLucene('high');
console.log(`Found ${results.length} products matching 'high'`);
// "High-speed blender" contains "high"
expect(results.length).toBeGreaterThan(0);
// Try another fallback example that won't need $text
const powerfulResults = await Product.searchWithLucene('powerful');
console.log(`Found ${powerfulResults.length} products matching 'powerful'`);
// "Powerful laptop for professionals" contains "powerful"
expect(powerfulResults.length).toBeGreaterThan(0);
});
@@ -186,7 +188,7 @@ tap.test('should explain the advantages of the integrated approach', async () =>
console.log('4. searchWithLucene provides powerful search capabilities');
console.log('5. Backwards compatible with existing code');
console.log('================================================\n');
expect(true).toEqual(true);
});
@@ -199,4 +201,4 @@ tap.test('close database connection', async () => {
setTimeout(() => process.exit(), 2000);
});
tap.start({ throwOnError: true });
tap.start({ throwOnError: true });