test(10-05): bring every SPA module, composable and component under Vitest
- 41 unit and component suites under admin/tests/{app,state,shell,list,form,relation,views,ui}
covering states and a11y roles; every src module is imported by a test
- typed fixture helper assigns each JSON fixture to its generated OpenAPI type
- fix: iconFor ignores inherited object members such as "constructor"
- fix: field controls import ./control instead of the registry (import cycle
left a renderer unregistered depending on module load order)
- fix: dropdown shows the placeholder for an unknown stored value next to an emptyOption
- fix: list announces a failed schema load even when the rows arrive after it
- tailwind no longer scans admin/tests; boardwalk/dist rebuilt
This commit is contained in:
54
admin/tests/views/App.test.ts
Normal file
54
admin/tests/views/App.test.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
||||
import { enableAutoUnmount, flushPromises, mount } from '@vue/test-utils'
|
||||
import App from '../../src/App.vue'
|
||||
import NotFoundView from '../../src/views/NotFoundView.vue'
|
||||
import { setNavigation } from '../../src/state/useNavigation'
|
||||
import { navigationFixture } from '../fixtures/typed'
|
||||
import { resetState, routerAt, signIn } from '../helpers'
|
||||
|
||||
async function mountAt(path: string) {
|
||||
const router = await routerAt(path)
|
||||
const wrapper = mount(App, { global: { plugins: [router] } })
|
||||
await flushPromises()
|
||||
return { wrapper, router }
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
resetState()
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
document.body.innerHTML = ''
|
||||
})
|
||||
|
||||
enableAutoUnmount(afterEach)
|
||||
|
||||
describe('app root', () => {
|
||||
it('renders the login route outside the shell', async () => {
|
||||
const { wrapper } = await mountAt('/login')
|
||||
expect(wrapper.find('nav[aria-label="Wtyczki"]').exists()).toBe(false)
|
||||
expect(wrapper.find('form').exists()).toBe(true)
|
||||
})
|
||||
|
||||
it('renders shell routes inside the shell and an unknown path as not found', async () => {
|
||||
await signIn()
|
||||
setNavigation(navigationFixture.data)
|
||||
const { wrapper } = await mountAt('/nowhere')
|
||||
expect(wrapper.find('nav[aria-label="Wtyczki"]').exists()).toBe(true)
|
||||
expect(wrapper.findComponent(NotFoundView).exists()).toBe(true)
|
||||
expect(wrapper.find('main h1').text()).toBe('Nie znaleziono strony.')
|
||||
})
|
||||
|
||||
it('says so when the admin may open no plugin', async () => {
|
||||
await signIn()
|
||||
const { wrapper } = await mountAt('/')
|
||||
expect(wrapper.find('main h1').text()).toBe('Brak dostępnych sekcji.')
|
||||
})
|
||||
})
|
||||
|
||||
describe('not found view', () => {
|
||||
it('switches its message by the home prop', () => {
|
||||
expect(mount(NotFoundView).find('h1').text()).toBe('Nie znaleziono strony.')
|
||||
expect(mount(NotFoundView, { props: { home: true } }).find('h1').text()).toBe('Brak dostępnych sekcji.')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user