Skip to content

fix: persistence, validation, e2e tests + CI workflow#5

Merged
stuforfun merged 11 commits intomainfrom
dev-claude
Mar 9, 2026
Merged

fix: persistence, validation, e2e tests + CI workflow#5
stuforfun merged 11 commits intomainfrom
dev-claude

Conversation

@stuforfun
Copy link
Owner

Follow-up to the PR #3 revert. Full fix of localStorage persistence
plus test infrastructure so future PRs have automated browser coverage.

Fixes

  • Guard restore against incomplete state — loadState() now requires
    both cityName + tz; saveState() clears storage when origin is incomplete
  • Populate origin-tz on restore — #origin-tz display was blank after
    reload even though conversion was correct
  • Gate validation error behind strict mode — "Please select a city"
    no longer fires on page load, only on explicit user action

Tests

  • Playwright smoke tests covering 4 flows: fresh load, malformed state,
    valid restore, clear-origin-then-reload
  • GitHub Actions CI workflow — runs browser tests automatically on every
    PR and push to dev-claude/main

Docs

  • AGENTS.md — agent review protocol (static vs browser-verified reviews)
  • README updated with accurate persistence and CDN details

Contributors

  • Claude (Anthropic) — persistence fix, validation gate, README
  • Codex (GPT-5.4) — AGENTS.md, Playwright setup, CI workflow, test harness fix
  • stuforfun — browser test, code review, integration

Claude and others added 11 commits March 8, 2026 07:59
Browser test revealed two related bugs in the persistence logic:

1. saveState() was persisting state even when no origin city had been
   selected from the dropdown. fromTz is initialised to the browser
   local timezone at startup, so a state with tz set but empty cityName
   could be saved. On restore, this caused validateOrigin() to fire and
   show the 'Please select a city' error with the timezone already
   populated - an inconsistent and broken-looking UI.

2. Restore was accepting any saved state, including partially valid ones
   with missing cityName or dest city names, causing empty destination
   cards to be rendered with no conversion output.

Fix:
- saveState() now guards on fromTz && cityName both being present
- Restore now requires s.cityName && s.tz to proceed; falls back to
  fresh start otherwise
- Dest cards are only restored for entries with both tz and cityName
Extracted logic from b9357ff without the reformat baggage of eb738e7.
validateOrigin() was calling showErr('err-city') unconditionally,
causing the red error to appear on page load before the user had
interacted. Now only fires in strict mode (explicit user action).
ok=false still set either way so conversion correctly blocks.
@stuforfun stuforfun merged commit b91cdea into main Mar 9, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant