test: group remaining suite cleanups

This commit is contained in:
Peter Steinberger
2026-02-21 21:43:24 +00:00
parent 5c8f0b5a77
commit 861718e4dc
32 changed files with 870 additions and 922 deletions

View File

@@ -35,10 +35,6 @@ describe("isAuthErrorMessage", () => {
expect(isAuthErrorMessage(sample)).toBe(true);
}
});
it("ignores unrelated errors", () => {
expect(isAuthErrorMessage("rate limit exceeded")).toBe(false);
expect(isAuthErrorMessage("billing issue detected")).toBe(false);
});
});
describe("isBillingErrorMessage", () => {
@@ -54,11 +50,6 @@ describe("isBillingErrorMessage", () => {
expect(isBillingErrorMessage(sample)).toBe(true);
}
});
it("ignores unrelated errors", () => {
expect(isBillingErrorMessage("rate limit exceeded")).toBe(false);
expect(isBillingErrorMessage("invalid api key")).toBe(false);
expect(isBillingErrorMessage("context length exceeded")).toBe(false);
});
it("does not false-positive on issue IDs or text containing 402", () => {
const falsePositives = [
"Fixed issue CHE-402 in the latest release",
@@ -110,14 +101,6 @@ describe("isCloudCodeAssistFormatError", () => {
expect(isCloudCodeAssistFormatError(sample)).toBe(true);
}
});
it("ignores unrelated errors", () => {
expect(isCloudCodeAssistFormatError("rate limit exceeded")).toBe(false);
expect(
isCloudCodeAssistFormatError(
'400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.84.content.1.image.source.base64.data: At least one of the image dimensions exceed max allowed size for many-image requests: 2000 pixels"}}',
),
).toBe(false);
});
});
describe("isCloudflareOrHtmlErrorPage", () => {
@@ -195,13 +178,6 @@ describe("isContextOverflowError", () => {
}
});
it("ignores unrelated errors", () => {
expect(isContextOverflowError("rate limit exceeded")).toBe(false);
expect(isContextOverflowError("request size exceeds upload limit")).toBe(false);
expect(isContextOverflowError("model not found")).toBe(false);
expect(isContextOverflowError("authentication failed")).toBe(false);
});
it("ignores normal conversation text mentioning context overflow", () => {
// These are legitimate conversation snippets, not error messages
expect(isContextOverflowError("Let's investigate the context overflow bug")).toBe(false);
@@ -211,6 +187,46 @@ describe("isContextOverflowError", () => {
});
});
describe("error classifiers", () => {
it("ignore unrelated errors", () => {
const checks: Array<{
matcher: (message: string) => boolean;
samples: string[];
}> = [
{
matcher: isAuthErrorMessage,
samples: ["rate limit exceeded", "billing issue detected"],
},
{
matcher: isBillingErrorMessage,
samples: ["rate limit exceeded", "invalid api key", "context length exceeded"],
},
{
matcher: isCloudCodeAssistFormatError,
samples: [
"rate limit exceeded",
'400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.84.content.1.image.source.base64.data: At least one of the image dimensions exceed max allowed size for many-image requests: 2000 pixels"}}',
],
},
{
matcher: isContextOverflowError,
samples: [
"rate limit exceeded",
"request size exceeds upload limit",
"model not found",
"authentication failed",
],
},
];
for (const check of checks) {
for (const sample of check.samples) {
expect(check.matcher(sample)).toBe(false);
}
}
});
});
describe("isLikelyContextOverflowError", () => {
it("matches context overflow hints", () => {
const samples = [