groceries: Hoogvliet importer (sitemap SKUs + storefront GraphQL, EANs, promo labels) + store row; Lidl retries transient CDN 401s
Deploy production / deploy (push) Successful in 1m24s

This commit is contained in:
stan committed 2026-10-25 18:52:01 +00:00
1 parent c897ae3d14
commit 942c436d03
7 files changed
+29796 -3

No files matched your search

+68
View File
@@ -0,0 +1,68 @@
import { describe, expect, it } from 'vitest';
import { dirkItem } from './dirk';
import { hoogvlietCategory, hoogvlietItem } from './hoogvliet';
describe('dirk', () => {
it('maps a product with an offer', () => {
const it = dirkItem(
{
productId: 1,
normalPrice: 2.85,
offerPrice: 1.39,
endDate: '2026-10-27T00:00:00',
productInformation: {
headerText: 'Alpro Vanille',
packaging: '1 l',
brand: 'Alpro',
department: 'Zuivel & kaas',
webgroup: 'Melk'
}
},
4,
60
);
expect(it).toMatchObject({
priceCents: 285,
promoPriceCents: 139,
category: 'Zuivel & eieren',
promoLabel: 'Actie · t/m 27-10'
});
});
it('flags drugstore as non-food but baby food as food', () => {
const base = { productId: 2, normalPrice: 1, productInformation: { headerText: 'x' } };
expect(dirkItem(base, 10, 120)?.isFood).toBe(false);
expect(dirkItem(base, 10, 100)?.isFood).toBe(true);
});
});
describe('hoogvliet', () => {
it('prefers a real tree over theme trees and keeps the deepest path', () => {
expect(
hoogvlietCategory(['aanbiedingen', 'huishouden-non-food', 'huishouden-non-food/schoonmaken'])
).toEqual({
category: 'Huishouden & dieren',
isFood: false,
path: 'huishouden-non-food/schoonmaken'
});
});
it('drops in-store EANs and skips promotion groups', () => {
const p = {
sku: '980498000',
name: 'Casino wit',
url_key: 'hoogvliet-casino-wit-980498000',
metadata: JSON.stringify({ ean: '2140040000000', merk: 'Hoogvliet' }),
price_range: {
minimum_price: { regular_price: { value: 1.48 }, final_price: { value: 1.48 } }
},
categories: [{ level: 2, url_path: 'bakkerij' }]
};
expect(hoogvlietItem(p, new Map())).toMatchObject({
gtin: null,
name: 'Hoogvliet Casino wit',
url: 'https://hoogvliet.nl/product/hoogvliet-casino-wit-980498000'
});
expect(
hoogvlietItem({ ...p, metadata: JSON.stringify({ promo_products: '["1"]' }) }, new Map())
).toBeNull();
});
});