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', () => {