Skip to content

Commit 7693bf2

Browse files
committed
test: add tests to the fix
1 parent 6cfca3a commit 7693bf2

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

superset-frontend/src/explore/components/SaveModal.test.jsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,3 +315,33 @@ test('make sure slice_id in the URLSearchParams before the redirect', () => {
315315
);
316316
expect(result.get('slice_id')).toEqual('1');
317317
});
318+
319+
test('removes form_data_key from URL parameters after save', () => {
320+
const myProps = {
321+
...defaultProps,
322+
slice: { slice_id: 1, slice_name: 'title', owners: [1] },
323+
actions: {
324+
setFormData: jest.fn(),
325+
updateSlice: jest.fn(() => Promise.resolve({ id: 1 })),
326+
getSliceDashboards: jest.fn(),
327+
},
328+
user: { userId: 1 },
329+
history: {
330+
replace: jest.fn(),
331+
},
332+
dispatch: jest.fn(),
333+
};
334+
335+
const saveModal = new PureSaveModal(myProps);
336+
337+
// Test with form_data_key in the URL
338+
const urlWithFormDataKey = '?form_data_key=12345&other_param=value';
339+
const result = saveModal.handleRedirect(urlWithFormDataKey, { id: 1 });
340+
341+
// form_data_key should be removed
342+
expect(result.has('form_data_key')).toBe(false);
343+
// other parameters should remain
344+
expect(result.get('other_param')).toEqual('value');
345+
expect(result.get('slice_id')).toEqual('1');
346+
expect(result.get('save_action')).toEqual('overwrite');
347+
});

0 commit comments

Comments
 (0)