Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

test(tours): ask the trail grade cache one request after another, without an await in a loop

Mauricedfd02940b5ee
diff --git a/server/tests/unit/nest/tour-trail-grade.service.test.ts b/server/tests/unit/nest/tour-trail-grade.service.test.ts
index ac787db3e..a53242e06 100644
--- a/server/tests/unit/nest/tour-trail-grade.service.test.ts
+++ b/server/tests/unit/nest/tour-trail-grade.service.test.ts
@@ -78,10 +78,11 @@ describe('TourTrailGradeService (BIK-05)', () => {
it('TOUR-GRADE-006: keeps at most fifty thousand ways, forgetting the longest kept first', async () => {
query.mockResolvedValue([]);
- for (let part = 0; part < 26; part += 1) {
- const ids = Array.from({ length: 2000 }, (_, index) => part * 2000 + index + 1);
- await service.grades({ way_ids: ids });
- }
+ // One request after another, as the planner sends them.
+ await Array.from({ length: 26 }, (_, part) => part).reduce(async (previous, part) => {
+ await previous;
+ await service.grades({ way_ids: Array.from({ length: 2000 }, (_, index) => part * 2000 + index + 1) });
+ }, Promise.resolve());
query.mockClear();
// The first way was forgotten, so it is asked about again; the last one is still kept.
await service.grades({ way_ids: [1] });