fix(atlas): reconcile offline country and region changes together

Keep country and region reads in step with queued writes and with the mark source held by the server. Reconcile a delete already applied elsewhere before removing it from the account queue.
This commit is contained in:
Maurice
2026-12-06 17:20:49 +01:00
parent da0ecc3f88
commit e3922b76d8
13 changed files with 328 additions and 110 deletions
+20
View File
@@ -119,6 +119,26 @@ describe('Atlas e2e (real auth guard + real service + temp SQLite)', () => {
await deleteRows(orm, VisitedCountries, { user: userId });
});
it('returns mark provenance only when requested for offline use', async () => {
await markCountryVisited(orm, userId, 'JP');
await request(server)
.post('/api/addons/atlas/region/DE-BY/mark')
.set('Cookie', sessionCookie(userId))
.send({ name: 'Bayern', country_code: 'DE' })
.expect(200);
const res = await request(server).get('/api/addons/atlas/stats?offline=1').set('Cookie', sessionCookie(userId));
expect(res.status).toBe(200);
expect(res.body.countries).toEqual(
expect.arrayContaining([
expect.objectContaining({ code: 'JP', offline: { directMark: true, placeStatus: null } }),
expect.objectContaining({ code: 'DE', offline: { directMark: false, placeStatus: null } }),
]),
);
await deleteRows(orm, VisitedRegions, { user: userId });
await deleteRows(orm, VisitedCountries, { user: userId });
});
it('200 (not 201) on POST country mark, with upper-cased code written to the db', async () => {
const res = await request(server).post('/api/addons/atlas/country/de/mark').set('Cookie', sessionCookie(userId));
expect(res.status).toBe(200);