mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 00:43:15 +00:00
feat(journey): complete sharing, photo drafts and Studio maps
Connect the Journey backend to the web and mobile UI, including public access and subscriptions, day recordings, photo drafts and per-map framing. Preserve legacy recording responses and cover the new behavior in every locale.
This commit is contained in:
@@ -100,8 +100,11 @@ describe('a journey link with a password', () => {
|
||||
|
||||
const open = await request(server).get(`/api/public/journey/${token}`).set('Cookie', pair);
|
||||
expect(open.status).toBe(200);
|
||||
expect(open.headers['cache-control']).toBe('private, no-store');
|
||||
expect(open.body.journey.title).toBe(journey.title);
|
||||
expect((await request(server).get(`/api/public/journey/${token}/map-layers`).set('Cookie', pair)).status).toBe(200);
|
||||
const map = await request(server).get(`/api/public/journey/${token}/map-layers`).set('Cookie', pair);
|
||||
expect(map.status).toBe(200);
|
||||
expect(map.headers['cache-control']).toBe('private, no-store');
|
||||
});
|
||||
|
||||
it('JPUBLINK-E2E-002: a new password locks out the browsers that unlocked the old one', async () => {
|
||||
@@ -120,7 +123,9 @@ describe('a journey link with a password', () => {
|
||||
it('JPUBLINK-E2E-003: wrong passwords count per address and link, a right one does not', async () => {
|
||||
const { token } = await sharedJourney({ password: 'secret1' });
|
||||
for (let i = 0; i < 10; i++) {
|
||||
const res = await request(server).post(`/api/public/journey/${token}/unlock`).send({ password: `nope${i}` });
|
||||
const res = await request(server)
|
||||
.post(`/api/public/journey/${token}/unlock`)
|
||||
.send({ password: `nope${i}` });
|
||||
expect(res.status).toBe(401);
|
||||
}
|
||||
const limited = await request(server).post(`/api/public/journey/${token}/unlock`).send({ password: 'secret1' });
|
||||
@@ -194,13 +199,17 @@ describe('a journey link with an expiry', () => {
|
||||
});
|
||||
|
||||
describe('the view count of a journey link', () => {
|
||||
it('JPUBLINK-E2E-020: counts each reader once a day, on the journey read only, for the owner only', async () => {
|
||||
it('JPUBLINK-E2E-020: records each reader once a day and shows the count only to the owner', async () => {
|
||||
const { owner, journey, token } = await sharedJourney();
|
||||
|
||||
await request(server).get(`/api/public/journey/${token}`).set('User-Agent', 'Reader A');
|
||||
await request(server).get(`/api/public/journey/${token}`).set('User-Agent', 'Reader A');
|
||||
await request(server).get(`/api/public/journey/${token}`).set('User-Agent', 'Reader B');
|
||||
await request(server).get(`/api/public/journey/${token}/map-layers`).set('User-Agent', 'Reader C');
|
||||
expect((await ownerReads(journey.id, owner.id)).body.link.view_count).toBe(0);
|
||||
const view = (reader: string) =>
|
||||
request(server).post(`/api/public/journey/${token}/view`).set('User-Agent', reader);
|
||||
expect((await view('Reader A')).status).toBe(200);
|
||||
expect((await view('Reader A')).status).toBe(200);
|
||||
expect((await view('Reader B')).status).toBe(200);
|
||||
|
||||
const read = await ownerReads(journey.id, owner.id);
|
||||
expect(read.body.link.view_count).toBe(2);
|
||||
@@ -212,7 +221,9 @@ describe('the view count of a journey link', () => {
|
||||
|
||||
it('JPUBLINK-E2E-021: a locked link counts nobody who has not unlocked it', async () => {
|
||||
const { token } = await sharedJourney({ password: 'secret1' });
|
||||
await request(server).get(`/api/public/journey/${token}`).set('User-Agent', 'Stranger');
|
||||
expect((await request(server).post(`/api/public/journey/${token}/view`).set('User-Agent', 'Stranger')).status).toBe(
|
||||
401,
|
||||
);
|
||||
expect((await findRow(orm, JourneyShareTokens, { token }))?.view_count).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -366,7 +366,9 @@ describe('Journey recordings e2e (real guards + temp SQLite)', () => {
|
||||
'12',
|
||||
);
|
||||
|
||||
const listed = await request(server).get(base()).set(as(VIEWER));
|
||||
const legacy = await request(server).get(base()).set(as(VIEWER));
|
||||
expect(legacy.body.days.map((day: { source: string }) => day.source)).toEqual(['dawarich']);
|
||||
const listed = await request(server).get(base()).query({ includeGpx: true }).set(as(VIEWER));
|
||||
expect(listed.body.days.map((d: { date: string; source: string }) => [d.date, d.source])).toEqual([
|
||||
[DAY, 'dawarich'],
|
||||
[DAY, 'gpx'],
|
||||
@@ -379,7 +381,7 @@ describe('Journey recordings e2e (real guards + temp SQLite)', () => {
|
||||
|
||||
const dropped = await request(server).delete(`${base()}/${DAY}?source=gpx`).set(as(EDITOR));
|
||||
expect(dropped.status).toBe(200);
|
||||
const left = await request(server).get(base()).set(as(OWNER));
|
||||
const left = await request(server).get(base()).query({ includeGpx: true }).set(as(OWNER));
|
||||
expect(left.body.days.map((d: { date: string; source: string }) => [d.date, d.source])).toEqual([
|
||||
[DAY, 'dawarich'],
|
||||
['2026-05-15', 'gpx'],
|
||||
|
||||
Reference in New Issue
Block a user