Files
GerbilManager/gerbil-manager-web/e2e/ausstellungen.spec.ts
2026-06-22 22:43:19 +02:00

50 lines
2.2 KiB
TypeScript

/** EXHIBITION: Ausstellungs-/Show-Ergebnisse je Tier — Tab in der Rennmausakte. */
import { de, expect, skipUnlessMock, test } from './fixtures'
const t = de.pages.tierTabs.exhibitions
const ta = de.pages.tierTabs.actions
const tabs = de.pages.gerbils.detail.tabs
test('Rennmausakte: Ausstellungsergebnis anlegen, sehen und löschen', async ({ page, mockDb }) => {
skipUnlessMock()
await page.goto('/rennmaeuse/kruemel')
// Auf den "Ausstellungen"-Tab wechseln.
await page.getByRole('tab', { name: tabs.exhibitions }).click()
// Leerzustand sichtbar.
await expect(page.getByText(t.empty)).toBeVisible()
// Neues Ergebnis erfassen.
await page.getByRole('button', { name: new RegExp(t.newButton) }).click()
await page.getByLabel(new RegExp(t.fields.eventName)).fill('Nationale Rennmausschau 2026')
await page.getByLabel(t.fields.placement).fill('1. Platz')
await page.getByLabel(t.fields.award).fill('Best in Show')
await page.getByRole('button', { name: ta.save, exact: true }).click()
// Ergebnis erscheint in der Liste.
await expect(page.getByText('Nationale Rennmausschau 2026')).toBeVisible()
await expect(page.getByText('1. Platz')).toBeVisible()
// Wurde im Mock mit Tier-Bezug gespeichert.
expect(mockDb).not.toBeNull()
const row = mockDb!.exhibitions.find((r) => r.eventName === 'Nationale Rennmausschau 2026')
expect(row).toMatchObject({ gerbilId: 'kruemel', placement: '1. Platz', award: 'Best in Show' })
// Löschen (window.confirm automatisch annehmen).
page.once('dialog', (d) => void d.accept())
await page.getByRole('button', { name: ta.delete }).click()
await expect(page.getByText(t.empty)).toBeVisible()
})
test('Rennmausakte: leere Veranstaltung wird abgelehnt (Validierung)', async ({ page }) => {
skipUnlessMock()
await page.goto('/rennmaeuse/kruemel')
await page.getByRole('tab', { name: tabs.exhibitions }).click()
await page.getByRole('button', { name: new RegExp(t.newButton) }).click()
// Ohne Veranstaltung speichern → Validierungsfehler, kein Eintrag.
await page.getByRole('button', { name: ta.save, exact: true }).click()
await expect(page.getByText(t.validation.eventNameRequired)).toBeVisible()
})