Files
product-import-ai/test/scrape-image-schema.test.ts
T

56 lines
2.9 KiB
TypeScript

// @ts-nocheck
import test from "node:test";
import assert from "node:assert/strict";
import fs from "node:fs";
const schema = fs.readFileSync("sql/local-scrape-db.sql", "utf8");
test("local scrape schema stores image binaries with exact and visual hashes", () => {
assert.match(schema, /CREATE TABLE IF NOT EXISTS `scrape_image_blobs`/);
assert.match(schema, /`sha256` CHAR\(64\) NOT NULL/);
assert.match(schema, /`perceptual_hash` CHAR\(16\) NULL/);
assert.match(schema, /`image_data` LONGBLOB NOT NULL/);
assert.match(schema, /UNIQUE KEY `uq_scrape_image_blobs_sha256` \(`sha256`\)/);
});
test("local scrape schema tracks picture candidates and their target combination logic", () => {
assert.match(schema, /CREATE TABLE IF NOT EXISTS `scrape_picture_candidates`/);
assert.match(schema, /`target_strategy` ENUM\('unknown', 'color', 'size', 'combination', 'manual'\)/);
assert.match(schema, /`target_color` VARCHAR\(255\) NULL/);
assert.match(schema, /`target_size` VARCHAR\(128\) NULL/);
assert.match(schema, /`target_combi` VARCHAR\(255\) NULL/);
assert.match(schema, /`duplicate_status` ENUM\('unique', 'exact_duplicate', 'visual_duplicate', 'review'\)/);
});
test("local scrape schema can learn picture target rules from manual corrections", () => {
assert.match(schema, /CREATE TABLE IF NOT EXISTS `scrape_picture_target_rules`/);
assert.match(schema, /`product_name_pattern` VARCHAR\(255\) NULL/);
assert.match(schema, /`target_strategy` ENUM\('color', 'size', 'combination', 'manual'\) NOT NULL/);
assert.match(schema, /`examples_count` INT UNSIGNED NOT NULL DEFAULT 0/);
});
test("local scrape schema stores reusable source capabilities for pictures texts and features", () => {
assert.match(schema, /CREATE TABLE IF NOT EXISTS `scrape_source_capabilities`/);
assert.match(schema, /`capability` ENUM\('search', 'pictures', 'texts', 'features'\) NOT NULL/);
assert.match(schema, /`parser_key` VARCHAR\(128\) NOT NULL/);
assert.match(schema, /`selector_config` JSON NULL/);
assert.match(schema, /`extraction_config` JSON NULL/);
assert.match(schema, /`quality_config` JSON NULL/);
assert.match(schema, /UNIQUE KEY `uq_scrape_source_capability_parser`/);
});
test("local scrape schema links manufacturer mappings to selected source capabilities", () => {
assert.match(schema, /CREATE TABLE IF NOT EXISTS `scrape_manufacturer_source_capabilities`/);
assert.match(schema, /`target_strategy_override` ENUM\('unknown', 'color', 'size', 'combination', 'manual'\) NULL/);
assert.match(schema, /`config_override` JSON NULL/);
assert.match(schema, /UNIQUE KEY `uq_scrape_manufacturer_source_capability`/);
});
test("local scrape schema seeds Hudy and Idealo extraction capabilities", () => {
assert.match(schema, /'hudy-gallery'/);
assert.match(schema, /'hudy-product-texts'/);
assert.match(schema, /'hudy-product-params'/);
assert.match(schema, /'idealo-splide-gallery'/);
assert.match(schema, /'productGalleryOnly'/);
});