46 lines
1.8 KiB
TypeScript
46 lines
1.8 KiB
TypeScript
/** ERWERB: Erwerb/Kauf je Tier — Sektion in der Rennmausakte (anlegen / bearbeiten / löschen). */
|
|
import { de, expect, skipUnlessMock, test } from './fixtures'
|
|
|
|
const t = de.pages.tierTabs.acquisition
|
|
|
|
test('Tierakte: Erwerb erfassen, bearbeiten und löschen', async ({ page, mockDb }) => {
|
|
skipUnlessMock()
|
|
await page.goto('/rennmaeuse/kruemel')
|
|
|
|
const section = page.locator('section.ak-card', { hasText: t.sectionTitle })
|
|
await expect(section).toBeVisible()
|
|
await expect(section).toContainText(t.empty)
|
|
|
|
// Anlegen: Formular öffnen, Felder füllen, speichern.
|
|
await section.getByRole('button', { name: t.addButton }).click()
|
|
await section.getByLabel(t.fields.date).fill('2025-03-14')
|
|
await section.getByLabel(t.fields.price).fill('25.50')
|
|
await section.getByLabel(t.fields.note).fill('Auf der Börse gekauft.')
|
|
await section.getByRole('button', { name: t.addButton }).click()
|
|
|
|
// Eintrag erscheint in der Liste, im Mock gespeichert.
|
|
await expect(section).toContainText('25,50')
|
|
await expect(section).toContainText('Auf der Börse gekauft.')
|
|
expect(mockDb).not.toBeNull()
|
|
expect(mockDb!.acquisitions.length).toBe(1)
|
|
expect(mockDb!.acquisitions[0]).toMatchObject({
|
|
gerbilId: 'kruemel',
|
|
date: '2025-03-14',
|
|
price: 25.5,
|
|
note: 'Auf der Börse gekauft.',
|
|
})
|
|
|
|
// Bearbeiten: Preis ändern.
|
|
await section.getByRole('button', { name: t.edit }).click()
|
|
await section.getByLabel(t.fields.price).fill('30')
|
|
await section.getByRole('button', { name: t.saveButton }).click()
|
|
await expect(section).toContainText('30,00')
|
|
expect(mockDb!.acquisitions[0]).toMatchObject({ price: 30 })
|
|
|
|
// Löschen (window.confirm bestätigen).
|
|
page.once('dialog', (d) => d.accept())
|
|
await section.getByRole('button', { name: t.delete }).click()
|
|
await expect(section).toContainText(t.empty)
|
|
expect(mockDb!.acquisitions.length).toBe(0)
|
|
})
|