mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-06 18:54:17 +00:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user