feat: Implement logic to prevent deletion of system tasks and rewards; update APIs and tests accordingly
All checks were successful
Gitea Actions Demo / build-and-push (push) Successful in 34s
All checks were successful
Gitea Actions Demo / build-and-push (push) Successful in 34s
This commit is contained in:
@@ -1,11 +1,18 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
|
||||
import { mount } from '@vue/test-utils'
|
||||
import App from '../App.vue'
|
||||
|
||||
describe('App', () => {
|
||||
it('mounts renders properly', () => {
|
||||
const wrapper = mount(App)
|
||||
const wrapper = mount(App, {
|
||||
global: {
|
||||
stubs: {
|
||||
'router-view': {
|
||||
template: '<div>You did it!</div>',
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
expect(wrapper.text()).toContain('You did it!')
|
||||
})
|
||||
})
|
||||
|
||||
41
frontend/vue-app/src/__tests__/ItemList.spec.ts
Normal file
41
frontend/vue-app/src/__tests__/ItemList.spec.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import flushPromises from 'flush-promises'
|
||||
import ItemList from '../components/shared/ItemList.vue'
|
||||
|
||||
const systemItem = { id: 'sys1', name: 'System Task', user_id: null }
|
||||
const userItem = { id: 'user1', name: 'User Task', user_id: 'abc123' }
|
||||
|
||||
describe('ItemList.vue', () => {
|
||||
it('does not show delete button for system items', async () => {
|
||||
const wrapper = mount(ItemList, {
|
||||
props: {
|
||||
itemKey: 'items',
|
||||
itemFields: ['name'],
|
||||
deletable: true,
|
||||
testItems: [systemItem],
|
||||
},
|
||||
global: {
|
||||
stubs: ['svg'],
|
||||
},
|
||||
})
|
||||
await flushPromises()
|
||||
expect(wrapper.find('.delete-btn').exists()).toBe(false)
|
||||
})
|
||||
|
||||
it('shows delete button for user items', async () => {
|
||||
const wrapper = mount(ItemList, {
|
||||
props: {
|
||||
itemKey: 'items',
|
||||
itemFields: ['name'],
|
||||
deletable: true,
|
||||
testItems: [userItem],
|
||||
},
|
||||
global: {
|
||||
stubs: ['svg'],
|
||||
},
|
||||
})
|
||||
await flushPromises()
|
||||
expect(wrapper.find('.delete-btn').exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user