mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 07:50:13 +00:00
The review service can now refuse a new version with 429 export_hourly_limit (too many versions in the last hour). It had no sentence, so the person read "Couldn't add this version. Try again." and every retry was refused again. It now says the hourly limit was reached and when to try again, from the server's Retry-After, falling back to "in an hour" when none is sent. The daily limit keeps its "tomorrow" fallback. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
30 lines
1.2 KiB
JavaScript
30 lines
1.2 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { test } from "node:test";
|
|
import { ReviewFailed } from "../src/reviewClient.mjs";
|
|
import { versionSentence } from "../src/reviewVersionSentences.mjs";
|
|
|
|
test("the hourly version cap says how long to wait instead of telling the person to try again now", () => {
|
|
assert.equal(
|
|
versionSentence(new ReviewFailed(429, "export_hourly_limit", undefined, 25 * 60_000)),
|
|
"You've added the most versions for this hour. Try again in 25 minutes.",
|
|
);
|
|
});
|
|
|
|
test("each cap falls back to its own window when the server sends no Retry-After", () => {
|
|
assert.equal(
|
|
versionSentence(new ReviewFailed(429, "export_hourly_limit")),
|
|
"You've added the most versions for this hour. Try again in an hour.",
|
|
);
|
|
assert.equal(
|
|
versionSentence(new ReviewFailed(429, "export_daily_limit")),
|
|
"You've added the most versions for today. Try again tomorrow.",
|
|
);
|
|
});
|
|
|
|
test("the daily version cap rounds a long wait to hours", () => {
|
|
assert.equal(
|
|
versionSentence(new ReviewFailed(429, "export_daily_limit", undefined, 2 * 60 * 60_000)),
|
|
"You've added the most versions for today. Try again in about 2 hours.",
|
|
);
|
|
});
|