Skip to content

Reset calculate button on early validation and add UI tests#25

Merged
jordanhom merged 1 commit intomainfrom
codex/list-all-open-issues
Feb 6, 2026
Merged

Reset calculate button on early validation and add UI tests#25
jordanhom merged 1 commit intomainfrom
codex/list-all-open-issues

Conversation

@jordanhom
Copy link
Owner

Motivation

  • Prevent the calculate button from remaining stuck in the "Calculating..." state when input validation fails early in the UI flow.
  • Increase test coverage for UI behaviors around validation, error handling, and view switching to ensure the app reacts correctly to invalid inputs and missing data.

Description

  • Add a finalizeCalculation helper in js/ui.js that restores the calculate button text and state, and call it from early validation branches and the finally block to guarantee reset on all exit paths.
  • Ensure early validation branches for empty inputs and future/invalid birthdates call the new finalizer so the UI is left in a consistent state.
  • Expand tests/unit/ui.test.js with three new tests that assert rejection of future birthdates and that calculator functions are not called, simulate missing expectancy data to verify error handling, and validate that view switching updates aria-labelledby and calls the correct renderer.
  • Changes touch js/ui.js and tests/unit/ui.test.js to implement the fix and the additional tests.

Testing

  • Ran the full test suite with npm test -- --run and iterated until green; the final run reported all tests passing (47 passed).
  • The new and existing unit tests include tests/unit/ui.test.js (updated), tests/unit/calculator.test.js, and multiple gridRenderer unit tests which all executed successfully during the run.
  • Verified the failing UI behavior locally in tests and confirmed the calculate button state no longer remains "Calculating..." after early validation exits.

Codex Task

@jordanhom jordanhom merged commit 5a73220 into main Feb 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant