Skip to content

Fix #32: Architecture: Deepen the result handoff: one module at the route seam - #33

Merged
Kingson4Wu merged 3 commits into
mainfrom
ralphworks/issue-32
Sep 22, 2026
Merged

Kingson4Wu merged 3 commits into
mainfrom
ralphworks/issue-32

Conversation

@Kingson4Wu

Copy link
Copy Markdown
Contributor

Closes #32

Generated by RalphWorks. Execution and artifacts. Review the patch and required checks before merging.

@Kingson4Wu

Copy link
Copy Markdown
Contributor Author

Please revise this PR before merge: (1) clear() in useResultStore has no production caller, so remove it and its test; acceptance criterion 5 explicitly requires unused clearResult to be called or removed. Keep the public interface to submit and load. (2) Revert the unrelated Vitest upgrade and package-lock churn; retain the versions from main. Then rerun npm test -- --run && npm run build.

@Kingson4Wu Kingson4Wu added the ralphworks:implement RalphWorks scenario or status label label Sep 22, 2026

@Kingson4Wu Kingson4Wu left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review: Consolidate result storage into useResultStore

Scope: Replaces useHistory.js (localStorage only) and absorbs formatMbtiType.js into a single useResultStore.js that owns the sessionStorage handoff (mbti_result), the localStorage history (mbti_lab_result), type normalization, entry validation, and fresh-then-history precedence. Views are updated; formatMbtiType.test.js is replaced by useResultStore.test.js; one new ResultView regression test is added.

Verification performed

  • npx vitest run7 files / 78 tests passed
  • npm run build → succeeded (pre-existing >500 kB chunk warning only)
  • grep across src/ and tests/ → no dangling imports of useHistory or formatMbtiType; no raw reads of mbti_result / mbti_lab_result outside the new module
  • Backward compatibility: the saved result shape ({ type, percents } from useTest.js) has been stable since the initial commit (dd54182), and HISTORY_KEY keeps the old mbti_lab_result name, so existing users' persisted results pass the new validation and still load.
  • Refresh behavior on /result is preserved: submit() writes both storages, and after load() consumes the session entry, refresh falls back to an identical history entry.

Findings

Overall this is a clean, well-tested refactor that fixes the reported crash (invalid session entry reaching ResultCard). Findings below are minor / non-blocking.

  1. Dead code: clear() is never calledsrc/composables/useResultStore.js:89-92
    No view or test-other-than-its-own invokes clear(). The old clearResult was equally unused, so this is pre-existing API surface carried forward. Either wire it to a "clear history" affordance or drop it.

  2. submit() performs no validation, load() validates strictlysrc/composables/useResultStore.js:73-76 vs :36-67
    If a caller ever submits a malformed result, it is persisted to history and then silently rejected on every subsequent load() — the "last result" feature stays broken until a valid test overwrites it. Current callers (useTestTestView.vue:52) always produce valid shapes, so this is not a live bug, but validating in submit (or returning the parsed entry from it) would fail fast instead.

  3. Minor test-coverage regression: whitespace trimming — deleted tests/formatMbtiType.test.js (cases ' enfp ', '\tistj\n') vs tests/useResultStore.test.js:154-158
    normalizeType still trims, but only the lowercase case ('infp') is re-covered; the trim cases were dropped and normalizeType is not exported, so they can only be exercised through load(). A one-line putSession({ type: ' enfp ', ... }) case would restore parity.

  4. Note (intentional, no change requested): HomeView now consumes the fresh handoffsrc/views/HomeView.vue:62
    load() is read-and-consume, so a Home visit eats any not-yet-consumed session entry. In current flows both storages hold identical entries after submit, so this is benign and is exactly the mechanism that prevents a stale session entry from shadowing newer history (documented in the module header and covered by the "tab 2" test at tests/useResultStore.test.js:100-118). Flagging only so reviewers are aware of the semantic change to HomeView.

Conclusion

Approve. The core fix is correct and regression-tested (tests/ResultView.test.js:100-110 proves a corrupted session entry renders the empty state instead of crashing ResultCard), storage keys are backward compatible, and all 78 tests plus the production build pass. Findings 1-3 are optional polish.

RalphWorks review run: https://github.com/OctopusGarage/mbti-lab/actions/runs/35680692179

@Kingson4Wu
Kingson4Wu marked this pull request as ready for review September 22, 2026 02:49
@Kingson4Wu Kingson4Wu removed the ralphworks:review RalphWorks scenario or status label label Sep 22, 2026
@Kingson4Wu Kingson4Wu removed the ralphworks:implement RalphWorks scenario or status label label Sep 22, 2026
@Kingson4Wu

Copy link
Copy Markdown
Contributor Author

RalphWorks addressed PR feedback in f9ba9f0. Run: https://github.com/OctopusGarage/mbti-lab/actions/runs/35680753178

@Kingson4Wu
Kingson4Wu merged commit ef7a07b into main Sep 22, 2026
4 checks passed
@Kingson4Wu
Kingson4Wu deleted the ralphworks/issue-32 branch September 22, 2026 02:53
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.

Architecture: Deepen the result handoff: one module at the route seam

1 participant