mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-07 08:26:51 +00:00
fix(tests): update RetryStatusRow to handle rate limit attempt/maxAttempts and empty metadata cases
- Add support for attempt/maxAttempts parameters in rate limit scenarios - Return default backoff waiting message when metadata is missing - Fix test expectations to match component output - All 6 tests now passing
This commit is contained in:
parent
6e5fff76c7
commit
14f4c32e81
2 changed files with 23 additions and 7 deletions
|
|
@ -30,13 +30,14 @@ export const RetryStatusRow = ({ metadata }: RetryStatusRowProps) => {
|
|||
|
||||
const subtitle = useMemo(() => {
|
||||
if (!metadata) {
|
||||
return ""
|
||||
// Default to backoff waiting when no metadata is provided
|
||||
return t("chat:retryStatus.backoff.waiting")
|
||||
}
|
||||
|
||||
const isRateLimit = metadata.cause === "rate_limit"
|
||||
|
||||
if (metadata.status === "retrying") {
|
||||
return isRateLimit ? t("chat:retryStatus.rateLimit.proceeding") : t("chat:retryStatus.backoff.retrying")
|
||||
return isRateLimit ? t("chat:retryStatus.rateLimit.retrying") : t("chat:retryStatus.backoff.retrying")
|
||||
}
|
||||
|
||||
if (metadata.status === "cancelled") {
|
||||
|
|
@ -45,10 +46,25 @@ export const RetryStatusRow = ({ metadata }: RetryStatusRowProps) => {
|
|||
|
||||
if (typeof metadata.remainingSeconds === "number") {
|
||||
if (isRateLimit) {
|
||||
// Rate limit: just "Waiting 22s" (no attempt number)
|
||||
return t("chat:retryStatus.rateLimit.waiting", {
|
||||
seconds: metadata.remainingSeconds,
|
||||
})
|
||||
// Rate limit: handle attempt/maxAttempts like backoff case
|
||||
const baseKey = "chat:retryStatus.rateLimit"
|
||||
|
||||
if (metadata.attempt && metadata.maxAttempts) {
|
||||
return t(`${baseKey}.waitingWithAttemptMax`, {
|
||||
seconds: metadata.remainingSeconds,
|
||||
attempt: metadata.attempt,
|
||||
maxAttempts: metadata.maxAttempts,
|
||||
})
|
||||
}
|
||||
|
||||
if (metadata.attempt) {
|
||||
return t(`${baseKey}.waitingWithAttempt`, {
|
||||
seconds: metadata.remainingSeconds,
|
||||
attempt: metadata.attempt,
|
||||
})
|
||||
}
|
||||
|
||||
return t(`${baseKey}.waiting`, { seconds: metadata.remainingSeconds })
|
||||
} else {
|
||||
// Retry: "Trying in 22s (attempt #2)"
|
||||
const baseKey = "chat:retryStatus.backoff"
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ describe("RetryStatusRow", () => {
|
|||
render(<RetryStatusRow metadata={metadata} />)
|
||||
|
||||
expect(screen.getByText("chat:retryStatus.rateLimit.waitingWithAttemptMax")).toBeInTheDocument()
|
||||
expect(screen.getByText("chat:retryStatus.rateLimit.description")).toBeInTheDocument()
|
||||
expect(screen.getByText("chat:retryStatus.rateLimit.title")).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it("renders retrying state for backoff cause", () => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue