mirror of
https://github.com/Komediruzecki/token-circles.git
synced 2026-10-20 09:46:43 +02:00
* fix(nav): put Categories in the sidebar, and add a browser tour walker
The "What's New" tours navigate to each step's `requiredPage` (App.tsx), and the
Categories tour sends you to `#categories` — a real route in router.tsx that has no
entry in `navItems`. You land on a standalone page with no way back and no way in.
Two fixes and a guard:
- Add Categories to the sidebar, between Transactions and Accounts. It is a full
category manager (add/edit/delete, colors, icons, tax flags, per-category spend),
not a stray view. Bills' "Categories" is a count of subscription groups, so
pointing the tour there would have meant something else entirely.
- `.category-header` is `display: flex` with no `gap`, so the 40px icon sat flush
against the name — measured 0px between the icon's right edge and the name's left.
Now 12px. The rule is triplicated in the stylesheet; all three copies got it.
- Guard the class of bug rather than the instance: spotlightStore.test.ts now
asserts every route in router.tsx is reachable from the sidebar, and that no tour
navigates to a page the sidebar omits. Both fail on the pre-fix tree.
The static tests prove an anchor exists in the source; they cannot prove it is
rendered and visible when the tour reaches it. frontend/scripts/walk-tours.mjs
(`pnpm run test:tours`) walks every tour step in a real browser against the seeded
demo account and asserts each spotlight lands on a visible element, failing on either
the app's own "target missing" banner or a degenerate highlight rect. 51 steps across
15 tours pass on both desktop and mobile viewports. Documented as the tour-check
skill, mirroring the same workflow in mercurypitch.
* chore: track the tour-check skill in the repo
.claude/ was blanket-ignored, which is right for worktrees and local state but also
hid the agent skills. Ignore the contents and un-ignore .claude/skills/ so the
tour-check workflow ships with the repo instead of living on one machine.
* fix(categories): usable icon field, centred colour tick, and a prod-update skill
The icon field was capped at `maxlength="2"` while its own placeholder said
"e.g., food, home, car" — not one of its suggestions could be typed. Raised to 32 and
taught the resolver to accept a human word: exact icon key first, then the same keyword
matching already used on category names, so "food", "car" and "rent" each land on their
own glyph and anything unrecognised still falls back to the category name. Both the
Categories page and the add-category form on Budgets had the same limit; both fixed.
The field now shows the resolved icon beside it. That preview is a `createMemo`, not a
bare `<CategoryIcon>` — a Solid component body runs once, so passing the signal as a prop
rendered whatever the field held at mount and never updated while typing. Caught by
measuring the rendered path in a browser, not by reading the code.
`Object.hasOwn` guards the icon lookup. With a 2-character cap `constructor` was not
typeable; at 32 it is, and a bare index would have returned a function and rendered
`<path d={undefined}>`.
The colour swatches were 24px circles with no flex centring and default button padding,
so the check SVG sat on the text baseline. Now centred — measured 0x0 offset from centre
in both the card swatches and the modal.
Also adds the prod-update skill: the release procedure with the guided-tour walk as a
pre-tag gate, since tag pushes are not test-gated and tours break silently on layout
changes.
223 lines
8.4 KiB
JavaScript
223 lines
8.4 KiB
JavaScript
// ============================================================
|
|
// walk-tours — step through EVERY guided spotlight tour in a real browser
|
|
// and assert each step's spotlight lands on a visible element.
|
|
//
|
|
// The static guardrails in src/core/__tests__/spotlightStore.test.ts prove a step's
|
|
// `data-tour` anchor exists *in the source*. They cannot prove it is RENDERED and
|
|
// VISIBLE at the moment the tour reaches it — an anchor behind a tab, a collapsed
|
|
// section, an empty state, or a page that never mounts still passes them. Only a
|
|
// real browser walk catches that, which is what this script does.
|
|
//
|
|
// Usage:
|
|
// # 1. legacy backend with seeded demo data (the tours need real rows to point at)
|
|
// NODE_ENV=test node backend/index.js &
|
|
// curl -c /tmp/c.txt -X POST localhost:3847/api/auth/login -H 'Content-Type: application/json' \
|
|
// -H 'X-Skip-RateLimit: true' -d '{"username":"person","password":"something-like-this"}'
|
|
// curl -b /tmp/c.txt -X POST localhost:3847/api/profiles/reseed-demo -H 'X-Profile-ID: 1'
|
|
// # 2. dev server pointed at that backend
|
|
// cd frontend && API_PROXY_TARGET=http://127.0.0.1:3847 npm run dev -- --port 3800
|
|
// # 3. walk
|
|
// node scripts/walk-tours.mjs
|
|
//
|
|
// Env vars:
|
|
// BASE_URL app URL (default http://127.0.0.1:3800)
|
|
// MOBILE=1 390x844 touch viewport instead of 1280x800
|
|
// TOUR walk only the tour with this id (default: all)
|
|
// CHROMIUM chromium executable path (falls back to /opt/pw-browsers/chromium)
|
|
//
|
|
// Exits 0 when every step of every tour spotlights a visible element; exits 1 and
|
|
// prints MISS lines otherwise.
|
|
// ============================================================
|
|
import { readFileSync } from 'node:fs'
|
|
import { chromium } from '@playwright/test'
|
|
|
|
const BASE = process.env.BASE_URL || 'http://127.0.0.1:3800'
|
|
const MOBILE = process.env.MOBILE === '1'
|
|
const ONLY = process.env.TOUR || ''
|
|
|
|
// A spotlight rect smaller than this is a mis-anchored step (a collapsed or zero-size
|
|
// element), not a real highlight.
|
|
const MIN_HIGHLIGHT_PX = 14
|
|
|
|
// Tour ids + labels come straight from the store, so a newly added tour is walked
|
|
// without touching this script. The label is what the selection modal renders.
|
|
const storeSrc = readFileSync(new URL('../src/core/spotlightStore.ts', import.meta.url), 'utf8')
|
|
const TOURS = [...storeSrc.matchAll(/id:\s*'([a-z0-9-]+)',\s*\n\s*label:\s*'([^']+)',/g)].map(
|
|
(m) => ({ id: m[1], label: m[2] })
|
|
)
|
|
if (TOURS.length === 0) {
|
|
console.error('FATAL: parsed 0 tours out of spotlightStore.ts — has the shape changed?')
|
|
process.exit(1)
|
|
}
|
|
|
|
const launchOpts = {}
|
|
if (process.env.CHROMIUM) launchOpts.executablePath = process.env.CHROMIUM
|
|
let browser
|
|
try {
|
|
browser = await chromium.launch(launchOpts)
|
|
} catch {
|
|
browser = await chromium.launch({ executablePath: '/opt/pw-browsers/chromium' })
|
|
}
|
|
|
|
const ctx = await browser.newContext({
|
|
viewport: MOBILE ? { width: 390, height: 844 } : { width: 1280, height: 800 },
|
|
hasTouch: MOBILE,
|
|
})
|
|
|
|
// Authenticate the same way the e2e helpers do, so the walk runs against the seeded
|
|
// demo profile rather than an empty local DB — tours point at rows, not empty states.
|
|
const loginRes = await ctx.request.post(`${BASE}/api/auth/login`, {
|
|
data: { username: 'person', password: 'something-like-this' },
|
|
headers: { 'x-skip-ratelimit': 'true' },
|
|
})
|
|
if (!loginRes.ok()) {
|
|
console.error(
|
|
`FATAL: login returned ${loginRes.status()}. Is the backend up on 3847 and the dev ` +
|
|
`server proxying to it (API_PROXY_TARGET)?`
|
|
)
|
|
process.exit(1)
|
|
}
|
|
await ctx.addInitScript(() => {
|
|
localStorage.setItem('currentProfileId', '1')
|
|
localStorage.setItem('darkMode', 'false')
|
|
localStorage.setItem('finance_storage_mode', 'self-hosted')
|
|
// Start every tour from a clean slate so "Done" badges never change the modal layout.
|
|
localStorage.removeItem('finance_spotlight_tours')
|
|
})
|
|
|
|
const page = await ctx.newPage()
|
|
page.on('pageerror', (e) => console.log(' [pageerror]', String(e).slice(0, 140)))
|
|
|
|
await page.goto(BASE, { waitUntil: 'domcontentloaded', timeout: 30000 })
|
|
await page.waitForSelector('[data-test-id="whats-new-btn"]', { timeout: 30000 })
|
|
await page.waitForLoadState('networkidle', { timeout: 15000 }).catch(() => {})
|
|
|
|
const tooltip = page.locator('[class*="tooltip"]')
|
|
|
|
async function openTourModal() {
|
|
// The "What's New" button collapses the sidebar on click, so it needs re-opening for
|
|
// every tour. On mobile the sidebar is a drawer: its nav stays in the DOM but sits
|
|
// off-screen, so Playwright reports the button as visible while the click lands outside
|
|
// the viewport and times out. Open the drawer explicitly there rather than trusting
|
|
// visibility.
|
|
const btn = page.locator('[data-test-id="whats-new-btn"]')
|
|
const toggle = page.locator('[aria-label="Toggle sidebar"]').first()
|
|
const inViewport = async () => {
|
|
const box = await btn.boundingBox().catch(() => null)
|
|
if (!box) return false
|
|
const vp = page.viewportSize()
|
|
return box.x >= 0 && box.y >= 0 && box.x < vp.width && box.y < vp.height
|
|
}
|
|
if (!(await inViewport())) {
|
|
await toggle.click({ timeout: 5000 }).catch(() => {})
|
|
await page.waitForTimeout(400)
|
|
}
|
|
await btn.scrollIntoViewIfNeeded().catch(() => {})
|
|
await btn.click({ timeout: 8000 })
|
|
await page.waitForSelector('[class*="tourCard"]', { timeout: 8000 })
|
|
}
|
|
|
|
let totalSteps = 0
|
|
let missing = 0
|
|
const failures = []
|
|
|
|
async function walkTour({ id, label }) {
|
|
await openTourModal()
|
|
const card = page
|
|
.locator('[class*="tourCard"]')
|
|
.filter({ has: page.locator(`[class*="tourLabel"]:text-is("${label}")`) })
|
|
.first()
|
|
if (!(await card.isVisible().catch(() => false))) {
|
|
console.log(`\n### ${label} (${id}): NOT LISTED IN THE TOUR MODAL`)
|
|
missing++
|
|
failures.push(`${label}: tour not listed in the selection modal`)
|
|
return
|
|
}
|
|
await card.click()
|
|
|
|
try {
|
|
await tooltip.waitFor({ state: 'visible', timeout: 8000 })
|
|
} catch {
|
|
console.log(`\n### ${label} (${id}): TOUR DID NOT START`)
|
|
missing++
|
|
failures.push(`${label}: tour did not start`)
|
|
return
|
|
}
|
|
|
|
console.log(`\n### ${label} (${id})`)
|
|
const seen = new Set()
|
|
for (let i = 0; i < 40; i++) {
|
|
// Let the step settle: App.tsx navigates to requiredPage, the page chunk loads
|
|
// lazily, and Spotlight waits up to ~6s for its target via MutationObserver.
|
|
await page.waitForTimeout(1200)
|
|
if (!(await tooltip.isVisible().catch(() => false))) break
|
|
|
|
const title = (
|
|
(await page
|
|
.locator('[class*="tooltip"] h3')
|
|
.first()
|
|
.textContent()
|
|
.catch(() => '')) ?? ''
|
|
).trim()
|
|
const key = `${i}:${title}`
|
|
if (seen.has(key)) break
|
|
seen.add(key)
|
|
|
|
// Two independent signals: the app's own "target missing" banner, and the size of
|
|
// the SVG glow rect it draws around the resolved target.
|
|
const flagged = await page
|
|
.locator('[class*="targetMissing"]')
|
|
.isVisible()
|
|
.catch(() => false)
|
|
const box = await page
|
|
.locator('svg[class*="backdropSvg"] rect[stroke-width="2"]')
|
|
.first()
|
|
.boundingBox()
|
|
.catch(() => null)
|
|
const sized = !!box && box.width > MIN_HIGHLIGHT_PX && box.height > MIN_HIGHLIGHT_PX
|
|
const ok = !flagged && sized
|
|
|
|
totalSteps++
|
|
if (!ok) {
|
|
missing++
|
|
failures.push(
|
|
`${label} / step ${i + 1} "${title}": ${flagged ? 'app reports target missing' : 'no visible highlight'}`
|
|
)
|
|
}
|
|
console.log(
|
|
` ${ok ? 'ok ' : 'MISS'} step ${i + 1}: ${title} ` +
|
|
`${box ? `${Math.round(box.width)}x${Math.round(box.height)}` : 'no-highlight'}` +
|
|
`${flagged ? ' [target-missing banner]' : ''}`
|
|
)
|
|
|
|
const next = page.locator('[class*="tooltip"] [class*="btnPrimary"]').last()
|
|
if (!(await next.isVisible().catch(() => false))) break
|
|
await next.click().catch(() => {})
|
|
}
|
|
|
|
// Leave no tour running into the next one.
|
|
if (await tooltip.isVisible().catch(() => false)) {
|
|
await page
|
|
.locator('[class*="tooltip"] button', { hasText: 'End Tour' })
|
|
.first()
|
|
.click()
|
|
.catch(() => {})
|
|
await page.waitForTimeout(300)
|
|
}
|
|
await page.goto(BASE, { waitUntil: 'domcontentloaded' })
|
|
await page.waitForTimeout(500)
|
|
}
|
|
|
|
for (const t of TOURS) {
|
|
if (ONLY && t.id !== ONLY) continue
|
|
await walkTour(t)
|
|
}
|
|
|
|
console.log(`\nTOTAL steps: ${totalSteps}, steps without a visible spotlight: ${missing}`)
|
|
if (failures.length) {
|
|
console.log('\nFailures:')
|
|
for (const f of failures) console.log(` - ${f}`)
|
|
}
|
|
await browser.close()
|
|
process.exit(missing === 0 ? 0 : 1)
|