feat: Improves key expiration handling in Explore (#18624)

* feat: Improves key expiration handling in Explore

* Sets use_slice_data equals true

* Shows toast when recovering
This commit is contained in:
Michael S. Molina
2022-02-09 13:20:21 -03:00
committed by GitHub
parent bcad1acec2
commit f03b4dbedb
8 changed files with 79 additions and 8 deletions

View File

@@ -28,6 +28,7 @@ const reduxState = {
common: { conf: { SUPERSET_WEBSERVER_TIMEOUT: 60 } },
controls: { datasource: { value: '1__table' } },
datasource: {
id: 1,
type: 'table',
columns: [{ is_dttm: false }],
metrics: [{ id: 1, metric_name: 'count' }],
@@ -65,7 +66,7 @@ fetchMock.get('glob:*/api/v1/explore/form_data*', {});
const renderWithRouter = (withKey?: boolean) => {
const path = '/superset/explore/';
const search = withKey ? `?form_data_key=${key}` : '';
const search = withKey ? `?form_data_key=${key}&dataset_id=1` : '';
return render(
<MemoryRouter initialEntries={[`${path}${search}`]}>
<Route path={path}>
@@ -82,7 +83,12 @@ test('generates a new form_data param when none is available', async () => {
expect(replaceState).toHaveBeenCalledWith(
expect.anything(),
undefined,
expect.stringMatching('form_data'),
expect.stringMatching('form_data_key'),
);
expect(replaceState).toHaveBeenCalledWith(
expect.anything(),
undefined,
expect.stringMatching('dataset_id'),
);
replaceState.mockRestore();
});
@@ -96,6 +102,11 @@ test('generates a different form_data param when one is provided and is mounting
undefined,
expect.stringMatching(key),
);
expect(replaceState).toHaveBeenCalledWith(
expect.anything(),
undefined,
expect.stringMatching('dataset_id'),
);
replaceState.mockRestore();
});