feat(hunt): track walking distance via GPS, show live locations on map
Docker Image CI / test (push) Failing after 41s
Docker Image CI / deploy (push) Skipped
Tests / unit (push) Failing after 36s
Tests / integration (push) Successful in 1m34s

Add foreground-only GPS distance tracking for hunts
This commit is contained in:
2026-09-27 20:55:58 +02:00
parent a0fc836c05
commit 61cc516f47
43 changed files with 2313 additions and 24 deletions
+48
View File
@@ -192,4 +192,52 @@ describe('submit answer (POST /api/quest/[questId]/submit)', () => {
);
expect(res.status).toBe(418);
});
it('persists lat/lon when submitted with the answer', async () => {
const { quest, team } = await seedPlayground('owner@test.dev');
const client = newClient();
await client.login('owner@test.dev', TEST_PASSWORD);
const res = await client.post(
`/api/quest/${quest.id}/submit`,
form({ answer: 'here', lat: '52.520008', lon: '13.404954' })
);
expect(res.status).toBe(200);
const answer = await prisma.questAnswer.findFirstOrThrow({
where: { teamId: team.id, questId: quest.id }
});
expect(Number(answer.lat)).toBeCloseTo(52.520008, 5);
expect(Number(answer.lon)).toBeCloseTo(13.404954, 5);
});
it('leaves lat/lon null when not submitted', async () => {
const { quest, team } = await seedPlayground('owner@test.dev');
const client = newClient();
await client.login('owner@test.dev', TEST_PASSWORD);
await client.post(
`/api/quest/${quest.id}/submit`,
form({ answer: 'no location' })
);
const answer = await prisma.questAnswer.findFirstOrThrow({
where: { teamId: team.id, questId: quest.id }
});
expect(answer.lat).toBeNull();
expect(answer.lon).toBeNull();
});
it('never creates a TrackPoint from a submission', async () => {
const { quest } = await seedPlayground('owner@test.dev');
const client = newClient();
await client.login('owner@test.dev', TEST_PASSWORD);
await client.post(
`/api/quest/${quest.id}/submit`,
form({ answer: 'here', lat: '52.520008', lon: '13.404954' })
);
expect(await prisma.trackPoint.count()).toBe(0);
});
});