feat(onboarding): add max-length validation for household name (100 chars)
Fails fast before the API call with a clear German error message. Tests boundary: 100 chars accepted, 101 rejected. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -123,6 +123,28 @@ describe('household setup — form action', () => {
|
||||
expect(result.data.name).toBe('');
|
||||
});
|
||||
|
||||
it('returns fail(400) when name exceeds 100 characters', async () => {
|
||||
const longName = 'a'.repeat(101);
|
||||
const result = await actions.default(createRequest({ name: longName }));
|
||||
|
||||
expect(result.status).toBe(400);
|
||||
expect(result.data.errors.name).toBeTruthy();
|
||||
expect(mockPost).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('accepts name at exactly 100 characters', async () => {
|
||||
mockPost.mockResolvedValue(mockSuccess());
|
||||
const maxName = 'a'.repeat(100);
|
||||
|
||||
try {
|
||||
await actions.default(createRequest({ name: maxName }));
|
||||
} catch {
|
||||
// redirect throws
|
||||
}
|
||||
|
||||
expect(mockPost).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('returns fail with form error on API failure', async () => {
|
||||
mockPost.mockResolvedValue({
|
||||
data: undefined,
|
||||
|
||||
Reference in New Issue
Block a user