Some checks failed
CI / Lint (pull_request) Has been cancelled
CI / Schema map up to date (pull_request) Has been cancelled
CI / Forbidden patterns (9 checks) (pull_request) Has been cancelled
CI / Migrations apply (node-pg-migrate) (pull_request) Has been cancelled
Visual diff / Should run? (pull_request) Has been cancelled
CI / Unit tests (vitest) (pull_request) Has been cancelled
Convoy metrics gate / Require role-event telemetry on convoy PRs (pull_request) Has been cancelled
PR Health rollup / Aggregate gate status (pull_request) Has been cancelled
Preview smoke / Should run? (pull_request) Has been cancelled
Preview smoke / Playwright smoke (pull_request) Has been cancelled
Visual diff / Screenshot diff (pull_request) Has been cancelled
Add pricing schema, free API integrations (MTG bulk, TCGdex, Foolio), valuation and sort-by-price, card detail pricing UI, and nearby store discovery via home zip and OSM geo clients. Co-authored-by: Cursor <cursoragent@cursor.com>
47 lines
1.7 KiB
JavaScript
47 lines
1.7 KiB
JavaScript
// @vitest-environment jsdom
|
|
import { afterEach, describe, expect, test } from 'vitest';
|
|
import { cleanup, render, screen } from '@testing-library/react';
|
|
import CardDetailPurchaseTab, { stalenessBadgeText } from '../../components/card-detail/CardDetailPurchaseTab';
|
|
|
|
afterEach(() => cleanup());
|
|
|
|
const formatCurrency = (amount) => `$${Number(amount).toFixed(2)}`;
|
|
|
|
describe('stalenessBadgeText', () => {
|
|
test('shows outdated copy when stale', () => {
|
|
expect(stalenessBadgeText({ stale: true, pricesUpdatedAt: '2026-01-01T00:00:00.000Z' }))
|
|
.toBe('Prices may be outdated');
|
|
});
|
|
|
|
test('shows updated date when fresh', () => {
|
|
const text = stalenessBadgeText({ stale: false, pricesUpdatedAt: '2026-01-15T00:00:00.000Z' });
|
|
expect(text).toContain('Updated');
|
|
expect(text).toContain('2026');
|
|
});
|
|
});
|
|
|
|
describe('<CardDetailPurchaseTab>', () => {
|
|
test('renders staleness badge text from pricing payload', () => {
|
|
render(
|
|
<CardDetailPurchaseTab
|
|
card={{ name: 'Lightning Bolt', current_price: 1, market_price: 2, game: 'MTG' }}
|
|
pricing={{
|
|
prices: { current: 1.25, market: 2.5, currency: 'USD' },
|
|
pricesUpdatedAt: '2026-01-01T00:00:00.000Z',
|
|
stale: true,
|
|
outbound: {
|
|
tcgplayer: 'https://www.tcgplayer.com/search',
|
|
ebay: 'https://www.ebay.com/sch',
|
|
},
|
|
}}
|
|
pricingLoading={false}
|
|
formatCurrency={formatCurrency}
|
|
/>
|
|
);
|
|
|
|
expect(screen.getByTestId('pricing-staleness-badge').textContent)
|
|
.toBe('Prices may be outdated');
|
|
expect(screen.getByText('View on TCGPlayer')).toBeDefined();
|
|
expect(screen.getByTestId('card-detail-local-stores-slot')).toBeDefined();
|
|
});
|
|
});
|