Repository navigation
#75 follow-up: E2E route-handler coverage for quote lifecycle, shared technician reconciliation, docs refresh - #77
Conversation
…ipped The doc described a proposal (a /demo/tech route reusing /tech/page.tsx JSX via a shared TechJobView extraction, company.slug === 'demo' detection, an admin-role demo login) that was never built. What actually shipped across PRs #72/#74/#76 took a different shape: a floating TechPhoneModal widget on /dispatch running under the viewer's own dispatcher session (not a separate tech route or auth), a three-predicate demo-detection scheme (isDemoCompany/isSandboxDemoCompany/ isPrivateSandboxDemoCompany) answering three different questions, a dispatcher-role (not admin) private preview login, per-route is_demo visibility scoping, and a centralized SMS-suppression choke point instead of per-route filters. Rewrote the doc to describe the current architecture as-built, so it's useful as a reference instead of a misleading roadmap. Flagged in the new doc's "Open follow-ups" section rather than treated as done: a dedicated E2E quote-lifecycle regression suite (added separately, this same session) and whether TechPhoneModal should eventually get a real shared-component/impersonation connection to the production technician UI instead of its current parallel implementation. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015m3No73eyqpRxGLXWbccVw
…lease bug Added src/lib/__tests__/demoTenantQuoteLifecycle.test.ts: drives the real route handlers in sequence (POST /api/quotes -> line-items -> send-sms -> accept/decline) against one shared in-memory fake, the way a prospect's actual click-through exercises them -- the explicit Phase 1/4 ask in issue #75 ("Add end-to-end behavior coverage for the complete sandbox quote path"). Per-route is_demo visibility unit coverage already exists elsewhere; this file's job is proving the sequence works end to end and that technician state comes out correct at the finish line. Building it surfaced a real bug: POST /api/quotes/[id]/accept completes jobs and releases technicians on its own, independently of PATCH /api/jobs/[id] -- and had the exact same unconditional-release gap PR #76 just fixed there (releasing a technician even when they hold another still-active job). Extracted the fix into a shared src/lib/technicianReconciliation.ts helper (reconcileTechnicianAfterTerminalJob) and now call it from both routes instead of duplicating the logic a second time. Added a regression test to accept/route.test.ts mirroring the one already in jobs/[id]/route.test.ts. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015m3No73eyqpRxGLXWbccVw
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Last uncovered item on #75's Phase 4 checklist. Confirms running resetDemoTenant() twice in a row against the same sandbox company lands on the same baseline both times: equal jobsSeeded counts, no leftover rows from the first run surviving the second wipe, and the quote template still present exactly once. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015m3No73eyqpRxGLXWbccVw
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a23a352073
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…ew-coverage claim - reconcileTechnicianAfterTerminalJob's "next active job" query now excludes hidden load-test rows for ordinary companies (is_demo scoping, matching every other per-route fix from issue #75) and treats the legacy capitalized 'Completed' status as terminal, since the DB check constraint still permits it. - Add a companies table to accept/route.test.ts's fake Supabase (needed now that reconciliation looks up sandbox status) and is_demo: false on its multi-assignment fixture, mirroring the same fix already made in jobs/[id]/route.test.ts. - Correct demoTenantQuoteLifecycle.test.ts's docstring: it doesn't render /quote/[id] or /intake/quote/[token], and this repo has no page-component test harness to do so. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015m3No73eyqpRxGLXWbccVw
…uite exists The E2E sandbox quote lifecycle regression suite (issue #75 Phase 1) shipped in PR #77 -- remove it from the open-follow-ups list and note explicitly what's still genuinely uncovered (page-render tests, which need test infrastructure this repo doesn't have) versus what's a deliberate, undecided architecture question (TechPhoneModal's shared-component question). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015m3No73eyqpRxGLXWbccVw
diese-tech
left a comment
There was a problem hiding this comment.
Half-Shell review
Leonardo verdict: NOT READY yet. One contract/coverage blocker remains.
April O'Neil — what the story says
The PR says the new lifecycle suite fulfills #75's explicit Phase 1/4 request: create → line items → preview → send/simulate send → accept/decline → resulting job/technician state.
But the current test now explicitly documents that it does not render /quote/[id] or /intake/quote/[token]. The refreshed architecture doc also moves those pages into "Open follow-ups." That makes the PR description and the audit's completion claim materially stronger than what the code actually proves.
Donatello — architecture
The reconciliation extraction is a good move. PATCH /api/jobs/[id] and quote acceptance now share one terminal technician invariant instead of maintaining parallel logic.
I checked Codex's two reconciliation findings against the current head:
- hidden
is_demo=trueload-test jobs are now excluded for ordinary tenants while sandbox jobs remain eligible; - legacy
Completedis included in the terminal filter.
Those findings are resolved on the current branch.
Raphael — correctness
The shared helper preserves the important safeguards from #76:
- reconciliation happens after the terminal job write succeeds;
current_job_id = completedJobIdprotects against clobbering a pointer that moved concurrently;- another visible active assignment is promoted deterministically instead of falsely marking the tech available.
No new correctness blocker found in that refactor.
Michelangelo — UX/test reality
Codex's preview finding is still valid.
The new test proves the route-handler sequence, not the full prospect-facing quote flow. A regression where the dispatcher preview 404s, line items fail to render, or the customer token page breaks can still leave this suite green.
I agree that introducing a full RTL/jsdom component harness solely inside this PR may be disproportionate. But that does not make the original acceptance item complete.
Casey Jones — ugly path
This is exactly the kind of gap the demo audit was created to catch: backend state can be perfect while the prospect clicks a visible page and gets a broken experience. Calling the lifecycle gate complete without exercising those pages would hide that risk from the tracking issue.
Splinter — scope discipline
Two acceptable paths:
- Cover the preview/customer page path here using an appropriate browser/page-level regression mechanism, then this PR can legitimately satisfy that #75 item; or
- Keep this PR scoped to handler-chain coverage, but update the PR description and #75 tracking so preview/token-page coverage remains an explicit unfinished acceptance item rather than being implicitly declared done.
Do not build a large testing framework just to satisfy wording. Do keep the contract honest.
Shredder — adversarial challenge
Break /quote/[id] while leaving every API handler untouched. This new lifecycle suite still passes. Break /intake/quote/[token] so the generated customer link cannot render. It still passes.
That proves the claimed "complete sandbox quote path" regression gate is not complete yet.
Leonardo — final
Blocking finding: reconcile the PR's claimed #75 completion with the actual coverage. Codex's two code-level reconciliation findings are fixed; its preview-coverage finding remains valid.
Exact-head CI is green on 586c2fb6895ec76d88a71f49ac167ab9a4bd8365.
Once the preview/token-page gap is either covered here or explicitly left open in #75 with this PR's scope renamed accordingly, I don't have another blocker on the current code.
|
Taking Splinter's option 2: kept this PR scoped to handler-chain coverage, and corrected the contract instead of building a render harness to satisfy wording.
So the gap is now named in three places — PR description, tracking issue, and the test itself — rather than implied-complete in any of them. Not attempting a browser/render harness in this PR, per Splinter's steer that building one just to satisfy wording would be disproportionate. Codex's two reconciliation findings (is_demo scoping, legacy Generated by Claude Code |
diese-tech
left a comment
There was a problem hiding this comment.
Half-Shell re-review
Leonardo verdict: READY from review perspective.
April O'Neil — contract check
The audit-bookkeeping blocker from my prior review is resolved. The PR now accurately calls this route-handler lifecycle coverage, explicitly states that /quote/[id] and /intake/quote/[token] are not rendered by this suite, and #75 keeps page/component render coverage open in Phase 4 instead of implicitly treating it as complete.
Donatello — architecture
The shared reconcileTechnicianAfterTerminalJob() extraction is the right consolidation. Both PATCH /api/jobs/[id] and quote acceptance now use the same terminal-job reconciliation logic instead of carrying subtly different copies.
Codex's two correctness findings against that helper are addressed on the current head:
- ordinary tenants exclude hidden
is_demo=trueload-test jobs from replacement candidates while sandbox tenants include their synthetic rows - the legacy capitalized
Completedvalue is excluded as terminal alongside the normalized lowercase statuses
Raphael — correctness edge
I re-checked the repaired candidate selection. The helper remains company-scoped, excludes the completed job itself, promotes the oldest remaining active assignment deterministically, and only updates the technician when current_job_id still points at the completed job. No remaining blocker found in the refactor.
Michelangelo — test reality
The lifecycle test now says what it actually proves: route sequence and resulting state, not DOM/page rendering. That's a useful regression layer without pretending it's browser E2E. The missing preview/token-page render check remains visibly tracked rather than buried.
Casey Jones — ops path
Sandbox SMS behavior is also an actual centralized policy now: quote send can enqueue normally, while the outbox worker suppresses Twilio for sandbox companies. That is much safer than route-by-route demo exceptions.
Splinter — scope discipline
Good correction. We do not need to stand up RTL/jsdom or a browser harness inside this PR just to satisfy wording. The remaining render-level gaps are explicitly preserved as future work under #75.
Shredder — adversarial pass
The prior ambiguity is gone. A future maintainer can no longer read this PR and assume page rendering is regression-covered when it is not. The remaining gaps are named in both the PR and the audit issue.
Leonardo — final
READY from review perspective.
Exact-head CI is green on 586c2fb6895ec76d88a71f49ac167ab9a4bd8365. No blocking findings remain from this review.
Summary
Continuing the Half-Shell Demo Tenant Audit (#75) after PR #76 merged. Two remaining items from the audit's plan, plus a bug found while building the first one:
src/lib/__tests__/demoTenantQuoteLifecycle.test.ts— coverage toward Half-Shell Audit: private demo tenant regressions and product-fidelity gaps #75's Phase 1/4 ask. Drives the real route handlers in sequence (POST /api/quotes→ line-items → send-sms → accept/decline) against one shared in-memory fake, proving the sequence and the resulting job/technician state come out correct end to end.Scope correction (per Half-Shell review on this PR): this suite exercises the route-handler chain only. It does not render
/quote/[id](the dispatcher preview) or/intake/quote/[token](the customer page) — this repo has no page/component render harness (no RTL/jsdom setup anywhere) to do that with. A regression that breaks either page while the underlying data is correct would not be caught by this suite. That gap is called out explicitly in the test's own docstring and left as an open, unfinished item in Half-Shell Audit: private demo tenant regressions and product-fidelity gaps #75's Phase 4 checklist — not implicitly declared complete. Closing it for real would mean standing up a browser/page-level render harness, which is out of scope for this PR (Splinter's option 2: keep this PR's coverage honestly scoped rather than build a testing framework to satisfy wording).POST /api/quotes/[id]/acceptcompletes jobs and releases technicians independently ofPATCH /api/jobs/[id]— and had the exact same unconditional-release gap PR #75 Phase 2/3: analytics scoping, terminal technician release, reset/tech-phone fidelity #76 just fixed there (a technician holding a second active job gets falsely reported available). Extracted the fix into a sharedsrc/lib/technicianReconciliation.tshelper (reconcileTechnicianAfterTerminalJob) and call it from both routes instead of duplicating the logic a second time. Added matching regression coverage toaccept/route.test.ts.Also fixed, per Codex review on this PR: the helper's "next active job" candidate query is now
is_demo-scoped (hidden load-test rows can no longer get promoted into a real technician'scurrent_job_id), and its terminal-status filter now includes the legacy capitalized'Completed'spelling that the DB check constraint still permits.docs/demo-experience-design.md— it described a proposal (a/demo/techroute,company.slug === 'demo'detection, an admin-role demo login) that was never built; what shipped across Private preview demo tenant: safer resets, seed-demo removal, first-launch tutorial #72/Fix demo-tenant quote actions and stale technician availability #74/#75 Phase 2/3: analytics scoping, terminal technician release, reset/tech-phone fidelity #76 took a different shape entirely. Rewrote it to describe the current architecture as-built, with an "Open follow-ups" section naming both the preview/token-page render-coverage gap andTechPhoneModal's still-open shared-component architecture question.Test plan
npx tsc --noEmit— cleannpx vitest run— 372 passed / 8 skipped, no failures🤖 Generated with Claude Code
https://claude.ai/code/session_015m3No73eyqpRxGLXWbccVw
Generated by Claude Code