mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
PublicDashboards: Public dashboard refreshed when access token changes (#87913)
This commit is contained in:
parent
90970d5f58
commit
a6d64c6ed5
@ -2,7 +2,7 @@ import { render, screen, waitFor } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import React from 'react';
|
||||
import { Provider } from 'react-redux';
|
||||
import { Router } from 'react-router-dom';
|
||||
import { match, Router } from 'react-router-dom';
|
||||
import { useEffectOnce } from 'react-use';
|
||||
import { Props as AutoSizerProps } from 'react-virtualized-auto-sizer';
|
||||
import { getGrafanaContextMock } from 'test/mocks/getGrafanaContextMock';
|
||||
@ -248,6 +248,16 @@ describe('PublicDashboardPage', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('When public dashboard changes', () => {
|
||||
it('Should init again', async () => {
|
||||
const { rerender } = setup();
|
||||
rerender({ match: { params: { accessToken: 'another-new-access-token' } } as unknown as match });
|
||||
await waitFor(() => {
|
||||
expect(initDashboard).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Given a public dashboard with time range enabled', () => {
|
||||
it('Should render time range and refresh picker buttons', async () => {
|
||||
setup(undefined, {
|
||||
|
@ -69,8 +69,7 @@ const PublicDashboardPage = (props: Props) => {
|
||||
keybindingSrv: context.keybindings,
|
||||
})
|
||||
);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
}, [route.routeName, match.params.accessToken, context.keybindings, dispatch]);
|
||||
|
||||
useEffect(() => {
|
||||
if (prevProps?.location.search !== location.search) {
|
||||
@ -89,7 +88,7 @@ const PublicDashboardPage = (props: Props) => {
|
||||
getTimeSrv().setAutoRefresh(urlParams.refresh);
|
||||
}
|
||||
}
|
||||
}, [prevProps, location.search, props.queryParams, dashboard?.timepicker.hidden]);
|
||||
}, [prevProps, location.search, props.queryParams, dashboard?.timepicker.hidden, match.params.accessToken]);
|
||||
|
||||
if (!dashboard) {
|
||||
return <DashboardLoading initPhase={dashboardState.initPhase} />;
|
||||
|
Loading…
Reference in New Issue
Block a user