feat(web/m7-352): PlaylistPlaceholderCard with 4 state variants

This commit is contained in:
2026-05-04 18:31:42 -04:00
parent 886903ae27
commit b8bb1c1fa7
2 changed files with 74 additions and 0 deletions
@@ -0,0 +1,34 @@
import { describe, test, expect } from 'vitest';
import { render, screen } from '@testing-library/svelte';
import PlaylistPlaceholderCard from './PlaylistPlaceholderCard.svelte';
describe('PlaylistPlaceholderCard', () => {
test('renders label', () => {
render(PlaylistPlaceholderCard, { props: { label: 'For You', variant: 'pending' } });
expect(screen.getByText('For You')).toBeInTheDocument();
});
test('building variant shows building copy and pulses', () => {
const { container } = render(PlaylistPlaceholderCard, { props: { label: 'For You', variant: 'building' } });
expect(screen.getByText(/Building your daily mix/i)).toBeInTheDocument();
const cover = container.querySelector('[data-variant="building"] .aspect-square');
expect(cover?.className).toMatch(/animate-pulse/);
});
test('failed variant shows failure copy and does NOT pulse', () => {
const { container } = render(PlaylistPlaceholderCard, { props: { label: 'For You', variant: 'failed' } });
expect(screen.getByText(/Couldn't build this mix/i)).toBeInTheDocument();
const cover = container.querySelector('[data-variant="failed"] .aspect-square');
expect(cover?.className).not.toMatch(/animate-pulse/);
});
test('seed-needed variant shows variety copy', () => {
render(PlaylistPlaceholderCard, { props: { label: 'Songs like…', variant: 'seed-needed' } });
expect(screen.getByText(/Listen to more variety/i)).toBeInTheDocument();
});
test('pending variant (default) shows the within-24h copy', () => {
render(PlaylistPlaceholderCard, { props: { label: 'For You' } });
expect(screen.getByText(/within 24h/i)).toBeInTheDocument();
});
});