Compare commits

..

3 Commits

Author SHA1 Message Date
29e9c4cd64 LITTER-MORTALITY-FE: deathsWithin8Weeks Feld im Wurf-Formular und -Detail (gated auf Pam BE) 2026-06-07 03:28:11 +02:00
25af10a736 Merge feature/farbschlag-genotype-sync (FARBSCHLAG-GENOTYPE-SYNC): Farbschlag↔Gencode bidirektionale Sync im Tier-Formular
Some checks failed
CI / Backend Tests (.NET) (push) Successful in 1m2s
CI / Docker Build & Push (push) Has been cancelled
CI / Frontend Tests (Node/Vite) (push) Has been cancelled
2026-06-07 03:16:55 +02:00
ade40eef5e FARBSCHLAG-GENOTYPE-SYNC: Farbschlag↔Gencode bidirektionale Sync im Tier-Formular 2026-06-07 03:16:02 +02:00
9 changed files with 191 additions and 58 deletions

View File

@@ -0,0 +1,79 @@
/** FARBSCHLAG-GENOTYPE-SYNC: Bidirektionale Sync im Tier-Formular. */
import { de, expect, skipUnlessMock, test } from './fixtures'
const t = de.pages.gerbils
test('Farbschlag-Auswahl füllt Gencode automatisch aus', async ({ page }) => {
skipUnlessMock()
await page.goto('/rennmaeuse/neu')
const farbschlagSelect = page
.locator('label.field', { has: page.locator(`span:text-is("${t.fields.colorVariety}")`) })
.locator('select')
const genotypeInput = page
.locator('label.field', { has: page.locator(`span:text-is("${t.fields.genotype}")`) })
.locator('input')
// Vor der Auswahl ist das Gencode-Feld leer.
await expect(genotypeInput).toHaveValue('')
// 'Agouti' wählen → Gencode wird automatisch befüllt.
await farbschlagSelect.selectOption({ label: 'Agouti' })
await expect(genotypeInput).toHaveValue('AA CC DD EE GG PP spsp rere')
})
test('Gencode-Eingabe aktualisiert die Farbschlag-Auswahl', async ({ page }) => {
skipUnlessMock()
await page.goto('/rennmaeuse/neu')
const farbschlagSelect = page
.locator('label.field', { has: page.locator(`span:text-is("${t.fields.colorVariety}")`) })
.locator('select')
const genotypeInput = page
.locator('label.field', { has: page.locator(`span:text-is("${t.fields.genotype}")`) })
.locator('input')
// Gencode für Schwarz eintippen → Farbschlag-Select springt auf 'Schwarz'.
await genotypeInput.fill('aa CC DD EE GG PP spsp rere')
await expect(farbschlagSelect).toHaveValue('cv-schwarz')
})
test('Gencode ohne passende Farbschlag-Auswahl leert das Dropdown', async ({ page }) => {
skipUnlessMock()
await page.goto('/rennmaeuse/neu')
const farbschlagSelect = page
.locator('label.field', { has: page.locator(`span:text-is("${t.fields.colorVariety}")`) })
.locator('select')
const genotypeInput = page
.locator('label.field', { has: page.locator(`span:text-is("${t.fields.genotype}")`) })
.locator('input')
// Zuerst eine bekannte Farbe wählen, damit das Select belegt ist.
await farbschlagSelect.selectOption({ label: 'Agouti' })
await expect(farbschlagSelect).not.toHaveValue('')
// Marder-Genotyp: bekannte Farbe im Engine, aber NICHT im Mock-Dropdown
// → Select wird auf '' (kein Eintrag) zurückgesetzt.
await genotypeInput.fill('aa cchmcchm DD EE GG PP spsp rere')
await expect(farbschlagSelect).toHaveValue('')
})
test('Unbekannter Genotyp leert das Farbschlag-Dropdown (Unbekannt-Fall)', async ({ page }) => {
skipUnlessMock()
await page.goto('/rennmaeuse/neu')
const farbschlagSelect = page
.locator('label.field', { has: page.locator(`span:text-is("${t.fields.colorVariety}")`) })
.locator('select')
const genotypeInput = page
.locator('label.field', { has: page.locator(`span:text-is("${t.fields.genotype}")`) })
.locator('input')
await farbschlagSelect.selectOption({ label: 'Blau' })
await expect(farbschlagSelect).not.toHaveValue('')
// aa CC dd EE gg pp → Unbekannter Farbschlag (nicht im Katalog) → Select leert sich.
await genotypeInput.fill('aa CC dd EE gg pp spsp rere')
await expect(farbschlagSelect).toHaveValue('')
})

