adjust minor test config: global mock of HTML functions and addition of test-id

This commit is contained in:
2025-11-20 09:52:37 +01:00
parent c7526be3c9
commit c81196343f
2 changed files with 10 additions and 9 deletions

View File

@@ -22,6 +22,7 @@
<div data-testid="expand-container" class="flex flex-col items-center"> <div data-testid="expand-container" class="flex flex-col items-center">
<!-- + / × button --> <!-- + / × button -->
<button <button
data-testid="expand-button"
class="flex items-center justify-center w-12 h-12 rounded-full bg-blue-600 text-white text-2xl font-bold hover:bg-blue-700 transition" class="flex items-center justify-center w-12 h-12 rounded-full bg-blue-600 text-white text-2xl font-bold hover:bg-blue-700 transition"
on:click={toggle} on:click={toggle}
aria-expanded={expanded} aria-expanded={expanded}

View File

@@ -6,6 +6,14 @@ import { ROUTE_NAMES } from '../../src/routes';
import { actions } from '../../src/routes/(angemeldet)/list/+page.server'; import { actions } from '../../src/routes/(angemeldet)/list/+page.server';
import { createVorgang } from '$lib/server/vorgangService'; import { createVorgang } from '$lib/server/vorgangService';
// mock animation features of the browser
window.HTMLElement.prototype.scrollIntoView = vi.fn();
window.HTMLElement.prototype.animate = vi.fn(() => ({
finished: Promise.resolve(),
cancel: vi.fn(),
}))
describe('Vorgänge Liste Page EmptyList-Komponente View', () => { describe('Vorgänge Liste Page EmptyList-Komponente View', () => {
it('zeigt EmptyList-Komponente an, wenn Liste leer ist', () => { it('zeigt EmptyList-Komponente an, wenn Liste leer ist', () => {
const testData = { ...baseData, vorgangList: [] }; const testData = { ...baseData, vorgangList: [] };
@@ -47,16 +55,8 @@ describe('Teste Links auf Korrektheit', () => {
}); });
async function clickPlusButton() { async function clickPlusButton() {
// mock animation features of the browser
window.HTMLElement.prototype.scrollIntoView = vi.fn();
window.HTMLElement.prototype.animate = vi.fn(() => ({
finished: Promise.resolve(),
cancel: vi.fn(),
}))
// button is visible // button is visible
const button = screen.getByRole('button') const button = screen.getByTestId('expand-button')
expect(button).toBeInTheDocument(); expect(button).toBeInTheDocument();
await fireEvent.click(button) await fireEvent.click(button)