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 { goauctionPageUrl, parseGoauctionCalendar, parseGoauctionLots } from '../_g8-auctions-eu-apac-lib/goauction-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.dominicwinter.co.uk', currency: 'GBP' as const, listStyle: 'search' as const }; const CAL = `
Printed Books, Maps & Documents, Ornithology, Music Manuscripts, British & European Bookplates

Printed Books, Maps & Documents

Wednesday 28 January 2026
Results: Download PDF results
`; const GRID = `
`; describe('dominic-winter', () => { runFixtureSuite(connector, it, expect); it('fixtures: GBP book results', async () => { let sales = 0; for (const name of listFixtures('dominic-winter')) { for (const r of await connector.normalize(loadFixture('dominic-winter', name).raw)) { if (!('attributes' in r)) continue; expect(r.attributes.identifiers.dominic_winter_lot).toMatch(/^\d+\/\S+$/); if (r.kind === 'sale') { sales++; expect(r.currency).toBe('GBP'); expect(r.auctionHouse).toBe('Dominic Winter Auctioneers'); } } } expect(sales).toBeGreaterThan(10); }); it('parses the /Auction/Search style calendar + grid ("Lot 1 - title")', async () => { const sales = parseGoauctionCalendar(CAL, HOUSE); expect(sales).toHaveLength(1); expect(sales[0]).toMatchObject({ id: '885', title: 'Printed Books, Maps & Documents', date: '2026-01-28T00:00:00.000Z', url: 'https://www.dominicwinter.co.uk/Auction/Search?au=885&sd=2' }); expect(goauctionPageUrl(sales[0]!, 3, HOUSE)).toBe('https://www.dominicwinter.co.uk/Auction/Search?au=885&sd=2&pn=3&g=1'); const p = parseGoauctionLots(GRID, sales[0]!, HOUSE)!; expect(p.hasMore).toBe(true); expect(p.lots[0]).toMatchObject({ lotNo: '1', title: 'Amedeo (Luigi). On the "Polar Star", 2 volumes, 1903', price: 480, currency: 'GBP', sold: true }); const out = await connector.normalize({ url: sales[0]!.url, kind: 'sale', engine: 'api', fetchedAt: new Date(), payload: { kind: 'sale_results', url: sales[0]!.url, sale: sales[0]!, page: 1, totalLots: null, lots: p.lots } }); expect(attrsOf(out[0]!).categorySlug).toBe('books'); expect(attrsOf(out[0]!).year).toBe(1903); }); });