No single-click destructive action belongs in the kebab. Removing the item orphaned its whole path (RemoveTrackPopover was its only caller, and the admin/tracks API client was the popover's only caller), so per the repo's no-dead-code convention the chain is fully removed: the menu item + its admin/isAdmin plumbing in TrackMenu, RemoveTrackPopover(.svelte/.test), src/lib/api/admin/tracks(.ts/.test), and the now-needless transitive mocks in the CompactTrackCard / PlaylistTrackRow / playlist specs. The kebab is now an 8-item, admin-agnostic menu. The DELETE /api/admin/tracks server endpoint is untouched — a future safer admin surface can rebind it. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -25,10 +25,6 @@ vi.mock('$lib/api/likes', () => emptyLikesMock());
|
||||
|
||||
vi.mock('$lib/api/quarantine', () => emptyQuarantineMock());
|
||||
|
||||
vi.mock('$lib/api/admin/tracks', () => ({
|
||||
removeTrack: vi.fn().mockResolvedValue({ deleted_track_id: 't1' })
|
||||
}));
|
||||
|
||||
vi.mock('$lib/api/playlists', () => emptyPlaylistsMock());
|
||||
|
||||
vi.mock('$lib/player/store.svelte', () => ({
|
||||
@@ -56,7 +52,7 @@ describe('TrackMenu', () => {
|
||||
expect(kebab.getAttribute('aria-expanded')).toBe('true');
|
||||
});
|
||||
|
||||
test('opening menu shows all 9 entries for an admin user', async () => {
|
||||
test('opening menu shows all 8 entries', async () => {
|
||||
render(TrackMenu, { props: { track } });
|
||||
await fireEvent.click(screen.getByRole('button', { name: /track actions/i }));
|
||||
|
||||
@@ -68,15 +64,8 @@ describe('TrackMenu', () => {
|
||||
expect(screen.getByRole('menuitem', { name: /go to album/i })).toBeInTheDocument();
|
||||
expect(screen.getByRole('menuitem', { name: /go to artist/i })).toBeInTheDocument();
|
||||
expect(screen.getByRole('menuitem', { name: /^hide$/i })).toBeInTheDocument();
|
||||
expect(screen.getByRole('menuitem', { name: /remove from library/i })).toBeInTheDocument();
|
||||
|
||||
expect(screen.getAllByRole('menuitem')).toHaveLength(9);
|
||||
});
|
||||
|
||||
test('"Remove from library" hidden for non-admin', async () => {
|
||||
userState.current = { id: 'u2', username: 'normal', is_admin: false };
|
||||
render(TrackMenu, { props: { track } });
|
||||
await fireEvent.click(screen.getByRole('button', { name: /track actions/i }));
|
||||
// No "Remove from library" — destructive removal is intentionally absent.
|
||||
expect(screen.queryByRole('menuitem', { name: /remove from library/i })).not.toBeInTheDocument();
|
||||
expect(screen.getAllByRole('menuitem')).toHaveLength(8);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user