mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 01:53:33 -06:00
* refactor licenseURL function to use context and export permission evaluation fction * remove provisioning file * refactor licenseURL to take in a bool to avoid circular dependencies * remove function for appending nav link, as it was only used once and move the function to create admin node * better argument names * create a function for permission checking * extend permission checking when displaying server stats * enable the use of enterprise access control actions when evaluating permissions * import ordering * move licensing FGAC action definitions to models package to allow access from oss * move evaluatePermissions for routes to context serve * change permission evaluator to take in more permissions * move licensing FGAC actions again to appease wire * avoid index out of bounds issue in case no children are passed in when creating server admin node * simplify syntax for permission checking Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com> * update loading state for server stats * linting * more linting * fix test * fix a frontend test * update "licensing.reports:read" action naming * UI doesn't allow reading only licensing reports and not the rest of licensing info Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import React from 'react';
|
|
import { render, screen } from '@testing-library/react';
|
|
import { ServerStats } from './ServerStats';
|
|
import { ServerStat } from './state/apis';
|
|
|
|
const stats: ServerStat = {
|
|
activeAdmins: 1,
|
|
activeEditors: 0,
|
|
activeSessions: 1,
|
|
activeUsers: 1,
|
|
activeViewers: 0,
|
|
admins: 1,
|
|
alerts: 5,
|
|
dashboards: 1599,
|
|
datasources: 54,
|
|
editors: 2,
|
|
orgs: 1,
|
|
playlists: 1,
|
|
snapshots: 1,
|
|
stars: 3,
|
|
tags: 42,
|
|
users: 5,
|
|
viewers: 2,
|
|
};
|
|
|
|
jest.mock('./state/apis', () => ({
|
|
getServerStats: async () => stats,
|
|
}));
|
|
jest.mock('../../core/services/context_srv', () => ({
|
|
contextSrv: {
|
|
hasAccess: () => true,
|
|
},
|
|
}));
|
|
|
|
describe('ServerStats', () => {
|
|
it('Should render page with stats', async () => {
|
|
render(<ServerStats />);
|
|
expect(await screen.findByRole('heading', { name: /instance statistics/i })).toBeInTheDocument();
|
|
expect(screen.getByText('Dashboards (starred)')).toBeInTheDocument();
|
|
expect(screen.getByText('Tags')).toBeInTheDocument();
|
|
expect(screen.getByText('Playlists')).toBeInTheDocument();
|
|
expect(screen.getByText('Snapshots')).toBeInTheDocument();
|
|
expect(screen.getByRole('link', { name: 'Manage dashboards' })).toBeInTheDocument();
|
|
});
|
|
});
|