fix: persistence, validation, e2e tests + CI workflow#5
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to the PR #3 revert. Full fix of localStorage persistence
plus test infrastructure so future PRs have automated browser coverage.
Fixes
both cityName + tz; saveState() clears storage when origin is incomplete
reload even though conversion was correct
no longer fires on page load, only on explicit user action
Tests
valid restore, clear-origin-then-reload
PR and push to dev-claude/main
Docs
Contributors