mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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:
parent
5aacc7cc2a
commit
fcfde8abd8
@ -96,10 +96,28 @@ describe('SharePublic', () => {
|
|||||||
await screen.findByText('Welcome to Grafana public dashboards alpha!');
|
await screen.findByText('Welcome to Grafana public dashboards alpha!');
|
||||||
});
|
});
|
||||||
|
|
||||||
// test when checkboxes show up
|
it('renders default time in inputs', async () => {
|
||||||
// test checkboxes hidden
|
config.featureToggles.publicDashboards = true;
|
||||||
// test url hidden
|
const mockDashboard = new DashboardModel({
|
||||||
// test url shows up
|
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
|
// test checking if current version of dashboard in state is persisted to db
|
||||||
});
|
});
|
||||||
|
@ -164,14 +164,14 @@ export const SharePublicDashboard = (props: Props) => {
|
|||||||
<br />
|
<br />
|
||||||
<div style={{ padding: '5px' }}>
|
<div style={{ padding: '5px' }}>
|
||||||
<Input
|
<Input
|
||||||
value={props.dashboard.time.from}
|
value={props.dashboard.getDefaultTime().from}
|
||||||
disabled={true}
|
disabled={true}
|
||||||
addonBefore={
|
addonBefore={
|
||||||
<span style={{ width: '50px', display: 'flex', alignItems: 'center', padding: '5px' }}>From:</span>
|
<span style={{ width: '50px', display: 'flex', alignItems: 'center', padding: '5px' }}>From:</span>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
value={props.dashboard.time.to}
|
value={props.dashboard.getDefaultTime().to}
|
||||||
disabled={true}
|
disabled={true}
|
||||||
addonBefore={
|
addonBefore={
|
||||||
<span style={{ width: '50px', display: 'flex', alignItems: 'center', padding: '5px' }}>To:</span>
|
<span style={{ width: '50px', display: 'flex', alignItems: 'center', padding: '5px' }}>To:</span>
|
||||||
|
Loading…
Reference in New Issue
Block a user