mirror of
https://github.com/luxfi/quest.git
synced 2026-10-30 15:20:25 +00:00
The repo was a "coming soon" page. This is the game. A quest is a VALUE, not a database row — name, prize and every stop encode into the share link, so making one and sending it needs no account, no server and no storage. The code rides in the URL FRAGMENT, never the query string: a fragment is not sent to the server and does not appear in a Referer header, so the places someone chose stay out of access logs and off any site they click through to. `?q=` would quietly publish every quest anyone shares. Arriving is the one rule worth getting right. A stop is found when the device reports a position inside its radius, and the browser's own accuracy estimate is ADDED to that radius — a phone between tall buildings reports ±50 m, and holding it to the bare radius tells someone standing at the right door they are not there. Wildly inaccurate readings are capped, so a device claiming ±50 km cannot unlock a city from the sofa. Google is confined to one module. With no NEXT_PUBLIC_GOOGLE_MAPS_KEY every stop falls back to a list with a Maps link and the hunt is still playable, and "no key configured" is kept distinct from "Google refused" — collapsing those is how a missing env var gets mistaken for an outage. Prizes are the maker's own words, settled between the two people. Nothing here holds money or hands anything out; an escrow would be a custody problem and saying otherwise in the UI would be a lie about what happens when someone wins. Proven, not asserted: 28 unit tests over the pure core (unicode place names, truncated and hand-edited links returning null instead of throwing, coordinate precision against a 45 m radius, corrupt localStorage) and 7 Playwright tests driving the real static export at phone size with FAKED GPS — walk to Clarion Alley and the point lands, stand three blocks away and it does not, refuse location and the screen says so rather than doing nothing silently. Also fixes a pre-existing break: Tailwind was configured with no stylesheet importing it, so every utility class in the app was inert. Co-authored-by: Hanzo Dev <[email protected]>
54 lines
2.3 KiB
TypeScript
54 lines
2.3 KiB
TypeScript
import { test } from '@playwright/test'
|
|
|
|
/**
|
|
* Screenshots of the real screens, at phone size, for review.
|
|
* Not assertions — quest.spec.ts does the proving. This exists so a human can
|
|
* LOOK at what renders instead of trusting a green run.
|
|
*/
|
|
|
|
const CLARION = { latitude: 37.76474, longitude: -122.42201 }
|
|
const BALMY = { latitude: 37.75218, longitude: -122.41213 }
|
|
|
|
test('screens', async ({ page, context }) => {
|
|
await page.goto('/index.html')
|
|
await page.screenshot({ path: 'e2e/shots/1-landing.png', fullPage: true })
|
|
|
|
await page.goto('/create.html')
|
|
await page.getByPlaceholder('Mission murals').fill('Mission murals')
|
|
await page.getByPlaceholder('San Francisco').fill('San Francisco')
|
|
await page
|
|
.getByPlaceholder(/Coffee at Ritual/)
|
|
.fill('Coffee at Ritual, on me. Text me a photo of the last one.')
|
|
|
|
const coords = page.getByLabel('Add a stop by coordinates')
|
|
for (const [pt, clue, answer] of [
|
|
[CLARION, 'Where the walls argue back', 'Clarion Alley'],
|
|
[BALMY, 'The oldest paint in the barrio', 'Balmy Alley'],
|
|
] as const) {
|
|
await coords.fill(`${pt.latitude}, ${pt.longitude}`)
|
|
await coords.press('Enter')
|
|
const row = page.locator('li', { hasText: /^Stop/ }).last()
|
|
await row.getByPlaceholder(/^Clue/).fill(clue)
|
|
await row.getByPlaceholder(/^Answer/).fill(answer)
|
|
}
|
|
await page.screenshot({ path: 'e2e/shots/2-create.png', fullPage: true })
|
|
|
|
const link = await page.getByLabel('Share link').inputValue()
|
|
const path = link.replace(/^https?:\/\/[^/]+/, '').replace('/play#', '/play.html#')
|
|
|
|
await context.grantPermissions(['geolocation'])
|
|
await context.setGeolocation({ latitude: 37.7689, longitude: -122.4265 })
|
|
await page.goto(path)
|
|
await page.getByRole('button', { name: "I'm here" }).click()
|
|
await page.getByText(/Not there yet/).waitFor()
|
|
await page.screenshot({ path: 'e2e/shots/3-playing.png', fullPage: true })
|
|
|
|
await context.setGeolocation(CLARION)
|
|
await page.getByRole('button', { name: "I'm here" }).click()
|
|
await page.getByText('1 of 2 found').waitFor()
|
|
await context.setGeolocation(BALMY)
|
|
await page.getByRole('button', { name: "I'm here" }).click()
|
|
await page.getByRole('heading', { name: 'Quest complete' }).waitFor()
|
|
await page.screenshot({ path: 'e2e/shots/4-complete.png', fullPage: true })
|
|
})
|