WP-01: domain contract and failing tests for auth and user management
Domain entities/ports, service stubs, 18 application unit tests with in-memory fakes, API integration tests for /api/auth and /api/users, Vitest specs for the auth store, login page and user form, Playwright auth/user-management flow. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
42
frontend/src/components/UserForm.test.ts
Normal file
42
frontend/src/components/UserForm.test.ts
Normal file
@ -0,0 +1,42 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import UserForm from './UserForm.vue'
|
||||
|
||||
describe('UserForm', () => {
|
||||
it('emits the new user payload in create mode', async () => {
|
||||
const w = mount(UserForm, { props: { mode: 'create' } })
|
||||
await w.find('input[name=email]').setValue('u@x.de')
|
||||
await w.find('input[name=display_name]').setValue('User')
|
||||
await w.find('input[name=password]').setValue('user-password-123')
|
||||
await w.find('select[name=role]').setValue('admin')
|
||||
await w.find('form').trigger('submit')
|
||||
expect(w.emitted('submit')![0][0]).toEqual({
|
||||
email: 'u@x.de',
|
||||
display_name: 'User',
|
||||
password: 'user-password-123',
|
||||
role: 'admin',
|
||||
})
|
||||
})
|
||||
|
||||
it('rejects short passwords client-side', async () => {
|
||||
const w = mount(UserForm, { props: { mode: 'create' } })
|
||||
await w.find('input[name=email]').setValue('u@x.de')
|
||||
await w.find('input[name=display_name]').setValue('User')
|
||||
await w.find('input[name=password]').setValue('short')
|
||||
await w.find('form').trigger('submit')
|
||||
expect(w.emitted('submit')).toBeUndefined()
|
||||
expect(w.text()).toContain('at least 12 characters')
|
||||
})
|
||||
|
||||
it('hides email and password in edit mode and prefills values', () => {
|
||||
const w = mount(UserForm, {
|
||||
props: {
|
||||
mode: 'edit',
|
||||
user: { id: '1', email: 'u@x.de', display_name: 'User', role: 'user', is_active: false },
|
||||
},
|
||||
})
|
||||
expect(w.find('input[name=email]').exists()).toBe(false)
|
||||
expect(w.find('input[name=password]').exists()).toBe(false)
|
||||
expect((w.find('input[name=display_name]').element as HTMLInputElement).value).toBe('User')
|
||||
expect((w.find('input[name=is_active]').element as HTMLInputElement).checked).toBe(false)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user