test(coverage): lock noema src coverage at 100% - #48
Conversation
|
Warning Review limit reached
Next review available in: 42 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthrough분산 rate limiter와 OIDC replay guard의 잘못된 입력 및 예외 처리 테스트를 추가했습니다. Worker의 Changes방어적 인증 및 제한 검증
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
test/distributed-rate-limit.test.ts (1)
494-521: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value단일 테스트에서 4개의 독립된 검증 케이스를 검증합니다.
이 테스트는
nonObject,nonInteger,malformed,noBody4개의 서로 다른 요청을 만들고, 마지막에expect문 4개를 순서대로 실행합니다.toBe는 실패 시 즉시 예외를 던지므로, 첫 번째 assert(nonObject.status)가 실패하면 나머지 3개 assert는 실행되지 않습니다. 이 경우 회귀 발생 시 실패 원인을 파악하기 어렵습니다.각 검증 케이스를 별도의
it블록으로 분리하면, 어떤 입력 검증이 실패했는지 테스트 실행 결과에서 바로 확인할 수 있습니다.♻️ 제안: 검증 케이스별로 테스트 분리
- it("rejects non-object, non-integer, and content-type-less limiter payloads", async () => { - const limiter = new NoemaRateLimiter(fakeDurableObjectState().state); - - const nonObject = await limiter.fetch(new Request("https://noema-rate-limit.internal/check", { - method: "POST", - headers: { "content-type": "application/json" }, - body: JSON.stringify(123), - })); - const nonInteger = await limiter.fetch(new Request("https://noema-rate-limit.internal/check", { - method: "POST", - headers: { "content-type": "application/json" }, - body: JSON.stringify({ limit: 2.5 }), - })); - const malformed = await limiter.fetch(new Request("https://noema-rate-limit.internal/check", { - method: "POST", - headers: { "content-type": "application/json" }, - body: "not-json", - })); - const noBody = await limiter.fetch(new Request("https://noema-rate-limit.internal/check", { - method: "POST", - })); - - expect(nonObject.status).toBe(400); - expect(nonInteger.status).toBe(400); - expect(malformed.status).toBe(400); - expect(noBody.status).toBe(415); - }); + it("rejects a non-object limiter payload", async () => { + const limiter = new NoemaRateLimiter(fakeDurableObjectState().state); + const response = await limiter.fetch(new Request("https://noema-rate-limit.internal/check", { + method: "POST", + headers: { "content-type": "application/json" }, + body: JSON.stringify(123), + })); + expect(response.status).toBe(400); + }); + + it("rejects a non-integer limit", async () => { + const limiter = new NoemaRateLimiter(fakeDurableObjectState().state); + const response = await limiter.fetch(new Request("https://noema-rate-limit.internal/check", { + method: "POST", + headers: { "content-type": "application/json" }, + body: JSON.stringify({ limit: 2.5 }), + })); + expect(response.status).toBe(400); + }); + + it("rejects malformed JSON", async () => { + const limiter = new NoemaRateLimiter(fakeDurableObjectState().state); + const response = await limiter.fetch(new Request("https://noema-rate-limit.internal/check", { + method: "POST", + headers: { "content-type": "application/json" }, + body: "not-json", + })); + expect(response.status).toBe(400); + }); + + it("rejects a request without content-type", async () => { + const limiter = new NoemaRateLimiter(fakeDurableObjectState().state); + const response = await limiter.fetch(new Request("https://noema-rate-limit.internal/check", { + method: "POST", + })); + expect(response.status).toBe(415); + });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/distributed-rate-limit.test.ts` around lines 494 - 521, Split the combined test around NoemaRateLimiter into four independent it blocks, one each for the nonObject, nonInteger, malformed, and noBody request cases. Keep each request setup and its corresponding status assertion together, preserving the expected 400 responses for the first three cases and 415 for the content-type-less case.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@test/distributed-rate-limit.test.ts`:
- Around line 494-521: Split the combined test around NoemaRateLimiter into four
independent it blocks, one each for the nonObject, nonInteger, malformed, and
noBody request cases. Keep each request setup and its corresponding status
assertion together, preserving the expected 400 responses for the first three
cases and 415 for the content-type-less case.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a5621028-c44f-4425-918f-f47019718f34
📒 Files selected for processing (6)
test/distributed-rate-limit.test.tstest/oidc-replay.test.tstest/worker-defensive-rate-limit.test.tstest/worker-defensive-replay.test.tstest/worker-exchange-replay.test.tsvitest.config.ts
Rebase the coverage gate and fail-closed regression suite onto the current main branch, preserving the GitHub API egress trust boundary and its tests.
8a5c082 to
9678ff3
Compare
Summary
Bring the entire configured coverage scope (
src/**/*.ts) to 100% and lock it in with a Vitest threshold gate. The implementation is additive: new and expanded tests, coverage thresholds, and a changelog entry. Runtime behavior undersrc/is unchanged.Coverage: before → after
What changed
vitest.config.ts: enforce 100% statements, branches, functions, and lines over the existingsrc/**/*.tsscope.test/worker-exchange-replay.test.ts: exercise exact workflow-ref trust, trusted trace IDs, malformed token payloads, and single-use replay outcomes.test/worker-defensive-rate-limit.test.tsandtest/worker-defensive-replay.test.ts: verify unexpected dependency failures remain fail-closed.test/oidc-replay.test.tsandtest/distributed-rate-limit.test.ts: cover malformed decisions, transport errors, claim mismatches, and internal Durable Object request validation.CHANGELOG.md: record the enforced source-coverage contract.The branch has been synchronized with current
main, including the patchedundici@7.29.0lockfile and Node.js>=22runtime contract.Verification
npx vitest run --coveragenpm run typechecknpm testnpm run security:scan