import { describe, expect, it } from 'vitest'; import type { NormalizedRecord } from '@rareindex/shared'; import { ConnectorMetaSchema } from '@rareindex/connectors'; import { listFixtures, loadFixture, runFixtureSuite } from '@rareindex/connectors/testing'; import metaJson from './meta.json' with { type: 'json' }; import createConnector from './index.js'; import { parseDrouotCatalogue } from '../_g8-auctions-eu-apac-lib/drouot-platform.js'; const meta = ConnectorMetaSchema.parse(metaJson); const connector = createConnector(meta); const attrsOf = (r: NormalizedRecord) => { if (!('attributes' in r)) throw new Error(`record kind ${r.kind} has no attributes`); return r.attributes; }; const HOUSE = { base: 'https://www.osenat.com', currency: 'EUR' as const }; const CATALOGUE = `

Montres de poche

mercredi 15 juillet 2026 14:00
Paris
Lots 1 à 50 sur 50
x
Résultat : 2 245 EUR
1
1500 - 2500 EUR
Résultat 2 245 EUR
Résultats sans frais
`; describe('osenat', () => { runFixtureSuite(connector, it, expect); it('fixtures: EUR hammer results (Osenat = sans frais)', async () => { let sales = 0; for (const name of listFixtures('osenat')) { for (const r of await connector.normalize(loadFixture('osenat', name).raw)) { if (!('attributes' in r)) continue; expect(r.attributes.identifiers.osenat_lot).toMatch(/^\d+\/\S+$/); expect(r.sourceUrl).toMatch(/^https:\/\/www\.osenat\.com\//); if (r.kind === 'sale') { sales++; expect(r.currency).toBe('EUR'); expect(r.buyerPremiumIncluded).toBe(false); expect(r.auctionHouse).toBe('Osenat'); } } } expect(sales).toBeGreaterThan(10); }); it('reads "Résultats sans frais" as hammer and French dates/prices', async () => { const sale = { id: '174356', title: 'Montres de poche', url: 'https://www.osenat.com/catalogue/174356-montres-de-poche', date: null, location: null, extra: {} }; const p = parseDrouotCatalogue(CATALOGUE, sale, HOUSE)!; expect(p.hasMore).toBe(false); expect(p.totalLots).toBe(50); expect(p.lots[0]).toMatchObject({ lotNo: '1', price: 2245, currency: 'EUR', premiumIncluded: false, estimateLow: 1500, estimateHigh: 2500, sold: true }); expect(p.sale).toMatchObject({ date: '2026-07-15T00:00:00.000Z', location: 'Paris', title: 'Montres de poche' }); Object.assign(sale, p.sale, { extra: p.sale!.extra }); const out = await connector.normalize({ url: sale.url, kind: 'sale', engine: 'api', fetchedAt: new Date(), payload: { kind: 'sale_results', url: sale.url, sale, page: 1, totalLots: 50, lots: p.lots } }); expect(out).toHaveLength(1); expect(out[0]!.kind).toBe('sale'); expect(attrsOf(out[0]!).categorySlug).toBe('other_watches'); expect(attrsOf(out[0]!).year).toBe(1780); if (out[0]!.kind === 'sale') expect(out[0]!.location).toBe('Paris'); expect(connector.salePageUrl(sale, 3)).toBe('https://www.osenat.com/catalogue/174356?lang=fr&search=&offset=100&max=50'); }); });