Repository navigation
test(first-run-tour): end the tour in the order finish() writes it - #19003
christian-byrne wants to merge 2 commits into
Conversation
`endTour` set `lastEnding` before clearing `activeTour`. `finish()` does the
opposite: `dispatch({ type: 'ended' })` returns the state machine to `IDLE`,
and only then is `lastEnding` assigned. Under the arranged order anything
watching the tour end reads the ending a flush early and still looks correct —
making the watcher `flush: 'sync'` leaves all 62 tests green. With the writes
in production order the same change fails exactly one test,
`congratulates a tour the user walked to the end`.
Five teardowns also cleared `activeTour` on its own, leaving `lastEnding` null
after a step had been shown. No production path reaches that: `ended` is only
dispatched from `finish()`, which always records an ending, and `resolvedEmpty`
— the one ending-less return to `IDLE` — can only fire while the tour is still
resolving. They now end through `endTour(COMPLETED)`. The ending-less end keeps
its cover in `congratulates nobody when the tour never appeared`, which models
it the way `begin()` produces it.
No test added, removed or weakened; 62 passed before and after.
🔬 E2E Coverage:
|
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #19003 +/- ##
==========================================
+ Coverage 84.04% 84.94% +0.90%
==========================================
Files 3158 2309 -849
Lines 154414 133073 -21341
Branches 41918 35968 -5950
==========================================
- Hits 129772 113040 -16732
+ Misses 23037 19715 -3322
+ Partials 1605 318 -1287
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
MaanilVerma
left a comment
There was a problem hiding this comment.
Re-ran both mutations from the description on this branch with main merged in. Adding { flush: 'sync' } to the teardown watcher passes all 69 tests with main's version of this file and fails exactly congratulates a tour the user walked to the end with yours. The null-ending bail goes from 5 failures to 1. (The description says 62; main has added tests since, and the claim still holds.)
| Check | Result |
|---|---|
| sync-flush watcher caught | pass (0 to 1) |
| null-ending bail | pass (5 to 1) |
| five teardowns were unreachable | pass, read against tourState.ts |
| lint and format | pass |
| helper JSDoc | nitpick, inline A below |
question: #19013 rewrites this same endTour helper and these five call sites, and its version still writes lastEnding before tourIsOver(). Whichever of the two lands second will conflict here. Could the second one keep this order, and maybe the five teardowns as endTour(COMPLETED)? Otherwise the sync-flush mutation goes back to green with no test noticing.
Approving. The JSDoc nitpick is optional.
| /** | ||
| * The engine ending the tour and recording how, in the order `finish()` writes | ||
| * them: `dispatch({ type: 'ended' })` returns the state machine to `IDLE` — so | ||
| * `activeTour` and `step` fall together — and only then is `lastEnding` | ||
| * assigned. Writing the ending first would leave anything watching the tour end | ||
| * free to read it a flush early and still look correct. | ||
| */ |
There was a problem hiding this comment.
A
nitpick (non-blocking): this JSDoc narrates finish()'s internals (dispatch({ type: 'ended' }), IDLE), and that will drift the next time the store changes. The one thing a reader needs is that the order is load-bearing. Could we cut it to something like /** Ends the tour the way \finish()` does: state first, then `lastEnding`. */`?
Removed unnecessary comments from endTour function.
3561e02
❌ ErrorsYour PR has failed checks. Please review the issues below and take necessary action before merging. 🚦 5 Pipeline jobs failed
Useful? React with 👍 / 👎 This comment will be updated automatically if new data arrives.🔗 Commit SHA: 3561e02 | Docs | View more details | Give us feedback! |
Test-only. No production file is touched;
git diffonsrc/outside the one test file is empty.What this fixes
useFirstRunTourController.test.ts'sendTourhelper wrotelastEndingbefore clearingactiveTour.finish()inonboardingTourStore.tsdoes the opposite:The controller's teardown watcher fires on
activeTour === 'firstRun'going false and readsengine.lastEndingin the callback. With the ending written first, the test cannot tell a watcher that reads it after the flush from one that reads it during. Measured, not argued: adding{ flush: 'sync' }to that watcher — which in production would readlastEndingone statement beforefinish()writes it — leaves all 62 tests green. With the writes in production order the same change fails exactly one test,congratulates a tour the user walked to the end, which is the test that would be wrong in production.And five teardowns that arranged a state production cannot reach
Five tests cleared
activeTouron its own, leavinglastEndingnull after a step had already been shown. There is no production path to that pair:endedis dispatched only fromfinish(), which always records an ending when a tour was active;resolvedEmptyis the one other transition toIDLE(tourState.ts:98) and it is refused unlessstate.phase === 'resolving', i.e. before any step exists.They now end through
endTour(COMPLETED). The genuinely ending-less end keeps its cover incongratulates nobody when the tour never appeared, which models it the waybegin()produces it — request, resolve nothing, return to idle insidestartTour.The effect on coverage is visible: making the watcher bail on a null ending (
if (!ending) return) failed 5 tests before, of which only that one arranged a reachable state; after, it fails exactly that 1. Forgetting the outcome instead (tourWasCompleted = ending !== null) still fails the same 4congratulates nobody for a tour …cases, before and after — the value of the read was already covered, only its timing was not.Checks
npx vitest run --testTimeout=30000 src/renderer/extensions/firstRunTour/tour/useFirstRunTourController.test.tsnpx vitest run --testTimeout=30000 src/renderer/extensions/firstRunTour/ src/extensions/core/agentPanel.test.ts src/components/graph/GraphCanvas.test.ts src/views/GraphView.test.tsNODE_OPTIONS=--max-old-space-size=8192 npx vue-tsc --noEmitoxfmt --check/eslint/oxlint --type-awareno-unnecessary-type-conversionis reported, so the clean result is a real one)typecheck:app)--testTimeout=30000on every figure, so machine load under concurrent work cannot be mistaken for a test result.Base and merge order
Based on
main, deliberately.useFirstRunTourController.{ts,test.ts}are byte-identical atmainand at #18966's head, so this needs no position in the consent stack. #18986 is the only open PR that touches this test file, and all seven of its hunks are in thestartingdescribe (itsbeginTourreturn-type change); this touchesendTourand thenudge/run outcomedescribes, so the two do not overlap.No test was added, removed or weakened; no production behaviour changed.