mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-06 18:54:17 +00:00
fix(atlas): date a country's first and last trip from the trips that count
The Atlas tooltip took both dates from the start dates of every trip with a place in the country. One trip showed the month it began twice, the month it ended never appeared, and a trip only booked could become the last visit of a country already visited. Both now come from the trips that give the country its status, places and bookings alike: the start of the earliest and the end of the latest, with a trip still under way ending today. The optimistic mark on the client clears the dates the same way the server does. The second label rendered the raw key atlas.lastVisitLabel since #1908 removed it from the locales; the strings are back as they were. The month is built from the date's digits now, because a 'YYYY-MM-DD' string parses as UTC and showed the month before anywhere west of Greenwich. Closes #1535
This commit is contained in:
@@ -171,8 +171,9 @@ describe('Atlas e2e (real auth guard + real service + temp SQLite)', () => {
|
||||
expect(res.status).toBe(200);
|
||||
|
||||
const byCode = Object.fromEntries((res.body.countries as { code: string }[]).map((c) => [c.code, c]));
|
||||
expect(byCode['IT']).toMatchObject({ status: 'visited' });
|
||||
expect(byCode['JP']).toMatchObject({ status: 'planned' });
|
||||
// #1535: the dates run from the start to the end of the trip, not start to start.
|
||||
expect(byCode['IT']).toMatchObject({ status: 'visited', firstVisit: iso(-40), lastVisit: iso(-30) });
|
||||
expect(byCode['JP']).toMatchObject({ status: 'planned', firstVisit: iso(30), lastVisit: iso(40) });
|
||||
expect(res.body.stats.totalCountries).toBe(1);
|
||||
expect(res.body.stats.totalCountriesPlanned).toBe(1);
|
||||
expect(res.body.countries.length).toBeGreaterThan(res.body.stats.totalCountries);
|
||||
|
||||
Reference in New Issue
Block a user