← Back to Pull requests

test(server,app): execute src/server's entry point and bundle, pin #614's cron arms, and gate src/adapters/app/** + src/server/** at 100% (main.ts, node.ts:24/67/82, webhook.ts:65, cron.ts:85, vitest.config.mjs) #611

Closed
unknown closed this pull request without merging on Oct 29, 2026 21:23 UTC
View on GitHub
unknown unknown commented on Oct 29, 2026 04:28 UTC
Author

Test Improvement

Seven test files and one test-config change; nothing under src/, dist/ or docs touched.

From the original PR (main@282b8e0):

  • __tests__/server/main.test.ts — loading src/server/main.ts calls main() once with no arguments.

  • __tests__/server/node.test.ts — with buildReceiver's default background, a signed issue_comment is answered 202 while its dispatch is still pending (node.ts:24).

  • __tests__/adapters/app/webhookNonErrorThrow.test.ts — receiveWebhook answers 400 unusable delivery and logs the thrown value when appPlatform throws a non-Error (webhook.ts:65).

  • __tests__/server/bundle.test.ts — builds src/server/main.ts with ncc into a temp directory outside the repository, boots it, checks the require() list is builtins only, /healthz, a signed ping and an unsigned one.
  • Added after #614 landed (branch rebased onto main@1ce22f0), for the finding folded into #610:

  • __tests__/server/main.test.ts — also: node dist-server/index.js cron runs runCronOnce() once and sets process.exitCode to its result (main.ts:6-7).

  • __tests__/server/cronInterval.test.ts — a PROW_CRON_INTERVAL tick whose scheduled run rejects (real GET /app/installations → 500 through octokit) is logged as { level: 'error', event: 'schedule' } with no repo, /healthz keeps answering and the next tick still polls (node.ts:82); with PROW_CRON_INTERVAL unset, a day of fake time schedules nothing.

  • __tests__/server/cronIntervalNonErrorRejection.test.ts — the String(error) arm of the same catch, with runScheduledJobs mocked to reject with a plain object (octokit only ever throws Errors, same approach as webhookNonErrorThrow.test.ts).

  • __tests__/server/portDefault.test.ts — env.PORT ?? 8080 observed through a mocked @hono/node-server serve, so nothing binds :8080 on the runner (the arm the first revision left unpinned).

  • __tests__/adapters/app/cron.test.ts — one more case: a scheduled handler that throws a non-Error is reported as [object Object] and counted in report.failed (cron.ts:85).

  • vitest.config.mjs — per-path thresholds 'src/adapters/app/' and 'src/server/' at 100 % lines/branches/functions/statements, next to the global 99 floor.
  • Added after review (rebased onto main@9643326, after #615/#616/#618):

  • __tests__/adapters/app/platform.test.ts — one more case: appPlatform's default DeferStrategy (deferInPlace, platform.ts:26-29, added by #615 with zero unit hits) waits the whole delay under fake timers and then answers 'continue'. Without it the new src/adapters/app/ gate fails on main at 98.58 % lines.

  • vitest.config.mjs — the four pre-existing threshold keys quoted so style/quote-props agrees with the glob keys (the red build-test).

  • __tests__/server/cronInterval.test.ts — stdoutLines takes the structural mock shape instead of ReturnType<typeof vi.spyOn>, which tsc -p tsconfig.test.json (#599) rejects as an implicit any.

  • src/server/worker.ts / worker-env.d.ts stay out of unit coverage as #615 set them: the per-path threshold is evaluated over the files coverage.exclude leaves in, so 'src/server/' passes at 100 % with the Worker excluded (verified by the whole-suite run below).
  • Why. vitest.e2e-coverage.config.mjs:45-47 excludes src/adapters/app/ and src/server/ from the bundle run because "unit coverage holds them to 100%". Nothing enforced that premise — the global floor is 99 and the rest of src/ absorbs whole uncovered arms in the App adapter — and #614 was the first time it bit: cron.ts:85, both arms of node.ts:82 and main.ts:6-7 landed with zero hits. The thresholds make the exclusion's premise a check on every run; the tests are what lets the check pass today.

    Files / cluster claimed — src/server/, src/adapters/app/webhook.ts:65, src/adapters/app/cron.ts, and the thresholds block of vitest.config.mjs (#605 edits that file's setupFiles line, a separate hunk). Disjoint from every other held PR: #591/#593/#597 (plugins, dispatcher, labels), #595 (setup.ts, config), #596 (bundle scenario for sweep), #598 (testUtils.ts), #599 (tsconfig.test.json), #601 (coverageIgnoreHints.test.ts), #603 (runtime.test.ts), #609 (src/platform/index.ts), #612 (receiveWebhook refusal texts), #613 (decodeContent).

    Testing

    At 447b98c (rebased onto main@9643326):

  • npm run test:coverage (whole suite, with the per-path thresholds) — 222 files, 2646 passed; 100 / 99.77 / 100 / 100, exit 0, no threshold error; src/adapters/app and src/server absent from the uncovered table

  • npx vitest run --coverage --coverage.include='src/server/' --coverage.include='src/adapters/app/*' __tests__/server __tests__/adapters/app — 12 files, 66 passed, "8 files fully covered"

  • npm run typecheck — clean; npx eslint vitest.config.mjs __tests__/adapters/app/platform.test.ts __tests__/server/cronInterval.test.ts — clean

  • each new test fails without its arm: deferInPlace returning 'deferred', or await sleep(delayMs) → void delayMs, both fail the new platform.test.ts case; replacing the node.ts:82 sink call with void error fails both interval tests; ?? 8080 → ?? 3000 fails portDefault.test.ts; removing the cron branch from main.ts fails the new main.test.ts case; String(error) → "" in cron.ts:85 fails the new cron.test.ts case
  • Related Issue


    Closes #610 — every box of the original finding and of the one folded onto it (cron.ts:85, node.ts:67/82, main.ts cron arm, per-path thresholds) is in this PR.

    ---
    Filed by quality agent (hold-gated mode). Human review required.*

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: jeefy Review duration: 1014m
    All Vouch review confidence checks passed
    Residual risk 0.33 = Change Risk (0.75) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.75 · 650 lines diff across 8 files
    0.75
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.075
    Real PR Conversation Timeline
    1 comments
    "Review active on #611"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 75.2% (HIGH) · Higher = larger blast radius
    75.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 32.5% · Safe to merge
    32.5%