feat(hunt): track walking distance via GPS, show live locations on map
Add foreground-only GPS distance tracking for hunts
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user