Content
View differences
Updated by Alexander Coles 15 days ago
## Context
The `frontend/src/turbo/` layer glues Turbo Drive and Angular together but had has almost no unit coverage — the only spec was is `helpers.spec.ts` (progress bar). Every integration function (`addTurboEventListeners`, `addTurboGlobalListeners`, the `register*StreamAction` functions, the Angular wrapper) hard-bound hard-binds to the global `document` and returned returns `void`, giving vitest so there is no way seam to drive them or tear listeners down between cases. from a test. The only coverage of real navigation behaviour was is one expensive Selenium spec (`spec/features/notifications/turbo_angular_navigation_spec.rb`). The most upgrade-fragile code in the frontend therefore had has the least coverage.
The sharpest symptom was is `frontend/src/turbo/turbo-navigation-patch.ts`: a monkeypatch of Turbo internals (`FrameElement.delegateConstructor.prototype.proposeVisitIfNavigatedWithAction`) working around https://github.com/hotwired/turbo/issues/1300. It carried carries `@ts-nocheck` and `/* eslint-disable */`, so neither tsc nor eslint watched watches it, and it had has zero tests — yet it runs on every frame-with-action visit. The patched symbol still exists in Turbo 8.0.23, so the patch still binds and is may still be load-bearing; it could not cannot be safely deleted without a spec that reproduces the underlying symptom.
## Goal
Add unit Introduce a test coverage seam across `frontend/src/turbo/`, then use it to settle whether make the navigation monkeypatch a decidable delete rather than a guess.
## Tasks
- Adopt one convention: every installer takes its event target as a parameter (e.g. `addTurboEventListeners(target = document)`) and returns a teardown handle where it owns mutable state, so the directory becomes jsdom-drivable.
- Add vitest specs that construct a target, dispatch synthetic `turbo:*` events, and assert effects (dialog close on `turbo:submit-end`, custom stream actions, nonce scrubbing) — extending the fake-timer pattern already used in `helpers.spec.ts`.
- Write a behavioural spec reproducing the symptom `turbo-navigation-patch.ts` works around (https://github.com/hotwired/turbo/issues/1300).
- With that spec in place, test whether the patch is still needed. load-bearing on Turbo 8.0.23. If the spec stays green without it, delete `turbo-navigation-patch.ts`. If not, move it behind a named `applyFrameVisitPatch()` seam pinned to the Turbo version, with the spec as the regression guard and a comment recording the upstream issue state.
## Notes
Relates to #DREAM-514 — this jsdom test harness is the precondition for the bootstrapping/routing rework that ticket is on hold over. Landing it improves the integration's integration's testability without committing to the contentious redesign.
The `frontend/src/turbo/` layer glues Turbo Drive and Angular together but had
The sharpest symptom was
## Goal
Add unit
## Tasks
- Adopt one convention: every installer takes its event target as a parameter (e.g. `addTurboEventListeners(target = document)`) and returns a teardown handle where it owns mutable state, so the directory becomes jsdom-drivable.
- Add vitest specs that construct a target, dispatch synthetic `turbo:*` events, and assert effects (dialog close on `turbo:submit-end`, custom stream actions, nonce scrubbing) — extending the fake-timer pattern already used in `helpers.spec.ts`.
- Write a behavioural spec reproducing the symptom `turbo-navigation-patch.ts` works around (https://github.com/hotwired/turbo/issues/1300).
- With that spec in place, test whether the patch
## Notes
Relates to #DREAM-514 — this jsdom test harness is the precondition for the bootstrapping/routing rework that ticket is on hold over. Landing it improves the integration's