fix(test): use m() calls and toBeAttached() in ImportStatusCard tests
Some checks failed
CI / Unit & Component Tests (pull_request) Failing after 2m36s
CI / OCR Service Tests (pull_request) Successful in 15s
CI / Backend Unit Tests (pull_request) Successful in 4m21s
CI / fail2ban Regex (pull_request) Successful in 37s
CI / Compose Bucket Idempotency (pull_request) Successful in 56s

CI Chromium runs with German locale so hardcoded English strings like
'No spreadsheet file found.' never matched. Use m.admin_system_import_*()
to assert whatever locale the browser resolves to.

Spinner test used toBeVisible() on an empty <span> whose dimensions come
entirely from Tailwind CSS. Without layout CSS the span is 0×0 and fails
the visibility check; toBeAttached() asserts DOM presence, which is the
right semantic here.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-05-14 15:12:28 +02:00
parent f4bda546a0
commit 0d934a1b44

View File

@@ -1,5 +1,6 @@
import { describe, expect, it, vi } from 'vitest';
import { render } from 'vitest-browser-svelte';
import { m } from '$lib/paraglide/messages.js';
import ImportStatusCard from './ImportStatusCard.svelte';
type ImportStatus = {
@@ -26,7 +27,7 @@ describe('ImportStatusCard', () => {
}
});
await expect.element(getByTestId('spinner')).toBeVisible();
await expect.element(getByTestId('spinner')).toBeAttached();
});
it('shows processed count at text-base while RUNNING', async () => {
@@ -62,7 +63,7 @@ describe('ImportStatusCard', () => {
}
});
await expect.element(getByText('No spreadsheet file found.')).toBeVisible();
await expect.element(getByText(m.admin_system_import_failed_no_spreadsheet())).toBeVisible();
});
it('shows internal error message when statusCode is IMPORT_FAILED_INTERNAL', async () => {
@@ -73,7 +74,7 @@ describe('ImportStatusCard', () => {
}
});
await expect.element(getByText('Import failed due to an internal error.')).toBeVisible();
await expect.element(getByText(m.admin_system_import_failed_internal())).toBeVisible();
});
it('shows idle text when importStatus is non-null and state is IDLE', async () => {
@@ -84,7 +85,7 @@ describe('ImportStatusCard', () => {
}
});
await expect.element(getByText('No import started.')).toBeVisible();
await expect.element(getByText(m.admin_system_import_status_idle())).toBeVisible();
});
it('shows no spinner when importStatus is null', async () => {