From cc9f7d48c8ad61fcfc554ad45ad12a633e8c8fb4 Mon Sep 17 00:00:00 2001 From: Shirone Date: Fri, 16 Jan 2026 23:58:48 +0100 Subject: [PATCH] fix: enhance authentication error handling in Claude usage service tests - Updated test to send a specific authentication error pattern to the data callback. - Triggered the exit handler to validate the handling of authentication errors. - Improved error message expectations for better clarity during test failures. --- .../server/tests/unit/services/claude-usage-service.test.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/server/tests/unit/services/claude-usage-service.test.ts b/apps/server/tests/unit/services/claude-usage-service.test.ts index 024c4e3a..07ad13c9 100644 --- a/apps/server/tests/unit/services/claude-usage-service.test.ts +++ b/apps/server/tests/unit/services/claude-usage-service.test.ts @@ -518,7 +518,11 @@ Resets in 2h const promise = ptyService.fetchUsageData(); - dataCallback!('authentication_error'); + // Send data containing the authentication error pattern the service looks for + dataCallback!('"type":"authentication_error"'); + + // Trigger the exit handler which checks for auth errors + exitCallback!({ exitCode: 1 }); await expect(promise).rejects.toThrow( "Claude CLI authentication issue. Please run 'claude logout' and then 'claude login' in your terminal to refresh permissions."