initial commit
This commit is contained in:
32
test/nuxt/login.spec.js
Normal file
32
test/nuxt/login.spec.js
Normal file
@@ -0,0 +1,32 @@
|
||||
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)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user