diff options
| author | Bryan Morgan <[email protected]> | 2025-06-29 16:35:20 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-06-29 20:35:20 +0000 |
| commit | cdb803b9a431128a851a4da82edaa82494ac6215 (patch) | |
| tree | bb281f50f41ff68cde421f78de622e220eeefb6e /packages/core/src/utils/user_id.test.ts | |
| parent | dbe63e7234b0ea2577f84aab774ef011d300745f (diff) | |
Added obfuscated google account ID to clearcut log messages (#2593)
Diffstat (limited to 'packages/core/src/utils/user_id.test.ts')
| -rw-r--r-- | packages/core/src/utils/user_id.test.ts | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/packages/core/src/utils/user_id.test.ts b/packages/core/src/utils/user_id.test.ts new file mode 100644 index 00000000..81b99ef4 --- /dev/null +++ b/packages/core/src/utils/user_id.test.ts @@ -0,0 +1,48 @@ +/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +import { describe, it, expect } from 'vitest'; +import { getInstallationId, getObfuscatedGoogleAccountId } from './user_id.js'; + +describe('user_id', () => { + describe('getInstallationId', () => { + it('should return a valid UUID format string', () => { + const installationId = getInstallationId(); + + expect(installationId).toBeDefined(); + expect(typeof installationId).toBe('string'); + expect(installationId.length).toBeGreaterThan(0); + + // Should return the same ID on subsequent calls (consistent) + const secondCall = getInstallationId(); + expect(secondCall).toBe(installationId); + }); + }); + + describe('getObfuscatedGoogleAccountId', () => { + it('should return a non-empty string', () => { + const result = getObfuscatedGoogleAccountId(); + + expect(result).toBeDefined(); + expect(typeof result).toBe('string'); + expect(result.length).toBeGreaterThan(0); + + // Should be consistent on subsequent calls + const secondCall = getObfuscatedGoogleAccountId(); + expect(secondCall).toBe(result); + }); + + it('should return the same as installation ID when no Google Account ID is cached', () => { + // In a clean test environment, there should be no cached Google Account ID + // so getObfuscatedGoogleAccountId should fall back to installation ID + const googleAccountIdResult = getObfuscatedGoogleAccountId(); + const installationIdResult = getInstallationId(); + + // They should be the same when no Google Account ID is cached + expect(googleAccountIdResult).toBe(installationIdResult); + }); + }); +}); |
