|
1 | 1 | import assert from "node:assert/strict" |
2 | 2 | import test from "node:test" |
3 | 3 |
|
4 | | -import { MAX_PULL_REQUEST_FILES, MAX_THREAD_COMMENTS, classifyTarget, inspectTarget } from "./opencode-target.mjs" |
| 4 | +import { MAX_PULL_REQUEST_FILES, MAX_THREAD_ITEMS, classifyTarget, inspectTarget } from "./opencode-target.mjs" |
5 | 5 |
|
6 | 6 | const repository = "owner/repo" |
7 | 7 | const pull = { |
@@ -92,26 +92,31 @@ test("plan permits fork pull requests", async () => { |
92 | 92 | assert.equal(result.head_repo, "fork/repo") |
93 | 93 | }) |
94 | 94 |
|
| 95 | +test("accepts a thread at the item limit", async () => { |
| 96 | + const comments = Array.from({ length: MAX_THREAD_ITEMS }, () => ({ body: "comment" })) |
| 97 | + await assert.doesNotReject(() => inspectTarget({ issue: { number: 8 } }, "plan", { ...options, fetchImpl: response({ issueComments: comments }) })) |
| 98 | +}) |
| 99 | + |
95 | 100 | test("rejects oversized thread context before model access", async () => { |
96 | | - const comments = Array.from({ length: MAX_THREAD_COMMENTS + 1 }, () => ({ body: "comment" })) |
| 101 | + const comments = Array.from({ length: MAX_THREAD_ITEMS + 1 }, () => ({ body: "comment" })) |
97 | 102 | await assert.rejects( |
98 | 103 | () => inspectTarget({ issue: { number: 8 } }, "plan", { ...options, fetchImpl: response({ issueComments: comments }) }), |
99 | | - /limits issue and pull request threads/, |
| 104 | + /limits issue and pull request threads to 50 items/, |
100 | 105 | ) |
101 | 106 | }) |
102 | 107 |
|
103 | 108 | test("counts PR reviews and nested review comments in the context limit", async () => { |
104 | | - const reviews = Array.from({ length: MAX_THREAD_COMMENTS + 1 }, (_, id) => ({ id, body: "review" })) |
| 109 | + const reviews = Array.from({ length: MAX_THREAD_ITEMS + 1 }, (_, id) => ({ id, body: "review" })) |
105 | 110 | await assert.rejects( |
106 | 111 | () => inspectTarget({ pull_request: { number: 9 } }, "plan", { ...options, fetchImpl: response({ reviews }) }), |
107 | | - /limits issue and pull request threads/, |
| 112 | + /limits issue and pull request threads to 50 items/, |
108 | 113 | ) |
109 | 114 | await assert.rejects( |
110 | 115 | () => inspectTarget({ pull_request: { number: 9 } }, "plan", { |
111 | 116 | ...options, |
112 | | - fetchImpl: response({ reviews: [{ id: 1, body: "review" }], reviewComments: Array.from({ length: MAX_THREAD_COMMENTS }, () => ({ body: "comment" })) }), |
| 117 | + fetchImpl: response({ reviews: [{ id: 1, body: "review" }], reviewComments: Array.from({ length: MAX_THREAD_ITEMS }, () => ({ body: "comment" })) }), |
113 | 118 | }), |
114 | | - /limits issue and pull request threads/, |
| 119 | + /limits issue and pull request threads to 50 items/, |
115 | 120 | ) |
116 | 121 | }) |
117 | 122 |
|
|
0 commit comments