-
Notifications
You must be signed in to change notification settings - Fork 1k
fix(ci): restore quota-reset route coverage #3621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -481,14 +481,11 @@ describe("activation is the single switch", () => { | |||||||||||||||||||
| // The end-to-end proof: config -> activation -> the production quota writer -> HTTP body. | ||||||||||||||||||||
| // Every earlier test exercises one link; this is the only one that shows the chain holds. | ||||||||||||||||||||
| const bodies: string[] = []; | ||||||||||||||||||||
| const server = Bun.serve({ | ||||||||||||||||||||
| port: 0, | ||||||||||||||||||||
| hostname: "127.0.0.1", | ||||||||||||||||||||
| async fetch(req) { | ||||||||||||||||||||
| bodies.push(await req.text()); | ||||||||||||||||||||
| return new Response("ok"); | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| }); | ||||||||||||||||||||
| const realFetch = globalThis.fetch; | ||||||||||||||||||||
| globalThis.fetch = (async (_input: unknown, init?: RequestInit) => { | ||||||||||||||||||||
| bodies.push(String(init?.body ?? "")); | ||||||||||||||||||||
| return new Response("ok"); | ||||||||||||||||||||
|
Comment on lines
+485
to
+487
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Scope the fetch mock to the configured webhook. The stub ignores Proposed fix- globalThis.fetch = (async (_input: unknown, init?: RequestInit) => {
+ const expectedWebhookUrl = "https://hooks.example.test/quota-reset";
+ globalThis.fetch = (async (input: unknown, init?: RequestInit) => {
+ const requestUrl = input instanceof Request ? input.url : String(input);
+ expect(requestUrl).toBe(expectedWebhookUrl);
bodies.push(String(init?.body ?? ""));
return new Response("ok");
}) as typeof globalThis.fetch;📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||
| }) as typeof globalThis.fetch; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const home = mkdtempSync(join(tmpdir(), "ocx-live-")); | ||||||||||||||||||||
| writeFileSync(join(home, "config.json"), JSON.stringify({ | ||||||||||||||||||||
|
|
@@ -499,7 +496,7 @@ describe("activation is the single switch", () => { | |||||||||||||||||||
| }, | ||||||||||||||||||||
| quotaResetNotify: { | ||||||||||||||||||||
| enabled: true, | ||||||||||||||||||||
| webhookUrl: `http://127.0.0.1:${server.port}/hook`, | ||||||||||||||||||||
| webhookUrl: "https://hooks.example.test/quota-reset", | ||||||||||||||||||||
| allowPrivateNetwork: true, | ||||||||||||||||||||
| // Passive-only: this asserts the live request path fires without any timer involved. | ||||||||||||||||||||
| pollSeconds: 0, | ||||||||||||||||||||
|
|
@@ -543,7 +540,7 @@ describe("activation is the single switch", () => { | |||||||||||||||||||
| resetQuotaResetActivationForTests(); | ||||||||||||||||||||
| resetQuotaResetNotifyCacheForTests(); | ||||||||||||||||||||
| clearAccountQuota(); | ||||||||||||||||||||
| server.stop(true); | ||||||||||||||||||||
| globalThis.fetch = realFetch; | ||||||||||||||||||||
| if (previousHome === undefined) delete process.env["OPENCODEX_HOME"]; | ||||||||||||||||||||
| else process.env["OPENCODEX_HOME"] = previousHome; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 18531
🤖 get_repo_knowledge executed:
get_repo_knowledge lidge-jun/opencodex /tmp/coderabbit-repo-knowledge/lidge-jun-opencodex-7afea732/conventions /tmp/coderabbit-repo-knowledge/lidge-jun-opencodex-7afea732/learningsLength of output: 18912
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 24756
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 32935
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 17889
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 11071
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 9365
Add focused CLI contract tests for
provider resetsThe CLI sends
--limit NasGET /api/quota-resets?limit=N, which matches the handler’slimitparameter. The handler returns{ enabled, events }, andprintDataemits this payload directly for--json. Add tests intests/cli/cli-provider.test.tsfor the request URL and direct JSON payload.🤖 Prompt for AI Agents