mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-14 13:27:09 +02:00
feat(ui): add remove all missing files functionality (#4108)
* Add remove all missing files feature * test: update mediafile_repository tests for missing files deletion Signed-off-by: Deluan <deluan@navidrome.org> --------- Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
parent
992c78376c
commit
3ccc02f375
8 changed files with 119 additions and 17 deletions
42
ui/src/missing/DeleteMissingFilesButton.test.jsx
Normal file
42
ui/src/missing/DeleteMissingFilesButton.test.jsx
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import React from 'react'
|
||||
import { render } from '@testing-library/react'
|
||||
import { describe, it, expect, beforeEach, vi } from 'vitest'
|
||||
import DeleteMissingFilesButton from './DeleteMissingFilesButton.jsx'
|
||||
import * as RA from 'react-admin'
|
||||
|
||||
vi.mock('react-admin', async () => {
|
||||
const actual = await vi.importActual('react-admin')
|
||||
return {
|
||||
...actual,
|
||||
Button: ({ children, onClick, label }) => (
|
||||
<button onClick={onClick}>{label || children}</button>
|
||||
),
|
||||
Confirm: ({ isOpen }) => (isOpen ? <div data-testid="confirm" /> : null),
|
||||
useNotify: vi.fn(),
|
||||
useDeleteMany: vi.fn(() => [vi.fn(), { loading: false }]),
|
||||
useRefresh: vi.fn(),
|
||||
useUnselectAll: vi.fn(),
|
||||
}
|
||||
})
|
||||
|
||||
describe('DeleteMissingFilesButton', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
it('uses remove_all label when deleteAll is true', () => {
|
||||
const { getByRole } = render(<DeleteMissingFilesButton deleteAll />)
|
||||
expect(getByRole('button').textContent).toBe(
|
||||
'resources.missing.actions.remove_all',
|
||||
)
|
||||
})
|
||||
|
||||
it('calls useDeleteMany with empty ids when deleteAll is true', () => {
|
||||
render(<DeleteMissingFilesButton deleteAll />)
|
||||
expect(RA.useDeleteMany).toHaveBeenCalledWith(
|
||||
'missing',
|
||||
[],
|
||||
expect.any(Object),
|
||||
)
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue