Skip to content

#75 follow-up: E2E route-handler coverage for quote lifecycle, shared technician reconciliation, docs refresh - #77

Merged
diese-tech merged 5 commits into
mainfrom
claude/awesome-cray-d9djpp
Sep 21, 2026
Merged

diese-tech merged 5 commits into
mainfrom
claude/awesome-cray-d9djpp

Conversation

@diese-tech

@diese-tech diese-tech commented Sep 21, 2026 •

Copy link
Copy Markdown
Owner

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:

  • Added 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).
  • Found and fixed a real bug while building it: POST /api/quotes/[id]/accept completes jobs and releases technicians independently of PATCH /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 shared src/lib/technicianReconciliation.ts helper (reconcileTechnicianAfterTerminalJob) and call it from both routes instead of duplicating the logic a second time. Added matching regression coverage to accept/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's current_job_id), and its terminal-status filter now includes the legacy capitalized 'Completed' spelling that the DB check constraint still permits.
  • Rewrote docs/demo-experience-design.md — it described a proposal (a /demo/tech route, 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 and TechPhoneModal's still-open shared-component architecture question.

Test plan

  • npx tsc --noEmit — clean
  • npx vitest run — 372 passed / 8 skipped, no failures

🤖 Generated with Claude Code

https://claude.ai/code/session_015m3No73eyqpRxGLXWbccVw


Generated by Claude Code

…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
@vercel

vercel Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
swift-dispatch Ready Ready Preview Sep 21, 2026 5:49am UTC

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread src/lib/technicianReconciliation.ts Resolved
Comment thread src/lib/technicianReconciliation.ts Resolved
…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 diese-tech left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

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=true load-test jobs are now excluded for ordinary tenants while sandbox jobs remain eligible;
  • legacy Completed is 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 = completedJobId protects 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:

  1. 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
  2. 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.

Copy link
Copy Markdown
Owner Author

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.

  • Updated the PR description to stop presenting the E2E suite as fulfilling the "preview" step, and to state plainly what it does and doesn't cover (route-handler sequence only; /quote/[id] and /intake/quote/[token] are not rendered, since this repo has no page-render test harness).
  • Half-Shell Audit: private demo tenant regressions and product-fidelity gaps #75's Phase 4 checklist already reflects this as an explicit open item, not a silently-dropped claim (updated earlier in this session, before this review landed).
  • The test file's own docstring already says the same thing (fixed for Codex's identical finding on the same line).

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 Completed handling) are fixed on 586c2fb, which you've confirmed. Let me know if the corrected description resolves this, or if you'd rather the scope/title also change to make the partial completion more visible in the PR list itself.


Generated by Claude Code

@diese-tech diese-tech changed the title #75 follow-up: E2E quote lifecycle coverage, shared technician reconciliation, docs refresh #75 follow-up: E2E route-handler coverage for quote lifecycle, shared technician reconciliation, docs refresh Sep 21, 2026

@diese-tech diese-tech left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

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=true load-test jobs from replacement candidates while sandbox tenants include their synthetic rows
  • the legacy capitalized Completed value 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.

@diese-tech
diese-tech merged commit 64d11d1 into main Sep 21, 2026
4 checks passed

This branch was successfully deployed

1 active deployment
Preview — 586c2fb6 Deployed Sep 21, 2026 by vercel[bot]
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.

2 participants