mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* user essentials mob! 🔱 lastFile:pkg/api/preferences.go * user essentials mob! 🔱 * user essentials mob! 🔱 lastFile:packages/grafana-data/src/types/config.ts * user essentials mob! 🔱 lastFile:public/app/core/services/echo/utils.test.ts * user essentials mob! 🔱 * user essentials mob! 🔱 lastFile:public/views/index-template.html * user essentials mob! 🔱 * Restore currentUser.lightTheme for backwards compat * fix types * Apply suggestions from code review Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * cleanup * cleanup --------- Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com> Co-authored-by: Joao Silva <joao.silva@grafana.com> Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>
42 lines
974 B
TypeScript
42 lines
974 B
TypeScript
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');
|
|
});
|
|
});
|