Files
minstrel/web/src/lib/api/home.test.ts
T
bvandeusenandClaude Opus 4.8 3f240bc777
test-web / test (push) Successful in 32s
feat(web): "You might like" Home row (#790 web client slice)
The web UI rendered a fixed set of Home sections and had no code for the
server's you_might_like_albums / you_might_like_artists (shipped in
v2026.06.11), so the row was absent in the web client. Adds it, mirroring
the Rediscover block, positioned directly under the system-playlists row.

- types.ts HomePayload: two new slices (server always emits them; web ships
  in lockstep with the server).
- +page.svelte: a "You might like" section (albums + artists scrollers) as the
  first section under the playlists row, with a "still learning your taste"
  empty state for the cold-start/gated case. Reuses existing AlbumCard /
  ArtistCard / HorizontalScrollRow.
- home.test.ts / page.test.ts: mock payloads gain the two fields.

Completes the You-might-like row across all three clients (server already
emits it; Android in v2026.06.11; web here).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-11 22:59:58 -04:00

35 lines
942 B
TypeScript

import { afterEach, describe, expect, test, vi } from 'vitest';
vi.mock('./client', () => ({
api: { get: vi.fn() }
}));
import { listHome } from './home';
import { qk } from './queries';
import { api } from './client';
import type { HomePayload } from './types';
afterEach(() => vi.clearAllMocks());
describe('home client', () => {
test('listHome hits /api/home', async () => {
const fixture: HomePayload = {
recently_added_albums: [],
rediscover_albums: [],
rediscover_artists: [],
most_played_tracks: [],
last_played_artists: [],
you_might_like_albums: [],
you_might_like_artists: []
};
(api.get as ReturnType<typeof vi.fn>).mockResolvedValueOnce(fixture);
const got = await listHome();
expect(api.get).toHaveBeenCalledWith('/api/home');
expect(got).toEqual(fixture);
});
test('qk.home key is stable', () => {
expect(qk.home()).toEqual(['home']);
});
});