Files
grafana/public/app/features/dashboard/dashgrid/PanelHeader/PanelHeader.test.tsx
Jeff Levin d076bedb5e public dashboards: finalize db schema & v1 feature complete (#50467)
This PR completes public dashboards v1 functionality and simplifies public dashboard conventions. It exists as a large PR so that we are not making constant changes to the database schema.

models.PublicDashboardConfig model replaced with models.PublicDashboard directly
dashboard_public_config table renamed to dashboard_public
models.Dashboard.IsPublic removed from the dashboard and replaced with models.PublicDashboard.isEnabled
Routing now uses a uuid v4 as an access token for viewing a public dashboard anonymously, PublicDashboard.Uid only used as database identifier
Frontend utilizes uuid for auth'd operations and access token for anonymous access
Default to time range defined on dashboard when viewing public dashboard
Add audit fields to public dashboard

Co-authored-by: Owen Smallwood <owen.smallwood@grafana.com>, Ezequiel Victorero <ezequiel.victorero@grafana.com>, Jesse Weaver <jesse.weaver@grafana.com>
2022-06-22 13:58:52 -08:00

43 lines
1.5 KiB
TypeScript

import { render, screen } from '@testing-library/react';
import React from 'react';
import { createEmptyQueryResponse } from '../../../explore/state/utils';
import { DashboardModel, PanelModel } from '../../state';
import { PanelHeader } from './PanelHeader';
let panelModel = new PanelModel({
id: 1,
gridPos: { x: 1, y: 1, w: 1, h: 1 },
type: 'type',
title: 'title',
});
let panelData = createEmptyQueryResponse();
describe('Panel Header', () => {
const dashboardModel = new DashboardModel({}, { publicDashboardAccessToken: 'abc123' });
it('will render header title but not render dropdown icon when dashboard is being viewed publicly', () => {
window.history.pushState({}, 'Test Title', '/public-dashboards/abc123');
render(
<PanelHeader panel={panelModel} dashboard={dashboardModel} isViewing={false} isEditing={false} data={panelData} />
);
expect(screen.getByText('title')).toBeDefined();
expect(screen.queryByTestId('panel-dropdown')).toBeNull();
});
it('will render header title and dropdown icon when dashboard is not being viewed publicly', () => {
const dashboardModel = new DashboardModel({}, { publicDashboardAccessToken: '' });
window.history.pushState({}, 'Test Title', '/d/abc/123');
render(
<PanelHeader panel={panelModel} dashboard={dashboardModel} isViewing={false} isEditing={false} data={panelData} />
);
expect(screen.getByText('title')).toBeDefined();
expect(screen.getByTestId('panel-dropdown')).toBeDefined();
});
});