mirror of
https://github.com/apache/superset.git
synced 2026-07-09 08:15:49 +00:00
feat(frontend): add dataset cache clearing utilities and integration (#35264)
Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Geidō <60598000+geido@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
9fbfcf0ccd
commit
0b535b792e
@@ -61,6 +61,10 @@ jest.mock('src/SqlLab/actions/sqlLab', () => ({
|
||||
jest.mock('src/explore/exploreUtils/formData', () => ({
|
||||
postFormData: jest.fn(),
|
||||
}));
|
||||
jest.mock('src/utils/cachedSupersetGet', () => ({
|
||||
...jest.requireActual('src/utils/cachedSupersetGet'),
|
||||
clearDatasetCache: jest.fn(),
|
||||
}));
|
||||
|
||||
// eslint-disable-next-line no-restricted-globals -- TODO: Migrate from describe blocks
|
||||
describe('SaveDatasetModal', () => {
|
||||
@@ -336,4 +340,42 @@ describe('SaveDatasetModal', () => {
|
||||
templateParams: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
test('clears dataset cache when creating new dataset', async () => {
|
||||
const clearDatasetCache = jest.spyOn(
|
||||
require('src/utils/cachedSupersetGet'),
|
||||
'clearDatasetCache',
|
||||
);
|
||||
const postFormData = jest.spyOn(
|
||||
require('src/explore/exploreUtils/formData'),
|
||||
'postFormData',
|
||||
);
|
||||
|
||||
const dummyDispatch = jest.fn().mockResolvedValue({ id: 123 });
|
||||
useDispatchMock.mockReturnValue(dummyDispatch);
|
||||
useSelectorMock.mockReturnValue({ ...user });
|
||||
postFormData.mockResolvedValue('chart_key_123');
|
||||
|
||||
render(<SaveDatasetModal {...mockedProps} />, { useRedux: true });
|
||||
|
||||
const inputFieldText = screen.getByDisplayValue(/unimportant/i);
|
||||
fireEvent.change(inputFieldText, { target: { value: 'my dataset' } });
|
||||
|
||||
const saveConfirmationBtn = screen.getByRole('button', {
|
||||
name: /save/i,
|
||||
});
|
||||
userEvent.click(saveConfirmationBtn);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(clearDatasetCache).toHaveBeenCalledWith(123);
|
||||
});
|
||||
});
|
||||
|
||||
test('clearDatasetCache is imported and available', () => {
|
||||
const clearDatasetCache =
|
||||
require('src/utils/cachedSupersetGet').clearDatasetCache;
|
||||
|
||||
expect(clearDatasetCache).toBeDefined();
|
||||
expect(typeof clearDatasetCache).toBe('function');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user