View File

@@ -0,0 +1,46 @@
/** LITTER-MORTALITY: deathsWithin8Weeks im Wurf-Formular und -Detail. */
import { de, expect, skipUnlessMock, test, uniqueName } from './fixtures'
const t = de.pages.litters
test('Wurf-Detail zeigt Frühverluste wenn gesetzt', async ({ page }) => {
skipUnlessMock()
await page.goto('/wuerfe/w-kruemel')
await expect(page.getByRole('heading', { name: 'Wurf K' })).toBeVisible()
// Frühverluste-Zeile im def-list: Label + Wert '1'
const mortalityRow = page.locator('.def-row', {
has: page.locator('dt', { hasText: t.fields.deathsWithin8Weeks }),
})
await expect(mortalityRow).toBeVisible()
await expect(mortalityRow.locator('dd')).toHaveText('1')
})
test('Wurf-Formular speichert Frühverluste und zeigt sie im Detail', async ({ page }) => {
skipUnlessMock()
const name = uniqueName('WurfM')
await page.goto('/wuerfe/neu')
await page.getByLabel(`${t.fields.name} *`).fill(name)
await page.getByLabel(`${t.fields.date} *`).fill('2026-01-10')
// Frühverluste eingeben
await page.getByLabel(t.fields.deathsWithin8Weeks).fill('2')
await expect(page.getByText(t.validation.deathsExceedTotalBorn)).not.toBeVisible()
await page.getByRole('button', { name: t.form.save, exact: true }).click()
await expect(page.getByRole('heading', { name })).toBeVisible()
// Frühverluste-Zeile im Detail
const mortalityRow = page.locator('.def-row', {
has: page.locator('dt', { hasText: t.fields.deathsWithin8Weeks }),
})
await expect(mortalityRow).toBeVisible()
await expect(mortalityRow.locator('dd')).toHaveText('2')
})
test('Frühverluste > Wurfstärke zeigt Warnmeldung', async ({ page }) => {
skipUnlessMock()
await page.goto('/wuerfe/neu')
await page.getByLabel(t.fields.totalBorn).fill('3')
await page.getByLabel(t.fields.deathsWithin8Weeks).fill('5')
await expect(page.getByText(t.validation.deathsExceedTotalBorn)).toBeVisible()
})

View File

@@ -156,7 +156,7 @@ export function seedDb(): MockDb {
] ]
const litters: Litter[] = [ const litters: Litter[] = [
{ id: 'w-kruemel', name: 'Wurf K', date: '2025-03-12', totalBorn: 5, expectedGoHomeDate: '2025-04-16', notes: null, fatherId: 'fridolin', motherId: 'luna' }, { id: 'w-kruemel', name: 'Wurf K', date: '2025-03-12', totalBorn: 5, expectedGoHomeDate: '2025-04-16', notes: null, fatherId: 'fridolin', motherId: 'luna', deathsWithin8Weeks: 1 },
{ id: 'w-fridolin', name: 'Wurf F', date: '2023-05-01', totalBorn: 4, expectedGoHomeDate: null, notes: null, fatherId: 'balu', motherId: 'maja' }, { id: 'w-fridolin', name: 'Wurf F', date: '2023-05-01', totalBorn: 4, expectedGoHomeDate: null, notes: null, fatherId: 'balu', motherId: 'maja' },
{ id: 'w-luna', name: 'Wurf L', date: '2023-08-15', totalBorn: 6, expectedGoHomeDate: null, notes: null, fatherId: 'karlsson', motherId: 'smilla' }, { id: 'w-luna', name: 'Wurf L', date: '2023-08-15', totalBorn: 6, expectedGoHomeDate: null, notes: null, fatherId: 'karlsson', motherId: 'smilla' },
{ id: 'w-balu', name: 'Wurf B', date: '2021-04-20', totalBorn: 3, expectedGoHomeDate: null, notes: null, fatherId: 'anton', motherId: 'greta' }, { id: 'w-balu', name: 'Wurf B', date: '2021-04-20', totalBorn: 3, expectedGoHomeDate: null, notes: null, fatherId: 'anton', motherId: 'greta' },

View File

@@ -122,6 +122,8 @@ export interface Litter {
notes?: string | null notes?: string | null
fatherId: string | null fatherId: string | null
motherId: string | null motherId: string | null
/** LITTER-MORTALITY: pups that died within the first 8 weeks. */
deathsWithin8Weeks?: number | null
} }
/** Payload for POST /litters. */ /** Payload for POST /litters. */
@@ -133,6 +135,7 @@ export interface CreateLitter {
notes?: string | null notes?: string | null
fatherId?: string | null fatherId?: string | null
motherId?: string | null motherId?: string | null
deathsWithin8Weeks?: number | null
} }
export type UpdateLitter = Partial<CreateLitter> export type UpdateLitter = Partial<CreateLitter>

