test(admin): expand admin/tags/[id] page coverage

Adds color picker hidden for child tags, form-success default
hidden state, mergeSuccess null render-without-throw.

3 new tests covering ~5 branches.

Refs #496.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-05-10 06:18:17 +02:00
parent 474779bcc3
commit 54e1fd7331

View File

@@ -118,4 +118,36 @@ describe('admin/tags/[id] page', () => {
const banners = document.querySelectorAll('[role="status"]');
expect(banners.length).toBeGreaterThan(0);
});
it('hides the color picker for child tags (parentId set)', async () => {
render(AdminTagEditPage, {
props: {
data: baseData({ tag: baseTag({ parentId: 't-parent' }) }),
form: undefined
}
});
const colorPicker = document.querySelector('[data-testid="color-picker"]');
expect(colorPicker).toBeNull();
});
it('does not show form-success banner when form is undefined', async () => {
render(AdminTagEditPage, { props: { data: baseData(), form: undefined } });
const banners = document.querySelectorAll('.bg-green-50');
// Some other green elements may exist, but the form-success specifically
// — accept that the banner may not be present
const formSuccessBanner = Array.from(banners).filter((b) =>
(b.textContent ?? '').match(/gespeichert|aktualisiert|saved/i)
);
expect(formSuccessBanner.length).toBe(0);
});
it('renders without throwing when mergeSuccess is null', async () => {
expect(() =>
render(AdminTagEditPage, {
props: { data: baseData({ mergeSuccess: null }), form: undefined }
})
).not.toThrow();
});
});