fix(#248): mode-aware delete button text in TagDeleteGuard and fix document.querySelector in spec

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-04-17 00:58:50 +02:00
parent 61976e9479
commit ba8758c085
5 changed files with 16 additions and 7 deletions

View File

@@ -604,6 +604,7 @@
"admin_tag_delete_only_this_sub_root": "Untergeordnete werden zu Root-Schlagwörtern",
"admin_tag_delete_subtree": "Gesamten Teilbaum löschen",
"admin_tag_delete_subtree_warn": "Löscht auch {count} untergeordnete Schlagwörter",
"admin_tag_delete_subtree_confirm_btn": "Teilbaum löschen",
"admin_tag_delete_confirm_heading": "Gib «{name}» zur Bestätigung ein:",
"filter_operator_and": "UND",
"filter_operator_or": "ODER",

View File

@@ -604,6 +604,7 @@
"admin_tag_delete_only_this_sub_root": "Children will become root tags",
"admin_tag_delete_subtree": "Delete entire subtree",
"admin_tag_delete_subtree_warn": "Also deletes {count} child tags",
"admin_tag_delete_subtree_confirm_btn": "Delete subtree",
"admin_tag_delete_confirm_heading": "Type «{name}» to confirm:",
"filter_operator_and": "AND",
"filter_operator_or": "OR",

View File

@@ -604,6 +604,7 @@
"admin_tag_delete_only_this_sub_root": "Las subordinadas se convertirán en etiquetas raíz",
"admin_tag_delete_subtree": "Eliminar todo el subárbol",
"admin_tag_delete_subtree_warn": "También elimina {count} etiquetas subordinadas",
"admin_tag_delete_subtree_confirm_btn": "Eliminar subárbol",
"admin_tag_delete_confirm_heading": "Escribe «{name}» para confirmar:",
"filter_operator_and": "Y",
"filter_operator_or": "O",

View File

@@ -91,10 +91,11 @@ const descendantCount = $derived.by(() => {
<input type="hidden" name="deleteMode" value={selectedMode ?? ''} />
<button
type="submit"
data-testid="delete-submit-btn"
disabled={!canDelete}
class="rounded-sm bg-danger px-4 py-2 font-sans text-xs font-bold tracking-widest text-danger-fg uppercase transition-opacity hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-40"
>
{m.btn_delete()}
{selectedMode === 'subtree' ? m.admin_tag_delete_subtree_confirm_btn() : m.btn_delete()}
</button>
</form>
</div>

View File

@@ -23,22 +23,27 @@ describe('TagDeleteGuard', () => {
it('delete button is disabled initially', async () => {
render(TagDeleteGuard, { tag, allTags });
const btn = document.querySelector<HTMLButtonElement>('button[type="submit"]');
expect(btn?.disabled).toBe(true);
await expect.element(page.getByTestId('delete-submit-btn')).toBeDisabled();
});
it('delete button is enabled after selecting single radio', async () => {
render(TagDeleteGuard, { tag, allTags });
await page.getByRole('radio', { name: /Nur dieses/i }).click();
const btn = document.querySelector<HTMLButtonElement>('button[type="submit"]');
expect(btn?.disabled).toBe(false);
await expect.element(page.getByTestId('delete-submit-btn')).not.toBeDisabled();
});
it('delete button is enabled after selecting subtree radio', async () => {
render(TagDeleteGuard, { tag, allTags });
await page.getByRole('radio', { name: /Gesamten Teilbaum/i }).click();
const btn = document.querySelector<HTMLButtonElement>('button[type="submit"]');
expect(btn?.disabled).toBe(false);
await expect.element(page.getByTestId('delete-submit-btn')).not.toBeDisabled();
});
it('delete button shows subtree-specific text when subtree mode is selected', async () => {
render(TagDeleteGuard, { tag, allTags });
await page.getByRole('radio', { name: /Gesamten Teilbaum/i }).click();
await expect
.element(page.getByTestId('delete-submit-btn'))
.toHaveTextContent(/Teilbaum löschen/i);
});
it('shows descendant count in impact summary', async () => {