deckhearth/test/lib/card-import-lorcana-bulk.test.js
Randall Stillwell ec9bb2b93e feat(catalog): unified multi-game bulk sync + schema map update
Ship Pokemon and Lorcana bulk import libs/scripts, unified weekly cron
sync across MTG/Pokemon/Lorcana with per-game error isolation and
catalog_sync_log telemetry. Admin UI adds Unified/Incremental/Bulk MTG modes.

- Rename reconcile migrations to 1781442330* timestamps so they apply
  after bulk-data migrations without node-pg-migrate ordering conflicts
- Add Lorcana set-code normalization + orphan cleanup migrations
- Drop stricter user_cards_user_card_unique (keep 3-column foil unique)
- Update docs/SCHEMA_MAP.md for tags, card_tags, catalog_sync_log, bulk columns

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-14 08:22:19 -05:00

66 lines
2.1 KiB
JavaScript

import { describe, expect, it } from 'vitest';
import { mapLorcanaCard } from '../../lib/card-import/lorcana-bulk.js';
describe('mapLorcanaCard', () => {
it('maps Lorcana bulk API fields to cards table shape', () => {
const mapped = mapLorcanaCard({
Unique_ID: 'TFC-001',
Name: 'Ariel - On Human Legs',
Set_Name: 'The First Chapter',
Set_ID: 'TFC',
Card_Num: 1,
Rarity: 'Uncommon',
Cost: 4,
Type: 'Character',
Color: 'Amber, Sapphire',
Classifications: 'Storyborn, Hero',
Body_Text: 'Voiceless: This character cannot {e} to sing songs.',
Strength: 3,
Willpower: 4,
Image: 'https://lorcana-api.com/images/ariel/on_human_legs/ariel-on_human_legs-large.png',
Artist: 'Koni',
Flavor_Text: '...',
Lore: 2,
Inkable: true,
Abilities: 'Shift 3',
});
expect(mapped).toEqual({
scryfallId: 'TFC-001',
name: 'Ariel - On Human Legs',
setName: 'The First Chapter',
setCode: 'TFC',
cardNumber: '1',
rarity: 'Uncommon',
manaCost: '4',
cmc: 4,
cardType: 'Character',
colors: JSON.stringify(['Amber', 'Sapphire']),
colorIdentity: JSON.stringify(['Amber', 'Sapphire']),
oracleText: 'Voiceless: This character cannot {e} to sing songs.',
power: '3',
toughness: '4',
imageUrl: 'https://lorcana-api.com/images/ariel/on_human_legs/ariel-on_human_legs-large.png',
stockImageUrl: 'https://lorcana-api.com/images/ariel/on_human_legs/ariel-on_human_legs-large.png',
flavorText: '...',
artist: 'Koni',
edhrecRank: 2,
keywords: JSON.stringify(['Storyborn', 'Hero', 'Shift 3', 'Inkable']),
});
});
it('omits Inkable keyword when card is not inkable', () => {
const mapped = mapLorcanaCard({
Unique_ID: 'ARI-001',
Name: 'Rhino - Motivational Speaker',
Set_Name: 'Archazia\'s Island',
Set_ID: 'ARI',
Card_Num: 1,
Inkable: false,
Classifications: 'Storyborn, Ally',
});
expect(JSON.parse(mapped.keywords)).toEqual(['Storyborn', 'Ally']);
});
});