mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* update eslint, tsconfig + esbuild to handle new jsx transform * remove thing that breaks the new jsx transform * remove react imports * adjust grafana-icons build * is this the correct syntax? * try this * well this was much easier than expected... * change grafana-plugin-configs webpack config * fixes * fix lockfile * fix 2 more violations * use path.resolve instead of require.resolve * remove react import * fix react imports * more fixes * remove React import * remove import React from docs * remove another react import
60 lines
1.8 KiB
TypeScript
60 lines
1.8 KiB
TypeScript
import { render, screen } from '@testing-library/react';
|
|
|
|
import config from 'app/core/config';
|
|
|
|
import { ServerStats } from './ServerStats';
|
|
import { ServerStat } from './state/apis';
|
|
|
|
const stats: ServerStat = {
|
|
activeAdmins: 1,
|
|
activeEditors: 0,
|
|
activeSessions: 1,
|
|
activeUsers: 1,
|
|
activeViewers: 0,
|
|
activeDevices: 1,
|
|
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: {
|
|
hasPermission: () => 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();
|
|
expect(screen.getByRole('link', { name: 'Manage data sources' })).toBeInTheDocument();
|
|
expect(screen.getByRole('link', { name: 'Manage alerts' })).toBeInTheDocument();
|
|
expect(screen.getByRole('link', { name: 'Manage users' })).toBeInTheDocument();
|
|
});
|
|
|
|
it('Should render page with anonymous stats', async () => {
|
|
config.anonymousEnabled = true;
|
|
config.anonymousDeviceLimit = 10;
|
|
render(<ServerStats />);
|
|
expect(await screen.findByRole('heading', { name: /instance statistics/i })).toBeInTheDocument();
|
|
expect(screen.getByText('Active anonymous devices')).toBeInTheDocument();
|
|
});
|
|
});
|