release / govulncheck (push) Successful in 23s
release / web (push) Successful in 1m22s
release / go (push) Successful in 1m41s
release / integration (push) Successful in 4m49s
release / android (push) Successful in 5m32s
release / Build signed APK (releases and dev) (push) Successful in 5m39s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 28s
release / Verify release artifacts (tag releases only) (push) Skipped
CI run 8789 warned on both: - kit 3 deprecates `config.alias`. The $test-utils alias becomes a `#test-utils/*` subpath import, matching #lib, and its 43 import sites move with it. - Vite's coming native config loader needs the extension on vitest.config.ts's import of vite.config. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
63 lines
2.2 KiB
TypeScript
63 lines
2.2 KiB
TypeScript
import { afterEach, describe, expect, test, vi } from 'vitest';
|
|
import { render, screen, fireEvent } from '@testing-library/svelte';
|
|
import type { TrackRef } from '#lib/api/types.js';
|
|
import { emptyLikesMock } from '../../test-utils/mocks/likes';
|
|
import { emptyPlaylistsMock } from '../../test-utils/mocks/playlists';
|
|
import { emptyQuarantineMock } from '../../test-utils/mocks/quarantine';
|
|
import { makeTracks } from '#test-utils/fixtures/track.js';
|
|
|
|
vi.mock('#lib/api/likes.js', () => emptyLikesMock());
|
|
|
|
vi.mock('#lib/api/quarantine.js', () => emptyQuarantineMock());
|
|
|
|
vi.mock('#lib/api/playlists.js', () => emptyPlaylistsMock());
|
|
|
|
vi.mock('#lib/auth/store.svelte.js', () => ({
|
|
user: { get value() { return { id: 'u1', username: 'u', is_admin: false }; } }
|
|
}));
|
|
|
|
vi.mock('$app/navigation', () => ({ goto: vi.fn() }));
|
|
|
|
vi.mock('#lib/player/store.svelte.js', () => ({
|
|
playQueue: vi.fn(),
|
|
enqueueTrack: vi.fn(),
|
|
playNext: vi.fn()
|
|
}));
|
|
|
|
import CompactTrackCard from './CompactTrackCard.svelte';
|
|
import { playQueue, enqueueTrack } from '#lib/player/store.svelte.js';
|
|
|
|
const titles = ['First', 'Second', 'Third'];
|
|
const tracks: TrackRef[] = makeTracks(3, { artist_name: 'Artist' }).map((t, i) => ({
|
|
...t,
|
|
title: titles[i]
|
|
}));
|
|
|
|
afterEach(() => vi.clearAllMocks());
|
|
|
|
describe('CompactTrackCard', () => {
|
|
test('clicking the card calls playQueue with sectionTracks at the right index', async () => {
|
|
render(CompactTrackCard, {
|
|
props: { track: tracks[1], sectionTracks: tracks, index: 1 }
|
|
});
|
|
await fireEvent.click(screen.getByRole('button', { name: /play second/i }));
|
|
expect(playQueue).toHaveBeenCalledWith(tracks, 1);
|
|
});
|
|
|
|
test('renders title and artist name', () => {
|
|
render(CompactTrackCard, {
|
|
props: { track: tracks[0], sectionTracks: tracks, index: 0 }
|
|
});
|
|
expect(screen.getByText('First')).toBeInTheDocument();
|
|
expect(screen.getByText('Artist')).toBeInTheDocument();
|
|
});
|
|
|
|
test('+ queue button calls enqueueTrack', async () => {
|
|
render(CompactTrackCard, {
|
|
props: { track: tracks[0], sectionTracks: tracks, index: 0 }
|
|
});
|
|
await fireEvent.click(screen.getByRole('button', { name: /add first to queue/i }));
|
|
expect(enqueueTrack).toHaveBeenCalledWith(tracks[0]);
|
|
});
|
|
});
|