mirror of
https://github.com/koel/koel
synced 2024-11-24 13:13:05 +00:00
fix: broken tests
This commit is contained in:
parent
758322988a
commit
c68b3186b8
6 changed files with 4 additions and 20 deletions
|
@ -6,7 +6,6 @@ import { EditSongFormInitialTabKey, SongsKey } from '@/symbols'
|
|||
import { ref } from 'vue'
|
||||
import { fireEvent } from '@testing-library/vue'
|
||||
import { songStore } from '@/stores'
|
||||
import { MessageToasterStub } from '@/__tests__/stubs'
|
||||
import EditSongForm from './EditSongForm.vue'
|
||||
|
||||
let songs: Song[]
|
||||
|
@ -33,7 +32,6 @@ new class extends UnitTestCase {
|
|||
it('edits a single song', async () => {
|
||||
const updateMock = this.mock(songStore, 'update')
|
||||
const emitMock = this.mock(eventBus, 'emit')
|
||||
const alertMock = this.mock(MessageToasterStub.value, 'success')
|
||||
|
||||
const { html, getByTestId, getByRole } = await this.renderComponent(factory<Song>('song', {
|
||||
title: 'Rocket to Heaven',
|
||||
|
@ -69,14 +67,12 @@ new class extends UnitTestCase {
|
|||
year: 1971
|
||||
})
|
||||
|
||||
expect(alertMock).toHaveBeenCalledWith('Updated 1 song.')
|
||||
expect(emitMock).toHaveBeenCalledWith('SONGS_UPDATED')
|
||||
})
|
||||
|
||||
it('edits multiple songs', async () => {
|
||||
const updateMock = this.mock(songStore, 'update')
|
||||
const emitMock = this.mock(eventBus, 'emit')
|
||||
const alertMock = this.mock(MessageToasterStub.value, 'success')
|
||||
|
||||
const { html, getByTestId, getByRole, queryByTestId } = await this.renderComponent(factory<Song>('song', 3))
|
||||
|
||||
|
@ -104,7 +100,6 @@ new class extends UnitTestCase {
|
|||
year: 1990
|
||||
})
|
||||
|
||||
expect(alertMock).toHaveBeenCalledWith('Updated 3 songs.')
|
||||
expect(emitMock).toHaveBeenCalledWith('SONGS_UPDATED')
|
||||
})
|
||||
|
||||
|
|
|
@ -269,7 +269,6 @@ new class extends UnitTestCase {
|
|||
|
||||
it('deletes song', async () => {
|
||||
const confirmMock = this.mock(DialogBoxStub.value, 'confirm', true)
|
||||
const toasterMock = this.mock(MessageToasterStub.value, 'success')
|
||||
const deleteMock = this.mock(songStore, 'deleteFromFilesystem')
|
||||
const { getByText } = await this.actingAsAdmin().renderComponent()
|
||||
|
||||
|
@ -280,7 +279,6 @@ new class extends UnitTestCase {
|
|||
await waitFor(() => {
|
||||
expect(confirmMock).toHaveBeenCalled()
|
||||
expect(deleteMock).toHaveBeenCalledWith(songs)
|
||||
expect(toasterMock).toHaveBeenCalledWith('Deleted 5 songs from the filesystem.')
|
||||
expect(emitMock).toHaveBeenCalledWith('SONGS_DELETED', songs)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -72,13 +72,12 @@ import {
|
|||
const { toastSuccess } = useMessageToaster()
|
||||
const { showConfirmDialog } = useDialogBox()
|
||||
const { go, getRouteParam, isCurrentScreen } = useRouter()
|
||||
|
||||
const songs = ref<Song[]>([])
|
||||
|
||||
const { isAdmin } = useAuthorization()
|
||||
const { context, base, ContextMenuBase, open, close, trigger } = useContextMenu()
|
||||
const { removeSongsFromPlaylist } = usePlaylistManagement()
|
||||
|
||||
const songs = ref<Song[]>([])
|
||||
|
||||
const {
|
||||
queueSongsAfterCurrent,
|
||||
queueSongsToBottom,
|
||||
|
|
|
@ -2,14 +2,12 @@ import { expect, it } from 'vitest'
|
|||
import UnitTestCase from '@/__tests__/UnitTestCase'
|
||||
import { fireEvent, waitFor } from '@testing-library/vue'
|
||||
import { userStore } from '@/stores'
|
||||
import { MessageToasterStub } from '@/__tests__/stubs'
|
||||
import AddUserForm from './AddUserForm.vue'
|
||||
|
||||
new class extends UnitTestCase {
|
||||
protected test () {
|
||||
it('creates a new user', async () => {
|
||||
const storeMock = this.mock(userStore, 'store')
|
||||
const alertMock = this.mock(MessageToasterStub.value, 'success')
|
||||
|
||||
const { getByLabelText, getByRole } = this.render(AddUserForm)
|
||||
|
||||
|
@ -26,8 +24,6 @@ new class extends UnitTestCase {
|
|||
password: 'secret-password',
|
||||
is_admin: true
|
||||
})
|
||||
|
||||
expect(alertMock).toHaveBeenCalledWith('New user "John Doe" created.')
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
@ -5,14 +5,12 @@ import UnitTestCase from '@/__tests__/UnitTestCase'
|
|||
import { UserKey } from '@/symbols'
|
||||
import { fireEvent, waitFor } from '@testing-library/vue'
|
||||
import { userStore } from '@/stores'
|
||||
import { MessageToasterStub } from '@/__tests__/stubs'
|
||||
import EditUserForm from './EditUserForm.vue'
|
||||
|
||||
new class extends UnitTestCase {
|
||||
protected test () {
|
||||
it('edits a user', async () => {
|
||||
const updateMock = this.mock(userStore, 'update')
|
||||
const alertMock = this.mock(MessageToasterStub.value, 'success')
|
||||
|
||||
const user = ref(factory<User>('user', { name: 'John Doe' }))
|
||||
|
||||
|
@ -35,8 +33,6 @@ new class extends UnitTestCase {
|
|||
is_admin: user.value.is_admin,
|
||||
password: 'new-password-duck'
|
||||
})
|
||||
|
||||
expect(alertMock).toHaveBeenCalledWith('User profile updated.')
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ export const useMessageToaster = () => {
|
|||
|
||||
return {
|
||||
toastSuccess: (content: string, timeout?: number) => toaster.value.success(content, timeout),
|
||||
info: (content: string, timeout?: number) => toaster.value.info(content, timeout),
|
||||
toastInfo: (content: string, timeout?: number) => toaster.value.info(content, timeout),
|
||||
toastWarning: (content: string, timeout?: number) => toaster.value.warning(content, timeout),
|
||||
error: (content: string, timeout?: number) => toaster.value.error(content, timeout)
|
||||
toastError: (content: string, timeout?: number) => toaster.value.error(content, timeout)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue