Benjamin Sutter
7934da7669
feat: design token system — DS_TEXT/DS_SURFACE/DS_BORDER + 237 hex migrations
...
Token infrastructure (src/lib/ds.ts):
- DS_TEXT: 16 semantic text color tokens (primary/secondary/muted/success/
warning/error/info/brand/signal + dark variants successDark/warningDark/
signalDark/infoDark for text on tinted surfaces)
- DS_BG: page/surface/subtle/muted background tokens
- DS_BORDER: default/muted/strong border tokens
- DS_SURFACE: 10 bg+border surface pairs (success/warning/error/info/indigo/
purple/orange/blue/neutral/slate)
- DS_MATCH_TIER: score-tier surface aliases keyed by strong/moderate/weak
- DS_PRE_MARKET / DS_MARKET_SIGNAL: named aliases for futureCard tokens
- DS_SHADOW: card/panel/dialog elevation tokens
- BADGE_COLORS: 14 semantic presets for GenericBadge (confidenceHigh,
riskMedium, preMarket, marketSignal, verified, gold, silver, bronze…)
GenericBadge (src/components/shared/GenericBadge.tsx):
- New semanticVariant prop (keyof BADGE_COLORS) — preferred over raw hex
- color prop becomes optional (fallback), type-documented as escape hatch
Priority file migrations — 237 hex literals replaced across 10 files:
ScoreBreakdownPanel.tsx −22 PipelineDetailPanel.tsx −22
FutureAvailabilityCard.tsx −26 AICompareSummary.tsx −27
LocationIntelligencePanel −39 AssistantPromptSuggestions −18
UnitStructurePanel.tsx −25 BerichtDialog.tsx −24
PreMarketPanel.tsx −24 PropertyActivityLogPanel −10
ESLint (eslint.config.js):
- Updated rule message to reference new tokens (DS_TEXT, DS_SURFACE, etc.)
- Added 'stroke' to monitored property names
- Remains 'warn' for gradual migration; use check:tokens for CI gate
CI script (scripts/check-tokens.js + npm run check:tokens):
- Counts hex patterns in components/ + pages/
- Fails if count > THRESHOLD (ratchet: 1958 baseline, lower per sprint)
- Reports top 15 offenders for prioritizing next migration batch
Results: ESLint targeted sx-prop violations: 1752 → 1030 (−41%)
0 TypeScript errors, 154 tests green
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-05-24 14:05:52 +02:00
Benjamin Sutter
0582031930
test: Vitest test infrastructure + 52 unit tests for matching engine
...
Install vitest, @vitest/coverage-v8, jsdom, @testing-library/react/jest-dom.
Add test / test:watch / test:coverage scripts to package.json.
Three test suites covering the business-critical scoring pipeline:
scoreCalculator.test.ts (28 tests)
- calcDataQualityModifier: all 5 boundary thresholds (+5 / 0 / -5 / -10 / -15)
- calcConfidenceModifier: verified/external/maison-work/future + low-conf stacking
- applyHardFilters: pass, wrong asset type, area tolerance, budget exclusion, OCCUPIED penalty, excluded city
- calculateScore: strong match ≥85, weak match <50, excluded=0, determinism,
formula verification, DQ+confidence direction, occupied 25-point penalty,
positive factors, allHardFactors completeness
rankingEngine.test.ts (10 tests)
- matchStrengthFromScore: STRONG/MODERATE/WEAK boundaries (78/52)
- rankMatches: score sort, type tiebreak (VERIFIED > EXTERNAL), confidence tiebreak
- buildFullMatch: all explainability fields, SHORTLIST+CONTACT for strong match,
SCHEDULE for future signals, uncertainty indicators
matchCardAdapter.test.ts (14 tests)
- VERIFIED_PORTFOLIO: resultType, title, locationLabel, matchScore, scoreBreakdown,
no disclaimer, reasons from positiveFactors, actions passthrough
- FUTURE_AVAILABILITY: resultType, disclaimer always present, signalProbability,
signalQuality HIGH for probability >= 0.70
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
2026-05-24 02:33:12 +02:00