The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/core/services/echo/utils.test.ts

41 lines
974 B

import { CurrentUserDTO, OrgRole } from '@grafana/data';
import { getUserIdentifier } from './utils';
const baseUser: CurrentUserDTO = {
isSignedIn: true,
id: 3,
login: 'myUsername',
email: 'email@example.com',
name: 'My Name',
theme: 'dark',
lightTheme: false, // deprecated
orgCount: 1,
orgId: 1,
orgName: 'Main Org.',
orgRole: OrgRole.Admin,
isGrafanaAdmin: false,
gravatarUrl: '/avatar/abc-123',
timezone: 'browser',
weekStart: 'browser',
locale: 'en-AU',
language: 'en-US',
externalUserId: '',
};
const gcomUser: CurrentUserDTO = {
...baseUser,
externalUserId: 'abc-123',
};
describe('echo getUserIdentifier', () => {
it('should return the external user ID (gcom ID) if available', () => {
const id = getUserIdentifier(gcomUser);
expect(id).toBe('abc-123');
});
it('should fall back to the email address', () => {
const id = getUserIdentifier(baseUser);
expect(id).toBe('email@example.com');
});
});