33 lines
1.6 KiB
JavaScript
33 lines
1.6 KiB
JavaScript
import { describe, it, expect } from 'vitest'
|
|
import { mountSuspended, registerEndpoint } from '@nuxt/test-utils/runtime'
|
|
import Login from '../../app/pages/login.vue'
|
|
|
|
describe('login page', () => {
|
|
it('renders sign in form (local auth always shown)', async () => {
|
|
registerEndpoint('/api/auth/config', () => ({ oidc: { enabled: false, label: '' } }), { method: 'GET' })
|
|
const wrapper = await mountSuspended(Login)
|
|
await new Promise(r => setTimeout(r, 50))
|
|
expect(wrapper.text()).toContain('Sign in')
|
|
expect(wrapper.find('input[type="text"]').exists()).toBe(true)
|
|
expect(wrapper.find('input[type="password"]').exists()).toBe(true)
|
|
})
|
|
|
|
it('shows OIDC button when OIDC is enabled', async () => {
|
|
registerEndpoint('/api/auth/config', () => ({ oidc: { enabled: true, label: 'Sign in with Authentik' } }), { method: 'GET' })
|
|
await clearNuxtData('auth-config')
|
|
const wrapper = await mountSuspended(Login)
|
|
await new Promise(r => setTimeout(r, 150))
|
|
expect(wrapper.text()).toContain('Sign in with Authentik')
|
|
expect(wrapper.find('a[href*="/api/auth/oidc/authorize"]').exists()).toBe(true)
|
|
})
|
|
|
|
it('shows both OIDC button and password form when OIDC is enabled', async () => {
|
|
registerEndpoint('/api/auth/config', () => ({ oidc: { enabled: true, label: 'Sign in with OIDC' } }), { method: 'GET' })
|
|
await clearNuxtData('auth-config')
|
|
const wrapper = await mountSuspended(Login)
|
|
await new Promise(r => setTimeout(r, 150))
|
|
expect(wrapper.find('a[href*="/api/auth/oidc/authorize"]').exists()).toBe(true)
|
|
expect(wrapper.find('input[type="password"]').exists()).toBe(true)
|
|
})
|
|
})
|