fix(explore): Overwriting a chart updates the form_data_key (#35888)

This commit is contained in:
Mehmet Salih Yavuz
2025-11-05 18:44:53 +03:00
committed by GitHub
parent a1d4dff99d
commit 3f49938b79
2 changed files with 32 additions and 3 deletions

View File

@@ -315,3 +315,33 @@ test('make sure slice_id in the URLSearchParams before the redirect', () => {
);
expect(result.get('slice_id')).toEqual('1');
});
test('removes form_data_key from URL parameters after save', () => {
const myProps = {
...defaultProps,
slice: { slice_id: 1, slice_name: 'title', owners: [1] },
actions: {
setFormData: jest.fn(),
updateSlice: jest.fn(() => Promise.resolve({ id: 1 })),
getSliceDashboards: jest.fn(),
},
user: { userId: 1 },
history: {
replace: jest.fn(),
},
dispatch: jest.fn(),
};
const saveModal = new PureSaveModal(myProps);
// Test with form_data_key in the URL
const urlWithFormDataKey = '?form_data_key=12345&other_param=value';
const result = saveModal.handleRedirect(urlWithFormDataKey, { id: 1 });
// form_data_key should be removed
expect(result.has('form_data_key')).toBe(false);
// other parameters should remain
expect(result.get('other_param')).toEqual('value');
expect(result.get('slice_id')).toEqual('1');
expect(result.get('save_action')).toEqual('overwrite');
});