test(auth): add comprehensive tests for GLM auth persistence fix

Add 26 new unit tests covering:
- isFirstTimeInstall() legacy config detection (8 tests)
- loadSettingsFromFile() path expansion (5 tests)
- ProfileDetector detectProfileType() (4 tests)
- expandPath() cross-platform handling (10 tests)

Test coverage for issue #195:
- Legacy config.json/profiles.json detection
- Tilde expansion to home directory
- Environment variable expansion (${VAR}, $VAR, %VAR%)
- Mixed path separator normalization
- Corrupted config graceful handling

Files:
- tests/unit/commands/setup-command.test.ts
- tests/unit/auth/profile-detector.test.ts
- tests/unit/utils/expand-path.test.ts
This commit is contained in:
kaitranntt committed 2025-12-24 18:33:52 -05:00
1 parent adb6222bc6
commit 92a79aa78b
7 files changed
+369 -5

No files matched your search

+1 -1
View File
@@ -65,7 +65,7 @@ export interface ProfileNotFoundError extends Error {
* Uses expandPath() for consistent cross-platform path handling.
* Returns empty object on error.
*/
function loadSettingsFromFile(settingsPath: string): Record<string, string> {
export function loadSettingsFromFile(settingsPath: string): Record<string, string> {
const expandedPath = expandPath(settingsPath);
try {
if (!fs.existsSync(expandedPath)) return {};