fixed frontent test errors
Some checks failed
Chore App Build and Push Docker Images / build-and-push (push) Failing after 1m47s
Some checks failed
Chore App Build and Push Docker Images / build-and-push (push) Failing after 1m47s
This commit is contained in:
@@ -10,14 +10,12 @@ describe('ItemList.vue', () => {
|
||||
it('does not show delete button for system items', async () => {
|
||||
const wrapper = mount(ItemList, {
|
||||
props: {
|
||||
fetchUrl: '',
|
||||
itemKey: 'items',
|
||||
itemFields: ['name'],
|
||||
deletable: true,
|
||||
testItems: [systemItem],
|
||||
},
|
||||
global: {
|
||||
stubs: ['svg'],
|
||||
},
|
||||
})
|
||||
await flushPromises()
|
||||
expect(wrapper.find('.delete-btn').exists()).toBe(false)
|
||||
@@ -26,14 +24,12 @@ describe('ItemList.vue', () => {
|
||||
it('shows delete button for user items', async () => {
|
||||
const wrapper = mount(ItemList, {
|
||||
props: {
|
||||
fetchUrl: '',
|
||||
itemKey: 'items',
|
||||
itemFields: ['name'],
|
||||
deletable: true,
|
||||
testItems: [userItem],
|
||||
},
|
||||
global: {
|
||||
stubs: ['svg'],
|
||||
},
|
||||
})
|
||||
await flushPromises()
|
||||
expect(wrapper.find('.delete-btn').exists()).toBe(true)
|
||||
|
||||
@@ -11,8 +11,8 @@ global.fetch = vi.fn()
|
||||
const mockRouter = createRouter({
|
||||
history: createMemoryHistory(),
|
||||
routes: [
|
||||
{ path: '/auth/login', name: 'Login' },
|
||||
{ path: '/profile', name: 'UserProfile' },
|
||||
{ path: '/auth/login', name: 'Login', component: { template: '<div />' } },
|
||||
{ path: '/profile', name: 'UserProfile', component: { template: '<div />' } },
|
||||
],
|
||||
})
|
||||
|
||||
|
||||
@@ -4,6 +4,10 @@ import { nextTick } from 'vue'
|
||||
import LoginButton from '../LoginButton.vue'
|
||||
import { authenticateParent, logoutParent } from '../../../stores/auth'
|
||||
|
||||
vi.mock('vue-router', () => ({
|
||||
useRouter: vi.fn(() => ({ push: vi.fn() })),
|
||||
}))
|
||||
|
||||
// Mock imageCache module
|
||||
vi.mock('@/common/imageCache', () => ({
|
||||
getCachedImageUrl: vi.fn(async (imageId: string) => `blob:mock-url-${imageId}`),
|
||||
|
||||
20
frontend/vue-app/src/test/setup.ts
Normal file
20
frontend/vue-app/src/test/setup.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { vi } from 'vitest'
|
||||
|
||||
// jsdom does not implement scrollTo — stub it to suppress "Not implemented" warnings
|
||||
window.scrollTo = vi.fn()
|
||||
|
||||
// jsdom does not support navigation — stub window.location to suppress
|
||||
// "Not implemented: navigation to another Document" warnings
|
||||
Object.defineProperty(window, 'location', {
|
||||
value: { href: '', pathname: '/', assign: vi.fn(), replace: vi.fn(), reload: vi.fn() },
|
||||
writable: true,
|
||||
})
|
||||
|
||||
// Globally mock imageCache so component tests don't make real fetch calls
|
||||
// and don't spam "response.blob is not a function" errors in jsdom.
|
||||
vi.mock('@/common/imageCache', () => ({
|
||||
getCachedImageUrl: vi.fn().mockResolvedValue(''),
|
||||
getCachedImageBlob: vi.fn().mockResolvedValue(new Blob()),
|
||||
revokeImageUrl: vi.fn(),
|
||||
revokeAllImageUrls: vi.fn(),
|
||||
}))
|
||||
Reference in New Issue
Block a user