feat: add unit tests for trusted flue functions#32186
Conversation
|
This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:
|
Review👉 Fix in your agent 👈Fix the following review findings in PR #32186 (https://github.com/cloudflare/cloudflare-docs/pull/32186).
Before making changes, review each finding and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g. the fix requires disproportionate effort for minimal benefit,
or the finding is factually incorrect), explain why
- If you need clarification before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
After triaging, follow this order:
1. Post a comment on this PR for any findings you are skipping, with the finding ID and your reasoning.
2. Then commit the fixes for the legitimate findings.
The comment must come before the commit — the bot reads PR comments when a new
push triggers a review, so skip comments posted after the push will be missed.
---
## Code Review
### Warnings (1)
#### CR-49f39dc6347c · Weak test assertion
- **File:** `.flue/lib/inproc-utils.test.ts` line 45
- **Issue:** `expect(maxActive).toBeLessThanOrEqual(3)` would pass if `withConcurrency` accidentally ran tasks serially (active=1), so it does not validate that a limit of 3 actually produces 3 concurrent tasks.
- **Fix:** Change the assertion to `expect(maxActive).toBe(3)`, which is the expected value when 10 tasks are run with a concurrency limit of 3.
### Suggestions (1)
#### CR-44b60e3cc039 · Duplicate patch version of vitest
- **File:** `.flue/package.json` line 27
- **Issue:** The repository root already pins vitest to 4.1.9 in devDependencies; .flue now pins 4.1.10, which will install a second vitest patch in the lockfile.
- **Fix:** Use the same vitest version as the root workspace (4.1.9) unless 4.1.10 is strictly required, to avoid duplicate installs and inconsistent runner behavior.
Code ReviewThis code review is in beta and may not always be helpful — use your judgment. Warnings (1)
Suggestions (1)
ConventionsNo convention issues found. Style Guide ReviewNo style-guide issues found. Acknowledged by author (1)
CommandsOnly codeowners can run commands. Post a comment with the command to trigger it.
|
|
Nimbus Preview URL: https://nimbus-8e1b262f.preview.developers.cloudflare.com |
|
Preview URL: https://8e1b262f.preview.developers.cloudflare.com |
|
CR-d079110f46a3 / CR-086f81e0ea3f — both findings assume the root CR-a09afc0a3e69 — the concern is valid in isolation but doesn't apply here. Every module that calls CR-d0259a0a9f76 — the CR-bdd20c2650d1 — no duplicate. Lines 8 and 9 of |
|
/review |
|
/rebase |
8e1b262 to
83aa554
Compare
|
/full-review |
Summary
Adds 127 Vitest unit tests covering the deterministic, pure TypeScript functions in
.flue/— the layer that doesn't require AI, GitHub API calls, R2, or Cloudflare Workers bindings to verify.What's tested:
lib/code-review-inproc.test.tsparseAddedLines(diff parsing, hunk math, file headers, edge cases),selectCodeReviewFiles(exclusions, sorting, capping),mergeCodeReviewResults(dedup by ID, summary counts)lib/code-review-render.test.tsrenderPendingComment,renderFailureComment,renderComment(all severity combinations, fix-in-agent block, acknowledged findings, degraded sections),renderReviewLimitComment,renderRebaseStatusUpdate(all status values, existing body injection, timestamp refresh)lib/code-review-state.test.tsextractReviewedHeadSha,extractReviewedAt,partitionComments(bot detection, last-wins, timestamp partitioning, bot-type exclusion)lib/code-review-results.test.tsassignCodeReviewFindingIdsandassignFindingIds(CR-/SG- prefix, stable IDs, line-number independence, evidence trimming)lib/inproc-utils.test.tswithConcurrency(ordering, concurrency limit, NaN/zero clamping, serial execution)lib/github-webhook.test.tsgetIssueOrPullRequestNumber/Url/Label/Title,truncateLogValueAlso adds
vitestas a devDependency, avitest.config.ts(withassetsInclude: ['**/*.md']to handle SKILL.md imports), and wirespnpm run testinto the Pre Build job influe-ci.yml.