Compare commits
4 Commits
ffbbc0dfad
...
feature/d7
| Author | SHA1 | Date | |
|---|---|---|---|
| 4d7333b714 | |||
| 62b07597f5 | |||
| 5ce35af813 | |||
| 7f6855be62 |
@@ -1,83 +0,0 @@
|
|||||||
using System.Net;
|
|
||||||
using System.Net.Http.Json;
|
|
||||||
using System.Text.Json;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using GerbilManagerWebAPI.Models;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
|
|
||||||
namespace GerbilManager.Tests;
|
|
||||||
|
|
||||||
/// <summary>profilePhotoUrl: computed field on GerbilDto — first photo by sortOrder, or null.</summary>
|
|
||||||
public class GerbilProfilePhotoTests : IClassFixture<ApiFactory>
|
|
||||||
{
|
|
||||||
private readonly HttpClient _client;
|
|
||||||
private readonly ApiFactory _factory;
|
|
||||||
|
|
||||||
public GerbilProfilePhotoTests(ApiFactory factory)
|
|
||||||
{
|
|
||||||
_factory = factory;
|
|
||||||
_client = factory.CreateClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Guid ExtractId(string json) =>
|
|
||||||
Guid.Parse(Regex.Match(json, "\"id\":\"([^\"]+)\"").Groups[1].Value);
|
|
||||||
|
|
||||||
private static string? GetStr(JsonElement el, string prop) =>
|
|
||||||
el.TryGetProperty(prop, out var v) && v.ValueKind == JsonValueKind.String
|
|
||||||
? v.GetString() : null;
|
|
||||||
|
|
||||||
private async Task<Guid> CreateGerbil(string name)
|
|
||||||
{
|
|
||||||
var resp = await _client.PostAsync("/gerbils", JsonContent.Create(new { name, gender = "female" }));
|
|
||||||
Assert.Equal(HttpStatusCode.Created, resp.StatusCode);
|
|
||||||
return ExtractId(await resp.Content.ReadAsStringAsync());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void InsertPhotos(Guid gerbilId, params (string fileName, int sortOrder)[] photos)
|
|
||||||
{
|
|
||||||
using var scope = _factory.Services.CreateScope();
|
|
||||||
var db = scope.ServiceProvider.GetRequiredService<ApplicationContext>();
|
|
||||||
foreach (var (fn, so) in photos)
|
|
||||||
db.GerbilPhotos.Add(new GerbilPhoto
|
|
||||||
{
|
|
||||||
Id = Guid.NewGuid(), GerbilId = gerbilId,
|
|
||||||
FileName = fn, SortOrder = so, CreatedAt = DateTimeOffset.UtcNow,
|
|
||||||
});
|
|
||||||
db.SaveChanges();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task GetById_without_photos_returns_null_profilePhotoUrl()
|
|
||||||
{
|
|
||||||
var id = await CreateGerbil("NoPhoto");
|
|
||||||
var json = await _client.GetStringAsync($"/gerbils/{id}");
|
|
||||||
var el = JsonDocument.Parse(json).RootElement;
|
|
||||||
Assert.True(el.TryGetProperty("profilePhotoUrl", out var v));
|
|
||||||
Assert.Equal(JsonValueKind.Null, v.ValueKind);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task GetById_with_photos_returns_lowest_sortOrder_url()
|
|
||||||
{
|
|
||||||
var id = await CreateGerbil("PhotoGerbil");
|
|
||||||
InsertPhotos(id, ("second.jpg", 1), ("first.jpg", 0));
|
|
||||||
|
|
||||||
var json = await _client.GetStringAsync($"/gerbils/{id}");
|
|
||||||
var el = JsonDocument.Parse(json).RootElement;
|
|
||||||
Assert.Equal("/photos/files/first.jpg", GetStr(el, "profilePhotoUrl"));
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task GetList_returns_profilePhotoUrl_without_n_plus_1()
|
|
||||||
{
|
|
||||||
var id = await CreateGerbil("ListPhoto");
|
|
||||||
InsertPhotos(id, ("list-photo.jpg", 0));
|
|
||||||
|
|
||||||
var json = await _client.GetStringAsync("/gerbils");
|
|
||||||
var root = JsonDocument.Parse(json).RootElement;
|
|
||||||
var items = root.GetProperty("items").EnumerateArray().ToList();
|
|
||||||
var gerbil = items.FirstOrDefault(x => GetStr(x, "id") == id.ToString());
|
|
||||||
Assert.NotEqual(default, gerbil);
|
|
||||||
Assert.Equal("/photos/files/list-photo.jpg", GetStr(gerbil, "profilePhotoUrl"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -29,8 +29,7 @@ namespace GerbilManagerWebAPI.Dtos
|
|||||||
List<string> CharacterTraits,
|
List<string> CharacterTraits,
|
||||||
string? CharacterNote,
|
string? CharacterNote,
|
||||||
bool? IsDeaf,
|
bool? IsDeaf,
|
||||||
bool IsResident,
|
bool IsResident);
|
||||||
string? ProfilePhotoUrl);
|
|
||||||
|
|
||||||
public record LitterDto(
|
public record LitterDto(
|
||||||
Guid Id,
|
Guid Id,
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ using GerbilManagerWebAPI.Common;
|
|||||||
using GerbilManagerWebAPI.Dtos;
|
using GerbilManagerWebAPI.Dtos;
|
||||||
using GerbilManagerWebAPI.Models;
|
using GerbilManagerWebAPI.Models;
|
||||||
using Gridify;
|
using Gridify;
|
||||||
using Gridify.EntityFramework;
|
|
||||||
using Microsoft.AspNetCore.Http.HttpResults;
|
using Microsoft.AspNetCore.Http.HttpResults;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
@@ -17,21 +16,8 @@ namespace GerbilManagerWebAPI.Endpoints
|
|||||||
|
|
||||||
// GET /gerbils (Gridify: filter/order/page; e.g. status==Active, litterId==…, orderBy=name)
|
// GET /gerbils (Gridify: filter/order/page; e.g. status==Active, litterId==…, orderBy=name)
|
||||||
group.MapGet("/", async ([AsParameters] GridifyParams query, ApplicationContext db) =>
|
group.MapGet("/", async ([AsParameters] GridifyParams query, ApplicationContext db) =>
|
||||||
{
|
TypedResults.Ok(await db.Gerbils.AsNoTracking()
|
||||||
var q = query.ToQuery();
|
.ToPagedResultAsync(query, ToDto)));
|
||||||
var paging = await db.Gerbils.AsNoTracking().GridifyAsync(q);
|
|
||||||
var ids = paging.Data.Select(g => g.Id).ToList();
|
|
||||||
var photoMap = ids.Count == 0 ? new Dictionary<Guid, string>() :
|
|
||||||
await db.GerbilPhotos.AsNoTracking()
|
|
||||||
.Where(p => ids.Contains(p.GerbilId))
|
|
||||||
.GroupBy(p => p.GerbilId)
|
|
||||||
.Select(g => new { GerbilId = g.Key, FileName = g.OrderBy(p => p.SortOrder).First().FileName })
|
|
||||||
.ToDictionaryAsync(x => x.GerbilId, x => x.FileName);
|
|
||||||
var items = paging.Data
|
|
||||||
.Select(g => ToDto(g, photoMap.TryGetValue(g.Id, out var fn) ? $"/photos/files/{fn}" : null))
|
|
||||||
.ToList();
|
|
||||||
return TypedResults.Ok(new PagedResult<GerbilDto>(items, paging.Count, q.Page, q.PageSize));
|
|
||||||
});
|
|
||||||
|
|
||||||
// GET /gerbils/breeders — distinct non-empty Herkunft values for the Tiere filter dropdown
|
// GET /gerbils/breeders — distinct non-empty Herkunft values for the Tiere filter dropdown
|
||||||
group.MapGet("/breeders", async (ApplicationContext db) =>
|
group.MapGet("/breeders", async (ApplicationContext db) =>
|
||||||
@@ -44,14 +30,7 @@ namespace GerbilManagerWebAPI.Endpoints
|
|||||||
group.MapGet("/{id:guid}", async Task<Results<Ok<GerbilDto>, NotFound>> (Guid id, ApplicationContext db) =>
|
group.MapGet("/{id:guid}", async Task<Results<Ok<GerbilDto>, NotFound>> (Guid id, ApplicationContext db) =>
|
||||||
{
|
{
|
||||||
var g = await db.Gerbils.AsNoTracking().FirstOrDefaultAsync(x => x.Id == id);
|
var g = await db.Gerbils.AsNoTracking().FirstOrDefaultAsync(x => x.Id == id);
|
||||||
if (g is null) return TypedResults.NotFound();
|
return g is null ? TypedResults.NotFound() : TypedResults.Ok(ToDto(g));
|
||||||
var photoFileName = await db.GerbilPhotos.AsNoTracking()
|
|
||||||
.Where(p => p.GerbilId == id)
|
|
||||||
.OrderBy(p => p.SortOrder)
|
|
||||||
.Select(p => p.FileName)
|
|
||||||
.FirstOrDefaultAsync();
|
|
||||||
var profilePhotoUrl = photoFileName != null ? $"/photos/files/{photoFileName}" : null;
|
|
||||||
return TypedResults.Ok(ToDto(g, profilePhotoUrl));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// POST /gerbils
|
// POST /gerbils
|
||||||
@@ -128,10 +107,10 @@ namespace GerbilManagerWebAPI.Endpoints
|
|||||||
g.IsResident = i.IsResident ?? (isCreate ? true : g.IsResident);
|
g.IsResident = i.IsResident ?? (isCreate ? true : g.IsResident);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static GerbilDto ToDto(Gerbil g, string? profilePhotoUrl = null) => new(
|
internal static GerbilDto ToDto(Gerbil g) => new(
|
||||||
g.Id, g.Name, g.Gender, g.Status, g.LitterId, g.OriginContactId, g.ReceiverContactId,
|
g.Id, g.Name, g.Gender, g.Status, g.LitterId, g.OriginContactId, g.ReceiverContactId,
|
||||||
g.EnclosureId, g.ColorVarietyId, g.DateOfBirth, g.DateOfDeath, g.CauseOfDeath,
|
g.EnclosureId, g.ColorVarietyId, g.DateOfBirth, g.DateOfDeath, g.CauseOfDeath,
|
||||||
g.GoHomeDate, g.Genotype, g.Notes, g.ImportSource, g.ExternalRef, g.OriginBreeder,
|
g.GoHomeDate, g.Genotype, g.Notes, g.ImportSource, g.ExternalRef, g.OriginBreeder,
|
||||||
g.CharacterTraits, g.CharacterNote, g.IsDeaf, g.IsResident, profilePhotoUrl);
|
g.CharacterTraits, g.CharacterNote, g.IsDeaf, g.IsResident);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,79 +0,0 @@
|
|||||||
/** 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('')
|
|
||||||
})
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
/** LITTER-JUVENILE-DETAILS: Jungtier-Felder (Farbschlag/Abgabe/Verstorben) im Wurf-Detail. */
|
|
||||||
import { de, expect, skipUnlessMock, test } from './fixtures'
|
|
||||||
|
|
||||||
const t = de.pages.litters
|
|
||||||
|
|
||||||
test('Jungtier-Liste zeigt Farbschlag, Abgabedatum, Abnehmer, Todesdatum und Todesursache', async ({
|
|
||||||
page,
|
|
||||||
}) => {
|
|
||||||
skipUnlessMock()
|
|
||||||
await page.goto('/wuerfe/w-kruemel')
|
|
||||||
await expect(page.getByRole('heading', { name: 'Wurf K' })).toBeVisible()
|
|
||||||
|
|
||||||
// Krümel: Active, colorVarietyId cv-agouti → Farbschlag 'Agouti'
|
|
||||||
const kruemelCard = page.getByRole('link', { name: /Krümel/ })
|
|
||||||
await expect(kruemelCard).toBeVisible()
|
|
||||||
await expect(kruemelCard).toContainText(`${t.detail.juvenileFields.colorVariety}: Agouti`)
|
|
||||||
|
|
||||||
// Pippa: GivenAway, Gold, goHomeDate 2025-05-01, Abnehmer Familie Huber
|
|
||||||
const pippaCard = page.getByRole('link', { name: /Pippa/ })
|
|
||||||
await expect(pippaCard).toBeVisible()
|
|
||||||
await expect(pippaCard).toContainText(`${t.detail.juvenileFields.colorVariety}: Gold`)
|
|
||||||
await expect(pippaCard).toContainText(t.detail.juvenileFields.goHomeDate)
|
|
||||||
await expect(pippaCard).toContainText(`${t.detail.juvenileFields.receiver}: Familie Huber`)
|
|
||||||
|
|
||||||
// Benny: Deceased, no colorVarietyId, dateOfDeath + causeOfDeath
|
|
||||||
const bennyCard = page.getByRole('link', { name: /Benny/ })
|
|
||||||
await expect(bennyCard).toBeVisible()
|
|
||||||
await expect(bennyCard).toContainText(t.detail.juvenileFields.dateOfDeath)
|
|
||||||
await expect(bennyCard).toContainText(`${t.detail.juvenileFields.causeOfDeath}: Altersschwäche`)
|
|
||||||
})
|
|
||||||
@@ -108,7 +108,6 @@ function gerbil(
|
|||||||
notes: null,
|
notes: null,
|
||||||
// BESTAND-FILTER: default = eigener Bestand; einzelne externe Ahnen unten gesetzt.
|
// BESTAND-FILTER: default = eigener Bestand; einzelne externe Ahnen unten gesetzt.
|
||||||
isResident: true,
|
isResident: true,
|
||||||
profilePhotoUrl: null,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +120,7 @@ export function seedDb(): MockDb {
|
|||||||
originContactId: 'con-meier',
|
originContactId: 'con-meier',
|
||||||
originBreeder: 'Clan-Kleine-Chaoten',
|
originBreeder: 'Clan-Kleine-Chaoten',
|
||||||
},
|
},
|
||||||
{ ...gerbil('fridolin', 'Fridolin', 'male', '2023-05-01', 'w-fridolin', 'cv-schwarz', 'aa CC DD EE GG PP spsp rere'), enclosureId: 'enc-gross', originBreeder: 'Zoohandlung Meier', profilePhotoUrl: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==' },
|
{ ...gerbil('fridolin', 'Fridolin', 'male', '2023-05-01', 'w-fridolin', 'cv-schwarz', 'aa CC DD EE GG PP spsp rere'), enclosureId: 'enc-gross', originBreeder: 'Zoohandlung Meier' },
|
||||||
gerbil('luna', 'Luna', 'female', '2023-08-15', 'w-luna', 'cv-gold', 'AA CC DD EE GG pp spsp rere'),
|
gerbil('luna', 'Luna', 'female', '2023-08-15', 'w-luna', 'cv-gold', 'AA CC DD EE GG pp spsp rere'),
|
||||||
gerbil('balu', 'Balu', 'male', '2021-04-20', 'w-balu', 'cv-agouti'),
|
gerbil('balu', 'Balu', 'male', '2021-04-20', 'w-balu', 'cv-agouti'),
|
||||||
gerbil('maja', 'Maja', 'female', '2021-06-11', null, 'cv-schwarz-schecke', 'aa CC DD EE GG PP Spsp rere'),
|
gerbil('maja', 'Maja', 'female', '2021-06-11', null, 'cv-schwarz-schecke', 'aa CC DD EE GG PP Spsp rere'),
|
||||||
@@ -152,19 +151,6 @@ export function seedDb(): MockDb {
|
|||||||
enclosureId: 'enc-leer',
|
enclosureId: 'enc-leer',
|
||||||
notes: 'neugieriger Entdecker',
|
notes: 'neugieriger Entdecker',
|
||||||
},
|
},
|
||||||
// LITTER-JUVENILE-DETAILS: Jungtiere für Wurf K mit Zusatzinfos.
|
|
||||||
{
|
|
||||||
...gerbil('pup-abgabe', 'Pippa', 'female', '2025-03-12', 'w-kruemel', 'cv-gold'),
|
|
||||||
status: 'GivenAway' as const,
|
|
||||||
goHomeDate: '2025-05-01',
|
|
||||||
receiverContactId: 'con-huber',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
...gerbil('pup-verstorben', 'Benny', 'male', '2025-03-12', 'w-kruemel', null),
|
|
||||||
status: 'Deceased' as const,
|
|
||||||
dateOfDeath: '2025-04-15',
|
|
||||||
causeOfDeath: 'Altersschwäche',
|
|
||||||
},
|
|
||||||
// UI-POLISH-1: Import-Stub ohne Namen — testet den '(ohne Namen)'-Platzhalter in Liste + Detail.
|
// UI-POLISH-1: Import-Stub ohne Namen — testet den '(ohne Namen)'-Platzhalter in Liste + Detail.
|
||||||
gerbil('nameless-stub', '', 'male', '2023-01-01', null, null),
|
gerbil('nameless-stub', '', 'male', '2023-01-01', null, null),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -154,20 +154,3 @@ test('Gencode-Chip zeigt Genotyp statt Farbname (STAMMBAUM-GENCODE)', async ({ p
|
|||||||
const fridolinCard = page.locator('.pedigree-card').filter({ hasText: 'Fridolin' })
|
const fridolinCard = page.locator('.pedigree-card').filter({ hasText: 'Fridolin' })
|
||||||
await expect(fridolinCard.locator('.pedigree-chip')).toContainText('aa CC')
|
await expect(fridolinCard.locator('.pedigree-chip')).toContainText('aa CC')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Tier mit Foto zeigt Avatar-Bild, Tier ohne Foto zeigt Rennmaus-Icon (STAMMBAUM-AVATAR)', async ({ page }) => {
|
|
||||||
skipUnlessMock()
|
|
||||||
// Fridolin hat profilePhotoUrl (data URI) → <img.pedigree-card__avatar> sichtbar
|
|
||||||
// Krümel hat profilePhotoUrl=null → kein img, SVG-Icon sichtbar
|
|
||||||
await page.goto('/rennmaeuse/kruemel/stammbaum')
|
|
||||||
await expect(page.locator('.pedigree-card').first()).toBeVisible()
|
|
||||||
|
|
||||||
// Fridolin ist Vater von Krümel → seine Karte enthält ein <img>
|
|
||||||
const fridolinCard = page.locator('.pedigree-card').filter({ hasText: 'Fridolin' })
|
|
||||||
await expect(fridolinCard.locator('img.pedigree-card__avatar')).toBeVisible()
|
|
||||||
|
|
||||||
// Krümel (root) hat kein Foto → SVG-Icon im Foto-Slot
|
|
||||||
const rootCard = page.locator('.pedigree-card.pedigree-card--root')
|
|
||||||
await expect(rootCard.locator('img.pedigree-card__avatar')).not.toBeAttached()
|
|
||||||
await expect(rootCard.locator('svg[role="img"]')).toBeVisible()
|
|
||||||
})
|
|
||||||
|
|||||||
@@ -56,8 +56,6 @@ export interface Gerbil {
|
|||||||
isResident?: boolean
|
isResident?: boolean
|
||||||
/** FORM-FIELDS-1: true=gehörlos, false=hörend, null=unbekannt. */
|
/** FORM-FIELDS-1: true=gehörlos, false=hörend, null=unbekannt. */
|
||||||
isDeaf?: boolean | null
|
isDeaf?: boolean | null
|
||||||
/** STAMMBAUM-AVATAR: URL des Profilfotos (erstes Foto nach sortOrder); null = kein Foto. API-relativ oder absolut. */
|
|
||||||
profilePhotoUrl?: string | null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Payload for POST /gerbils. */
|
/** Payload for POST /gerbils. */
|
||||||
|
|||||||
@@ -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, genotypeToFarbschlag, UNKNOWN_FARBSCHLAG } from '../genetics'
|
import { fromDisplayString } 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,14 +307,7 @@ export default function GerbilFormPage() {
|
|||||||
<span className="farbschlag-value">
|
<span className="farbschlag-value">
|
||||||
<select
|
<select
|
||||||
value={form.colorVarietyId}
|
value={form.colorVarietyId}
|
||||||
onChange={(e) => {
|
onChange={(e) => set('colorVarietyId', e.target.value)}
|
||||||
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) => (
|
||||||
@@ -394,23 +387,7 @@ 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) => {
|
onChange={(e) => set('genotype', e.target.value)}
|
||||||
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'}>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import { Link, useNavigate, useParams } from 'react-router-dom'
|
|||||||
import Tree from 'react-d3-tree'
|
import Tree from 'react-d3-tree'
|
||||||
import type { CustomNodeElementProps, Point, RawNodeDatum } from 'react-d3-tree'
|
import type { CustomNodeElementProps, Point, RawNodeDatum } from 'react-d3-tree'
|
||||||
import { de } from '../strings/de'
|
import { de } from '../strings/de'
|
||||||
import { API_BASE_URL, ApiError } from '../api/client'
|
import { ApiError } from '../api/client'
|
||||||
import { listLitters } from '../api/litters'
|
import { listLitters } from '../api/litters'
|
||||||
import { listColorVarieties } from '../api/lookups'
|
import { listColorVarieties } from '../api/lookups'
|
||||||
import { getInbreedingCoefficient } from '../api/pedigree'
|
import { getInbreedingCoefficient } from '../api/pedigree'
|
||||||
@@ -381,14 +381,6 @@ function PedigreeCard({
|
|||||||
const g = node.gerbil
|
const g = node.gerbil
|
||||||
const chip = farbschlag ? chipColorFor(farbschlag) : null
|
const chip = farbschlag ? chipColorFor(farbschlag) : null
|
||||||
const dob = g.dateOfBirth ? formatDate(g.dateOfBirth) : null
|
const dob = g.dateOfBirth ? formatDate(g.dateOfBirth) : null
|
||||||
const [imgError, setImgError] = useState(false)
|
|
||||||
useEffect(() => setImgError(false), [g.id])
|
|
||||||
const photoUrl =
|
|
||||||
!imgError && g.profilePhotoUrl
|
|
||||||
? /^(https?:|data:|\/\/)/.test(g.profilePhotoUrl)
|
|
||||||
? g.profilePhotoUrl
|
|
||||||
: `${API_BASE_URL}${g.profilePhotoUrl}`
|
|
||||||
: null
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={isRoot ? 'pedigree-card pedigree-card--root' : 'pedigree-card'}
|
className={isRoot ? 'pedigree-card pedigree-card--root' : 'pedigree-card'}
|
||||||
@@ -396,17 +388,9 @@ function PedigreeCard({
|
|||||||
role={isRoot ? undefined : 'button'}
|
role={isRoot ? undefined : 'button'}
|
||||||
title={isRoot ? undefined : t.tapHint}
|
title={isRoot ? undefined : t.tapHint}
|
||||||
>
|
>
|
||||||
<div className="pedigree-card__photo" aria-hidden={!photoUrl || undefined}>
|
{/* Foto-Platzhalter — echte Fotos kommen mit FEAT-6. */}
|
||||||
{photoUrl ? (
|
<div className="pedigree-card__photo" aria-hidden="true">
|
||||||
<img
|
<GerbilIcon size="1.6rem" />
|
||||||
src={photoUrl}
|
|
||||||
alt={g.name || ''}
|
|
||||||
className="pedigree-card__avatar"
|
|
||||||
onError={() => setImgError(true)}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<GerbilIcon size="1.6rem" aria-hidden="true" />
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
<div className="pedigree-card__body">
|
<div className="pedigree-card__body">
|
||||||
<div className="pedigree-card__name">
|
<div className="pedigree-card__name">
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
import { useCallback, useMemo } from 'react'
|
import { useMemo } from 'react'
|
||||||
import { Link, useParams } from 'react-router-dom'
|
import { Link, useParams } from 'react-router-dom'
|
||||||
import { de } from '../strings/de'
|
import { de } from '../strings/de'
|
||||||
import { getLitter } from '../api/litters'
|
import { getLitter } from '../api/litters'
|
||||||
import { getGerbil, listGerbils } from '../api/gerbils'
|
import { getGerbil, listGerbils } from '../api/gerbils'
|
||||||
import { listColorVarieties, listContacts } from '../api/lookups'
|
|
||||||
import { condition } from '../api/gridify'
|
import { condition } from '../api/gridify'
|
||||||
import { useApi } from '../hooks/useApi'
|
import { useApi } from '../hooks/useApi'
|
||||||
import { formatDate, genderLabel } from '../format/labels'
|
import { formatDate } from '../format/labels'
|
||||||
import { isValidGenotype } from '../format/genotypeText'
|
import { isValidGenotype } from '../format/genotypeText'
|
||||||
import { breed, fromDisplayString, genotypeToFarbschlag, UNKNOWN_FARBSCHLAG, type BreedingResult } from '../genetics'
|
import { breed, fromDisplayString, type BreedingResult } from '../genetics'
|
||||||
import BreedingResultView from '../components/BreedingResultView'
|
import BreedingResultView from '../components/BreedingResultView'
|
||||||
|
|
||||||
export default function WurfDetailPage() {
|
export default function WurfDetailPage() {
|
||||||
@@ -44,38 +43,6 @@ export default function WurfDetailPage() {
|
|||||||
return breed(fromDisplayString(fg), fromDisplayString(mg))
|
return breed(fromDisplayString(fg), fromDisplayString(mg))
|
||||||
}, [father.data, mother.data])
|
}, [father.data, mother.data])
|
||||||
|
|
||||||
// Farbschlag + Abnehmer lookups for the juvenile list.
|
|
||||||
const colorVarieties = useApi(() => listColorVarieties(), [])
|
|
||||||
const contacts = useApi(() => listContacts(), [])
|
|
||||||
|
|
||||||
const colorNameById = useMemo(
|
|
||||||
() => new Map((colorVarieties.data ?? []).map((c) => [c.id, c.name])),
|
|
||||||
[colorVarieties.data],
|
|
||||||
)
|
|
||||||
const contactNameById = useMemo(
|
|
||||||
() => new Map((contacts.data ?? []).map((c) => [c.id, c.name])),
|
|
||||||
[contacts.data],
|
|
||||||
)
|
|
||||||
|
|
||||||
const farbschlagOf = useCallback(
|
|
||||||
(g: { colorVarietyId: string | null; genotype: string | null }): string | null => {
|
|
||||||
if (g.colorVarietyId) {
|
|
||||||
const name = colorNameById.get(g.colorVarietyId)
|
|
||||||
if (name) return name
|
|
||||||
}
|
|
||||||
if (g.genotype?.trim()) {
|
|
||||||
try {
|
|
||||||
const name = genotypeToFarbschlag(fromDisplayString(g.genotype))
|
|
||||||
return name === UNKNOWN_FARBSCHLAG ? null : name
|
|
||||||
} catch {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
},
|
|
||||||
[colorNameById],
|
|
||||||
)
|
|
||||||
|
|
||||||
if (litter.loading) return <p className="muted">{de.common.loading}</p>
|
if (litter.loading) return <p className="muted">{de.common.loading}</p>
|
||||||
if (litter.error || !litter.data) {
|
if (litter.error || !litter.data) {
|
||||||
return (
|
return (
|
||||||
@@ -150,24 +117,14 @@ export default function WurfDetailPage() {
|
|||||||
{!juveniles.loading && registered === 0 && <p className="muted">{t.detail.noJuveniles}</p>}
|
{!juveniles.loading && registered === 0 && <p className="muted">{t.detail.noJuveniles}</p>}
|
||||||
{registered > 0 && (
|
{registered > 0 && (
|
||||||
<ul className="card-list">
|
<ul className="card-list">
|
||||||
{(juveniles.data?.items ?? []).map((g) => {
|
{(juveniles.data?.items ?? []).map((g) => (
|
||||||
const farbe = farbschlagOf(g)
|
<li key={g.id}>
|
||||||
const receiver = g.receiverContactId ? contactNameById.get(g.receiverContactId) : null
|
<Link to={`/rennmaeuse/${g.id}`} className="gerbil-card">
|
||||||
const tJf = t.detail.juvenileFields
|
<span className="gerbil-card__name">{g.name}</span>
|
||||||
return (
|
<span className="gerbil-card__meta">{de.pages.gerbils.genderLabels[g.gender]}</span>
|
||||||
<li key={g.id}>
|
</Link>
|
||||||
<Link to={`/rennmaeuse/${g.id}`} className="gerbil-card">
|
</li>
|
||||||
<span className="gerbil-card__name">{g.name}</span>
|
))}
|
||||||
<span className="gerbil-card__meta">{genderLabel(g.gender)}</span>
|
|
||||||
{farbe && <span className="gerbil-card__meta">{tJf.colorVariety}: {farbe}</span>}
|
|
||||||
{g.goHomeDate && <span className="gerbil-card__meta">{tJf.goHomeDate}: {formatDate(g.goHomeDate)}</span>}
|
|
||||||
{receiver && <span className="gerbil-card__meta">{tJf.receiver}: {receiver}</span>}
|
|
||||||
{g.dateOfDeath && <span className="gerbil-card__meta">{tJf.dateOfDeath}: {formatDate(g.dateOfDeath)}</span>}
|
|
||||||
{g.causeOfDeath && <span className="gerbil-card__meta">{tJf.causeOfDeath}: {g.causeOfDeath}</span>}
|
|
||||||
</Link>
|
|
||||||
</li>
|
|
||||||
)
|
|
||||||
})}
|
|
||||||
</ul>
|
</ul>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
@@ -236,7 +236,6 @@
|
|||||||
width: 42px;
|
width: 42px;
|
||||||
height: 42px;
|
height: 42px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
overflow: hidden;
|
|
||||||
background: var(--color-accent-soft);
|
background: var(--color-accent-soft);
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -244,13 +243,6 @@
|
|||||||
font-size: 1.4rem;
|
font-size: 1.4rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pedigree-card__avatar {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
object-fit: cover;
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.pedigree-card__body {
|
.pedigree-card__body {
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -189,14 +189,6 @@ export const de = {
|
|||||||
edit: 'Bearbeiten',
|
edit: 'Bearbeiten',
|
||||||
back: 'Zurück zur Liste',
|
back: 'Zurück zur Liste',
|
||||||
notFound: 'Dieser Wurf wurde nicht gefunden.',
|
notFound: 'Dieser Wurf wurde nicht gefunden.',
|
||||||
// LITTER-JUVENILE-DETAILS: pro-Jungtier-Felder
|
|
||||||
juvenileFields: {
|
|
||||||
colorVariety: 'Farbschlag',
|
|
||||||
goHomeDate: 'Abgegeben',
|
|
||||||
receiver: 'Abnehmer',
|
|
||||||
dateOfDeath: 'Verstorben',
|
|
||||||
causeOfDeath: 'Todesursache',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
// Formular
|
// Formular
|
||||||
form: {
|
form: {
|
||||||
|
|||||||
@@ -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": "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)",
|
"decision": "birth 2013 + 4 years = death year 2017, no exact date → year-only convention (01.01.2017). Previous entry (17.04.2016) was wrong.",
|
||||||
"dateOfDeath": "17.04.2016",
|
"dateOfDeath": "01.01.2017",
|
||||||
"source": "Julian 2026-06-07 — HUMANQUESTION D6"
|
"source": "Julian 2026-06-07 — HUMANQUESTION D7 (final Skarlett resolution)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Kazu von den Kleinen Chaoten",
|
"name": "Kazu von den Kleinen Chaoten",
|
||||||
@@ -162,6 +162,57 @@
|
|||||||
"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)"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user