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/tests/api/dashboard.test.ts

45 lines
1.1 KiB

import client from './client';
import * as setup from './setup';
describe('/api/dashboards', () => {
let state: any = {};
beforeAll(async () => {
state = await setup.ensureState({
orgName: 'api-test-org',
users: [
{ user: setup.admin, role: 'Admin' },
{ user: setup.editor, role: 'Editor' },
{ user: setup.viewer, role: 'Viewer' },
],
admin: setup.admin,
dashboards: [
{
title: 'aaa',
uid: 'aaa',
},
{
title: 'bbb',
uid: 'bbb',
},
],
});
});
describe('With admin user', () => {
it('can delete dashboard', async () => {
let rsp = await client.callAs(setup.admin).delete(`/api/dashboards/uid/aaa`);
expect(rsp.data.title).toBe('aaa');
});
});
describe('With viewer user', () => {
it('Cannot delete dashboard', async () => {
let rsp = await setup.expectError(() => {
return client.callAs(setup.viewer).delete(`/api/dashboards/uid/bbb`);
});
expect(rsp.response.status).toBe(403);
});
});
});