public dashboards:fix time regression (#51998)

This PR fixes a regression bug for public dashboards and adds a test to ensure the regression does not resurface.
This commit is contained in:
Jeff Levin 2022-07-11 03:50:34 -08:00 committed by GitHub
parent 5aacc7cc2a
commit fcfde8abd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 7 deletions

View File

@ -96,10 +96,28 @@ describe('SharePublic', () => {
await screen.findByText('Welcome to Grafana public dashboards alpha!');
});
// test when checkboxes show up
// test checkboxes hidden
// test url hidden
// test url shows up
//
it('renders default time in inputs', async () => {
config.featureToggles.publicDashboards = true;
const mockDashboard = new DashboardModel({
uid: 'mockDashboardUid',
});
const mockPanel = new PanelModel({
id: 'mockPanelId',
});
expect(mockDashboard.time).toEqual({ from: 'now-6h', to: 'now' });
//@ts-ignore
mockDashboard.originalTime = { from: 'test-from', to: 'test-to' };
render(<ShareModal panel={mockPanel} dashboard={mockDashboard} onDismiss={() => {}} />);
await waitFor(() => screen.getByText('Link'));
fireEvent.click(screen.getByText('Public Dashboard'));
await screen.findByText('Welcome to Grafana public dashboards alpha!');
expect(screen.getByDisplayValue('test-from')).toBeInTheDocument();
expect(screen.getByDisplayValue('test-to')).toBeInTheDocument();
});
// test checking if current version of dashboard in state is persisted to db
});

View File

@ -164,14 +164,14 @@ export const SharePublicDashboard = (props: Props) => {
<br />
<div style={{ padding: '5px' }}>
<Input
value={props.dashboard.time.from}
value={props.dashboard.getDefaultTime().from}
disabled={true}
addonBefore={
<span style={{ width: '50px', display: 'flex', alignItems: 'center', padding: '5px' }}>From:</span>
}
/>
<Input
value={props.dashboard.time.to}
value={props.dashboard.getDefaultTime().to}
disabled={true}
addonBefore={
<span style={{ width: '50px', display: 'flex', alignItems: 'center', padding: '5px' }}>To:</span>