test(views): NULL-Tiebreaker explizit verifizieren

Code-Review-Finding zu commit 226ca5e: vorheriges Test seedete nur ein
NULL-Recipe, der alphabetische Tiebreaker fuer ungesehene Eintraege
wurde nicht exerciert. Zweites ungesehenes Rezept mit anderer
Einsatzreihenfolge ergaenzt — beweist dass Donauwelle vor
Zwiebelkuchen kommt.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-22 14:20:51 +02:00
parent 226ca5e5ed
commit 6f54b004ca

View File

@@ -90,15 +90,19 @@ describe("listAllRecipesPaginated sort='viewed'", () => {
const profile = createProfile(db, 'Test');
const recipeA = seedRecipe(db, 'Apfelkuchen');
const recipeB = seedRecipe(db, 'Brokkoli');
const recipeC = seedRecipe(db, 'Couscous');
// Inserted in reverse-alphabetical order (Z before D) to prove the
// tiebreaker sorts by title, not insertion order.
const recipeC = seedRecipe(db, 'Zwiebelkuchen');
const recipeD = seedRecipe(db, 'Donauwelle');
// View order: B then A. C never viewed.
// View order: B then A. C and D never viewed.
recordView(db, profile.id, recipeB);
await new Promise((r) => setTimeout(r, 1100));
recordView(db, profile.id, recipeA);
const hits = listAllRecipesPaginated(db, 'viewed', 50, 0, profile.id);
expect(hits.map((h) => h.id)).toEqual([recipeA, recipeB, recipeC]);
// Viewed: A (most recent), B — then unviewed alphabetically: D before C.
expect(hits.map((h) => h.id)).toEqual([recipeA, recipeB, recipeD, recipeC]);
});
it('falls back to alphabetical when profileId is null', () => {