feat(onboarding): A2 — Household setup page #34

Merged
marcel merged 11 commits from feat/issue-19-household-setup into master 2026-04-02 19:39:09 +02:00
2 changed files with 26 additions and 0 deletions
Showing only changes of commit 2d1604492d - Show all commits

View File

@@ -18,6 +18,10 @@ export const actions = {
return fail(400, { errors: { name: 'Haushaltsname ist erforderlich' }, name: '' });
}
if (name.length > 100) {
return fail(400, { errors: { name: 'Haushaltsname darf maximal 100 Zeichen lang sein' }, name });
}
const api = apiClient(fetch);
const { data, error } = await api.POST('/v1/households', {
body: { name }

View File

@@ -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,