feat(catalog): supplier catalog cleanup, fuzzy matching, and navigation fixes
- Cleaned 137+ fake engine-displacement models from supplier imports (v3/v4 scripts: Chevrolet, Ford, Chrysler, Dodge, Jeep, Nissan, etc.) - Removed 1,251+ corrupted models (INT. prefixes, year-suffix, torque specs, empty names, trailing-year variants) - Migrated supplier tables to master DB (supplier_catalog, supplier_catalog_compat, supplier_catalog_interchange) - Fixed _get_mye_ids_with_parts() to query supplier_catalog_compat from master DB so supplier-only vehicles appear for all tenants - Added fuzzy model matcher with parenthesis stripping, noise suffix removal, compact matching, prefix/substring fallback, model aliases, and ±3 year proximity - Matched compat rows: KEEP GREEN +14,152, KNADIAN +3,021, VAZLO +127,500, LUK +477, RAYBESTOS +1,743 - Added KNADIAN catalog importer with year-range expansion and future-year filtering - Added VAZLO catalog importer with position parsing and SKU-in-model cleanup - Added Keep Green, LUK, Yokomitsu, Raybestos catalog importers - Cache clearing after cleanups (_classify_cache_*, nexus:mye_ids:*, nexus:brand_mye_counts:*) Final match rates: - KEEP GREEN: 90.3% - VAZLO: 93.6% - YOKOMITSU: 100.0% - KNADIAN: 57.4% - LUK: 51.0% - RAYBESTOS: 55.9%
This commit is contained in:
91
test_catalog.js
Normal file
91
test_catalog.js
Normal file
@@ -0,0 +1,91 @@
|
||||
const { chromium } = require('playwright');
|
||||
|
||||
(async () => {
|
||||
const browser = await chromium.launch({ headless: true });
|
||||
const context = await browser.newContext({ viewport: { width: 1280, height: 900 } });
|
||||
const page = await context.newPage();
|
||||
|
||||
// Set token directly via localStorage
|
||||
await page.goto('http://127.0.0.1:5001/pos/catalog', { waitUntil: 'networkidle' });
|
||||
await page.evaluate(() => {
|
||||
localStorage.setItem('pos_token', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoicG9zX2FjY2VzcyIsInRlbmFudF9pZCI6MzEsImVtcGxveWVlX2lkIjoxLCJyb2xlIjoib3duZXIiLCJuYW1lIjoiVGVzdCIsImJyYW5jaF9pZCI6MSwicGVybWlzc2lvbnMiOlsiaW52ZW50b3J5LnZpZXciLCJpbnZlbnRvcnkuZWRpdCIsImludmVudG9yeS5jcmVhdGUiLCJjYXRhbG9nLnZpZXciLCJjb25maWcuZWRpdF9wcmljZXMiXX0.iWLHGSnOeNW-eprH0-U1YkWZksIJqiuBc0ZZ20xdZq0');
|
||||
});
|
||||
await page.reload({ waitUntil: 'networkidle' });
|
||||
|
||||
// Wait for console logs
|
||||
page.on('console', msg => {
|
||||
if (msg.type() === 'error') {
|
||||
console.log('CONSOLE ERROR:', msg.text());
|
||||
}
|
||||
});
|
||||
|
||||
await page.waitForTimeout(2000);
|
||||
await page.screenshot({ path: '/tmp/catalog_initial.png', fullPage: false });
|
||||
|
||||
// Try to select Chevrolet brand
|
||||
const brands = await page.locator('.nav-card').all();
|
||||
console.log('Brands count:', brands.length);
|
||||
|
||||
for (const b of brands.slice(0, 5)) {
|
||||
const text = await b.textContent();
|
||||
console.log('Brand:', text);
|
||||
}
|
||||
|
||||
// Find Chevrolet
|
||||
const chevy = await page.locator('.nav-card').filter({ hasText: /Chevrolet/i }).first();
|
||||
if (await chevy.isVisible().catch(() => false)) {
|
||||
await chevy.click();
|
||||
await page.waitForTimeout(1500);
|
||||
await page.screenshot({ path: '/tmp/catalog_models.png', fullPage: false });
|
||||
|
||||
// Find Aveo
|
||||
const aveo = await page.locator('.nav-card').filter({ hasText: /Aveo/i }).first();
|
||||
if (await aveo.isVisible().catch(() => false)) {
|
||||
await aveo.click();
|
||||
await page.waitForTimeout(1500);
|
||||
await page.screenshot({ path: '/tmp/catalog_years.png', fullPage: false });
|
||||
|
||||
// Find 2018
|
||||
const y2018 = await page.locator('.nav-card').filter({ hasText: /2018/i }).first();
|
||||
if (await y2018.isVisible().catch(() => false)) {
|
||||
await y2018.click();
|
||||
await page.waitForTimeout(1500);
|
||||
await page.screenshot({ path: '/tmp/catalog_engines.png', fullPage: false });
|
||||
|
||||
// Find 1.5L
|
||||
const engine = await page.locator('.nav-card').filter({ hasText: /1\.5/i }).first();
|
||||
if (await engine.isVisible().catch(() => false)) {
|
||||
await engine.click();
|
||||
await page.waitForTimeout(2500);
|
||||
await page.screenshot({ path: '/tmp/catalog_categories.png', fullPage: false });
|
||||
|
||||
// Try to find Supplier Catalog
|
||||
const sc = await page.locator('.nav-card').filter({ hasText: /Proveedores/i }).first();
|
||||
if (await sc.isVisible().catch(() => false)) {
|
||||
console.log('FOUND Supplier Catalog card');
|
||||
await sc.click();
|
||||
await page.waitForTimeout(2000);
|
||||
await page.screenshot({ path: '/tmp/catalog_subgroups.png', fullPage: false });
|
||||
|
||||
// Find SUSPENSION
|
||||
const susp = await page.locator('.nav-card').filter({ hasText: /Suspension/i }).first();
|
||||
if (await susp.isVisible().catch(() => false)) {
|
||||
await susp.click();
|
||||
await page.waitForTimeout(2000);
|
||||
await page.screenshot({ path: '/tmp/catalog_parts.png', fullPage: false });
|
||||
}
|
||||
} else {
|
||||
console.log('Supplier Catalog card NOT found');
|
||||
const allCards = await page.locator('.nav-card').all();
|
||||
for (const c of allCards) {
|
||||
console.log('Card:', await c.textContent());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await browser.close();
|
||||
console.log('Done. Screenshots saved to /tmp/catalog_*.png');
|
||||
})();
|
||||
Reference in New Issue
Block a user