From 9806648c07a7af37ef3639454fd9e7c4e3367cae Mon Sep 17 00:00:00 2001 From: Kfir Amar Date: Sat, 14 Mar 2026 22:31:03 +0200 Subject: [PATCH] test(auth): cover stale active error metadata path Refine the recovered-account regression test to match the real observed state: an account can remain active while still carrying stale refresh-failure metadata. This verifies that getProviderCredentials surfaces those fields and that clearAccountError clears them through the real runtime path. --- tests/unit/auth-clear-account-error.test.mjs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/unit/auth-clear-account-error.test.mjs b/tests/unit/auth-clear-account-error.test.mjs index cab519edff..cb7f283f7f 100644 --- a/tests/unit/auth-clear-account-error.test.mjs +++ b/tests/unit/auth-clear-account-error.test.mjs @@ -32,16 +32,20 @@ test("clearAccountError clears stale provider error metadata after recovery", as email: "recover@example.com", accessToken: "access", refreshToken: "refresh", - testStatus: "error", - lastError: "Health check: token refresh failed", + testStatus: "active", + lastError: null, lastErrorType: "token_refresh_failed", lastErrorSource: "oauth", errorCode: "refresh_failed", - rateLimitedUntil: new Date(Date.now() + 60_000).toISOString(), + rateLimitedUntil: null, backoffLevel: 2, }); const credentials = await auth.getProviderCredentials("codex"); + assert.equal(credentials.connectionId, created.id); + assert.equal(credentials.errorCode, "refresh_failed"); + assert.equal(credentials.lastErrorType, "token_refresh_failed"); + assert.equal(credentials.lastErrorSource, "oauth"); await auth.clearAccountError(created.id, credentials); const updated = await providersDb.getProviderConnectionById(created.id);