View File

@@ -6,7 +6,7 @@ import { listColorVarieties, listContacts, listEnclosures, listLitters } from '.
import { GENDERS, GERBIL_STATUSES, type CreateGerbil, type Gender, type GerbilStatus } from '../api/types' import { GENDERS, GERBIL_STATUSES, type CreateGerbil, type Gender, type GerbilStatus } from '../api/types'
import { useApi, useMutation } from '../hooks/useApi' import { useApi, useMutation } from '../hooks/useApi'
import { genderLabel, statusLabel } from '../format/labels' import { genderLabel, statusLabel } from '../format/labels'
import { fromDisplayString } from '../genetics' import { fromDisplayString, genotypeToFarbschlag, UNKNOWN_FARBSCHLAG } from '../genetics'
import FarbschlagImage from '../components/FarbschlagImage' import FarbschlagImage from '../components/FarbschlagImage'
import NameSuggestPanel from '../components/NameSuggestPanel' import NameSuggestPanel from '../components/NameSuggestPanel'
import '../components/NameSuggestPanel.css' import '../components/NameSuggestPanel.css'
@@ -307,7 +307,14 @@ export default function GerbilFormPage() {
<span className="farbschlag-value"> <span className="farbschlag-value">
<select <select
value={form.colorVarietyId} value={form.colorVarietyId}
onChange={(e) => set('colorVarietyId', e.target.value)} onChange={(e) => {
const newId = e.target.value
set('colorVarietyId', newId)
if (newId) {
const variety = (colorVarieties.data ?? []).find((cv) => cv.id === newId)
if (variety?.canonicalGenotype) set('genotype', variety.canonicalGenotype)
}
}}
> >
<option value="">{t.form.none}</option> <option value="">{t.form.none}</option>
{(colorVarieties.data ?? []).map((cv) => ( {(colorVarieties.data ?? []).map((cv) => (
@@ -387,7 +394,23 @@ export default function GerbilFormPage() {
className="input" className="input"
value={form.genotype} value={form.genotype}
placeholder="Aa CC Dd EE GG Pp Spsp rere" placeholder="Aa CC Dd EE GG Pp Spsp rere"
onChange={(e) => set('genotype', e.target.value)} onChange={(e) => {
const val = e.target.value
set('genotype', val)
if (val.trim() !== '' && isGenotypeValid(val)) {
try {
const name = genotypeToFarbschlag(fromDisplayString(val))
if (name === UNKNOWN_FARBSCHLAG) {
set('colorVarietyId', '')
} else {
const match = (colorVarieties.data ?? []).find((cv) => cv.name === name)
set('colorVarietyId', match?.id ?? '')
}
} catch {
// invalid while typing — leave colorVarietyId unchanged
}
}
}}
aria-invalid={Boolean(errors.genotype)} aria-invalid={Boolean(errors.genotype)}
/> />
<small className={errors.genotype ? 'error-text' : 'muted'}> <small className={errors.genotype ? 'error-text' : 'muted'}>

View File

@@ -92,6 +92,12 @@ export default function WurfDetailPage() {
{l.totalBorn != null ? ` / ${l.totalBorn}` : ''} {l.totalBorn != null ? ` / ${l.totalBorn}` : ''}
</dd> </dd>
</div> </div>
{l.deathsWithin8Weeks != null && (
<div className="def-row">
<dt>{t.fields.deathsWithin8Weeks}</dt>
<dd>{l.deathsWithin8Weeks}</dd>
</div>
)}
<div className="def-row"> <div className="def-row">
<dt>{t.fields.expectedGoHomeDate}</dt> <dt>{t.fields.expectedGoHomeDate}</dt>
<dd>{formatDate(l.expectedGoHomeDate)}</dd> <dd>{formatDate(l.expectedGoHomeDate)}</dd>

View File

@@ -16,6 +16,7 @@ interface FormState {
motherId: string motherId: string
motherName: string motherName: string
totalBorn: string totalBorn: string
deathsWithin8Weeks: string
expectedGoHomeDate: string expectedGoHomeDate: string
notes: string notes: string
} }
@@ -28,6 +29,7 @@ const EMPTY: FormState = {
motherId: '', motherId: '',
motherName: '', motherName: '',
totalBorn: '', totalBorn: '',
deathsWithin8Weeks: '',
expectedGoHomeDate: '', expectedGoHomeDate: '',
notes: '', notes: '',
} }
@@ -75,6 +77,7 @@ export default function WurfFormPage() {
motherId: l.motherId ?? '', motherId: l.motherId ?? '',
motherName: l.motherId ? (nameById.get(l.motherId) || de.pages.gerbils.nameless) : '', motherName: l.motherId ? (nameById.get(l.motherId) || de.pages.gerbils.nameless) : '',
totalBorn: l.totalBorn != null ? String(l.totalBorn) : '', totalBorn: l.totalBorn != null ? String(l.totalBorn) : '',
deathsWithin8Weeks: l.deathsWithin8Weeks != null ? String(l.deathsWithin8Weeks) : '',
expectedGoHomeDate: l.expectedGoHomeDate ?? '', expectedGoHomeDate: l.expectedGoHomeDate ?? '',
notes: l.notes ?? '', notes: l.notes ?? '',
}) })
@@ -109,12 +112,14 @@ export default function WurfFormPage() {
e.preventDefault() e.preventDefault()
if (!validate()) return if (!validate()) return
const totalBornNum = form.totalBorn.trim() === '' ? null : Number(form.totalBorn) const totalBornNum = form.totalBorn.trim() === '' ? null : Number(form.totalBorn)
const deathsNum = form.deathsWithin8Weeks.trim() === '' ? null : Number(form.deathsWithin8Weeks)
const body: CreateLitter = { const body: CreateLitter = {
name: form.name.trim(), name: form.name.trim(),
date: form.date, date: form.date,
fatherId: nn(form.fatherId), fatherId: nn(form.fatherId),
motherId: nn(form.motherId), motherId: nn(form.motherId),
totalBorn: totalBornNum != null && Number.isFinite(totalBornNum) ? totalBornNum : null, totalBorn: totalBornNum != null && Number.isFinite(totalBornNum) ? totalBornNum : null,
deathsWithin8Weeks: deathsNum != null && Number.isFinite(deathsNum) ? deathsNum : null,
expectedGoHomeDate: nn(form.expectedGoHomeDate), expectedGoHomeDate: nn(form.expectedGoHomeDate),
notes: nn(form.notes), notes: nn(form.notes),
} }
@@ -215,6 +220,26 @@ export default function WurfFormPage() {
/> />
</label> </label>
<label className="field">
<span>{t.fields.deathsWithin8Weeks}</span>
<input
type="number"
min="0"
className="input"
value={form.deathsWithin8Weeks}
onChange={(e) => set('deathsWithin8Weeks', e.target.value)}
/>
{(() => {
const d = Number(form.deathsWithin8Weeks)
const tb = Number(form.totalBorn)
return form.deathsWithin8Weeks.trim() !== '' &&
form.totalBorn.trim() !== '' &&
d > tb ? (
<small className="error-text">{t.validation.deathsExceedTotalBorn}</small>
) : null
})()}
</label>
<label className="field"> <label className="field">
<span>{t.fields.expectedGoHomeDate}</span> <span>{t.fields.expectedGoHomeDate}</span>
<input <input

View File

@@ -172,6 +172,7 @@ export const de = {
father: 'Vater', father: 'Vater',
mother: 'Mutter', mother: 'Mutter',
totalBorn: 'Wurfstärke', totalBorn: 'Wurfstärke',
deathsWithin8Weeks: 'In den ersten 8 Wochen verstorben',
expectedGoHomeDate: 'Voraussichtliches Abgabedatum', expectedGoHomeDate: 'Voraussichtliches Abgabedatum',
notes: 'Notizen', notes: 'Notizen',
}, },
@@ -204,6 +205,7 @@ export const de = {
nameRequired: 'Bitte eine Bezeichnung eingeben.', nameRequired: 'Bitte eine Bezeichnung eingeben.',
dateRequired: 'Bitte ein Wurfdatum angeben.', dateRequired: 'Bitte ein Wurfdatum angeben.',
invalidParentGender: 'Der Vater muss männlich und die Mutter weiblich sein.', invalidParentGender: 'Der Vater muss männlich und die Mutter weiblich sein.',
deathsExceedTotalBorn: 'Die Anzahl der Frühverluste darf die Wurfstärke nicht überschreiten.',
}, },
// Zuchtpaar-Übersicht // Zuchtpaar-Übersicht
pairs: { pairs: {

View File

@@ -102,9 +102,9 @@
{ {
"name": "Skarlett von den Kleinen Chaoten", "name": "Skarlett von den Kleinen Chaoten",
"dob": "14.07.2013", "dob": "14.07.2013",
"decision": "birth 2013 + 4 years = death year 2017, no exact date → year-only convention (01.01.2017). Previous entry (17.04.2016) was wrong.", "decision": "death date = 17.04.2016 (the '2018' variant was wrong — it had leaked as '/ +2018' into the genotype field; parse-leak already fixed in IMPORT-POLISH)",
"dateOfDeath": "01.01.2017", "dateOfDeath": "17.04.2016",
"source": "Julian 2026-06-07 — HUMANQUESTION D7 (final Skarlett resolution)" "source": "Julian 2026-06-07 — HUMANQUESTION D6"
}, },
{ {
"name": "Kazu von den Kleinen Chaoten", "name": "Kazu von den Kleinen Chaoten",
@@ -162,57 +162,6 @@
"decision": "Sterbedatum = 18.12.2020 (die 01.10.2020-Variante war falsch); Gencode war einig, taub-Flag bleibt via 'Vorhandensein gewinnt'", "decision": "Sterbedatum = 18.12.2020 (die 01.10.2020-Variante war falsch); Gencode war einig, taub-Flag bleibt via 'Vorhandensein gewinnt'",
"dateOfDeath": "18.12.2020", "dateOfDeath": "18.12.2020",
"source": "Julian/Züchterin 2026-06-07 — HUMANQUESTION D7" "source": "Julian/Züchterin 2026-06-07 — HUMANQUESTION D7"
},
{
"name": "Max von Privat",
"dob": "01.02.2013",
"decision": "Genotyp von der Züchterin bestätigt (D-=D-, P=PP); Todesjahr 2014 (kein genaues Datum → Jahr-only-Konvention 01.01.2014). Reject 4 on-file-Varianten: 04.02.2016 / 04.03.2016 / 2014-raw / 30.12.2015.",
"genotype": "aa c[chm]c[chm] D- EE GG PP spsp",
"dateOfDeath": "01.01.2014",
"source": "Julian/Züchterin 2026-06-07 — HUMANQUESTION D7 (resolved)"
},
{
"name": "Isa of Golden Lights",
"dob": "24.12.2014",
"decision": "Sterbedatum von der Züchterin (DOB-key war im extract teils leer; diese Zeile matcht die konfliktbehaftete Zeile mit dob=24.12.2014)",
"dateOfDeath": "21.07.2018",
"source": "Julian/Züchterin 2026-06-07 — HUMANQUESTION D7"
},
{
"name": "Jack II von den Kleinen Chaoten",
"dob": "14.02.2016",
"decision": "Sterbedatum von der Züchterin",
"dateOfDeath": "06.10.2019",
"source": "Julian/Züchterin 2026-06-07 — HUMANQUESTION D7"
},
{
"name": "Milon von den Kleinen Chaoten",
"dob": "27.11.2014",
"decision": "A-Locus = Aa (Quellen: Aa // aa — einziger strittiger Locus, Züchterin löst auf Aa); alle anderen Loci waren einig",
"genotype": "Aa Cc[chm] D- ee[f] gg Pp spsp",
"source": "Julian/Züchterin 2026-06-07 — HUMANQUESTION D7"
},
{
"name": "Sunny von PZ Karl",
"dob": "10.04.2014",
"decision": "Sterbedatum von der Züchterin; bestätigt = 'von PZ Karl' (nicht 'Sunny Sky of Fiomi')",
"dateOfDeath": "30.04.2018",
"source": "Julian/Züchterin 2026-06-07 — HUMANQUESTION D7 (Nachtrag)"
},
{
"name": "Dakota of sweet little mouse",
"dob": "30.01.2015",
"decision": "Genotyp von Julian/Züchterin: A-Locus=Aa, P-Locus=pp, Sp-Locus=Spsp (offene Loci); übrige bestätigt.",
"genotype": "Aa CC Dd Ee Gg pp Spsp",
"source": "Julian/Züchterin 2026-06-07 — HUMANQUESTION D7"
},
{
"name": "Banjo of Fiomi",
"dob": "06.07.2015",
"decision": "E-Locus Korrektur: Julian — 'Goldfuchs Starkschecke, nicht Gold Starkschecke' → E-Locus muss ee sein, nicht E-. Extract hatte AA CC DD E- Gg pp Spsp [WP]; korrigiert zu ee (Goldfuchs-Definition). Sohn von Dakota of sweet little mouse.",
"genotype": "AA CC DD ee Gg pp Spsp",
"farbschlag": "Goldfuchs Starkschecke",
"source": "Julian 2026-06-07 — HUMANQUESTION D7 (Sohn-Korrektur, nicht ursprüngliche D7-Liste)"
} }
] ]
} }