- Add /planner/variety route with mobile stacked + desktop 2-column layout - Implement VarietyScoreHero: Fraunces score display + progress bar + color-coded description - Implement ScoreBreakdownList: 3 sub-score rows (protein diversity, ingredient overlap, effort balance) - Implement VarietyWarningCards: yellow-tint warning cards derived from API tagRepeats/ingredientOverlaps - Implement EffortBar: proportional colored segments (Easy/Medium/Hard) with ×N labels - Desktop: protein grid (7 columns, repeat highlight with yellow ring) + effort bar in right panel - Client-side sub-score derivation from VarietyScoreResponse (tagged for TODO to move to API) - 26 new tests across 5 components + server load function; 455 tests total, 0 type errors Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { render, screen } from '@testing-library/svelte';
|
|
import VarietyWarningCards from './VarietyWarningCards.svelte';
|
|
|
|
const warnings = [
|
|
{ title: 'Chicken zweimal diese Woche', explanation: 'Mo, Mi — erwäge einen Tausch.' },
|
|
{ title: 'Tomaten in 3 Gerichten', explanation: 'Mo, Di, Mi — sorge für Abwechslung.' }
|
|
];
|
|
|
|
describe('VarietyWarningCards', () => {
|
|
it('renders one card per warning', () => {
|
|
render(VarietyWarningCards, { props: { warnings } });
|
|
const cards = screen.getAllByTestId('warning-card');
|
|
expect(cards.length).toBe(2);
|
|
});
|
|
|
|
it('renders warning titles', () => {
|
|
render(VarietyWarningCards, { props: { warnings } });
|
|
expect(screen.getByText(/Chicken zweimal/)).toBeTruthy();
|
|
expect(screen.getByText(/Tomaten in 3/)).toBeTruthy();
|
|
});
|
|
|
|
it('renders warning explanations', () => {
|
|
render(VarietyWarningCards, { props: { warnings } });
|
|
expect(screen.getByText(/erwäge einen Tausch/)).toBeTruthy();
|
|
});
|
|
|
|
it('renders nothing when warnings is empty', () => {
|
|
render(VarietyWarningCards, { props: { warnings: [] } });
|
|
expect(screen.queryAllByTestId('warning-card').length).toBe(0);
|
|
});
|
|
});
|