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:
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user