From 6f54b004ca31a7093722cada3e8a61f1c1fa122c Mon Sep 17 00:00:00 2001 From: hsiegeln <37154749+hsiegeln@users.noreply.github.com> Date: Wed, 22 Apr 2026 14:20:51 +0200 Subject: [PATCH] test(views): NULL-Tiebreaker explizit verifizieren MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- tests/integration/recipe-views.test.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/integration/recipe-views.test.ts b/tests/integration/recipe-views.test.ts index 40c4f72..ef0eebb 100644 --- a/tests/integration/recipe-views.test.ts +++ b/tests/integration/recipe-views.test.ts @@ -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', () => {