fix: permalink save/overwrites in explore#25112
Conversation
| } | ||
| if (this.state.action === 'saveas') { | ||
| } else { | ||
| searchParams.set('slice_id', value.id.toString()); |
There was a problem hiding this comment.
Should we add a small check in the tests to make sure that the slice_id always appears?
There was a problem hiding this comment.
@justinpark + @geido so i've spent literally tons of time trying to get this test work with the current testing pattern and been having no luck. I did find that this is a known issue in enzyme when using shallow vs mount
enzymejs/enzyme#2086
What i suggest is we merge this to fix the current issue, and I can investigate on rewriting this file to work properly with RTL and i'll take full ownership over this
const defaultPropsTwo = {
addDangerToast: jest.fn(),
onHide: () => ({}),
actions: {
saveDataset: jest.fn().mockReturnValue({ id: 42 }),
setFormData: jest.fn(),
updateSlice: jest.fn().mockReturnValue({ id: 42 }),
},
form_data: { datasource: '107__table', url_params: { foo: 'bar' } },
history: {
replace: jest.fn(),
}
};
const fetchChartEndpoint = `glob:*/api/v1/chart/${1}?q=(columns:!(dashboards.id))`;
beforeAll(() => {
fetchMock.get(fetchDashboardsEndpoint, mockDashboardData)
fetchMock.get(fetchChartEndpoint, { dashboards: [mockDashboardData]})
});
test('make sure saveOverwrite function always has slice_id attached to the url', () => {
const wrapper = getWrapper(defaultPropsTwo, queryStore);
const footerWrapper = shallow(wrapper.find(StyledModal).props().footer);
wrapper.setState({
action: 'overwrite',
});
const overwriteRadio = wrapper.find('#overwrite-radio');
overwriteRadio.simulate('click');
expect(wrapper.state().action).toBe('overwrite');
const save = footerWrapper.find('#btn_modal_save');
save.simulate('click');
expect(defaultPropsTwo.history.replace).toBeCalled()
});
|
@hughhhh given this is a fix, would you mind adding some unit tests? |
|
@hughhhh If I recall correctly, permalinks don't use the |
|
@john-bodley + @michael-s-molina I updated the PR with more context information |
…ix-permlink-save
| }; | ||
|
|
||
| const saveModal = new PureSaveModal(myProps); | ||
| saveModal.setState = jest.fn(); |
Co-authored-by: Elizabeth Thompson <[email protected]>
Co-authored-by: Elizabeth Thompson <[email protected]>
| export default withRouter(connect(mapStateToProps)(SaveModal)); | ||
|
|
||
| // todo(hughhhh): For testing | ||
| // - need to revisit once we convert this to functional component |
There was a problem hiding this comment.
I think you can remove the todo and just say that you're exporting this for testing.
eschutho
left a comment
There was a problem hiding this comment.
LGTM. I just left a small nit comment.
Co-authored-by: Elizabeth Thompson <[email protected]> (cherry picked from commit e58a3ab)
Co-authored-by: Elizabeth Thompson <[email protected]> (cherry picked from commit e58a3ab)
* fix: is_select with UNION (apache#25290) (cherry picked from commit bb002d6) * fix: Add explicit ON DELETE CASCADE for dashboard_roles (apache#25320) (cherry picked from commit d54e827) * fix(chart): Supporting custom SQL as temporal x-axis column with filter (apache#25126) Co-authored-by: Kamil Gabryjelski <[email protected]> * fix: Use RLS clause instead of ID for cache key (apache#25229) (cherry picked from commit fba66c6) * fix: Improve the reliability of alerts & reports (apache#25239) (cherry picked from commit f672d5d) * fix: DashboardRoles cascade operation (apache#25349) (cherry picked from commit a971a28) * fix: datetime with timezone excel export (apache#25318) Co-authored-by: Michael S. Molina <[email protected]> (cherry picked from commit 5ebcd2a) * fix: Workaround for Cypress ECONNRESET error (apache#25399) (cherry picked from commit d76ff39) * fix(sqllab): invalid persisted tab state (apache#25308) (apache#25398) * fix: Rename on_delete parameter to ondelete (apache#25424) (cherry picked from commit 893b45f) * fix: preventing save button from flickering in SQL Lab (apache#25106) (cherry picked from commit 296ff17) * fix: chart import (apache#25425) (cherry picked from commit a4d8f36) * fix: swagger UI CSP error (apache#25368) (cherry picked from commit 1716b9f) * fix: smarter date formatter (apache#25404) (cherry picked from commit f0080f9) * fix(sqllab): invalid start date (apache#25437) * fix(nativeFilters): Speed up native filters by removing unnecessary rerenders (apache#25282) Co-authored-by: JUST.in DO IT <[email protected]> (cherry picked from commit a0eeb4d) * fix(SqlLab): make icon placement even (apache#25372) (cherry picked from commit 11b49a6) * fix: Duplicate items when pasting into Select (apache#25447) (cherry picked from commit 7cf96cd) * fix: update the SQLAlchemy model definition at json column for Log table (apache#25445) (cherry picked from commit e83a76a) * fix(helm chart): set chart appVersion to 3.0.0 (apache#25373) * fix(mysql): handle string typed decimal results (apache#24241) (cherry picked from commit 7eab59a) * fix: Styles not loading because of faulty CSP setting (apache#25468) (cherry picked from commit 0cebffd) * fix(sqllab): error with lazy_gettext for tab titles (apache#25469) (cherry picked from commit ddde178) * fix: Address Mypy issue which is causing CI to fail (apache#25494) (cherry picked from commit 36ed617) * chore: Adds 3.0.1 CHANGELOG * fix: Unable to sync columns when database or dataset name contains `+` (apache#25390) (cherry picked from commit dbe0838) * fix(sqllab): Broken query containing 'children' (apache#25490) (cherry picked from commit b92957e) * chore: Expand error detail on screencapture (apache#25519) (cherry picked from commit ba541e8) * fix: tags permissions error message (apache#25516) (cherry picked from commit 50b0816) * fix: Apply normalization to all dttm columns (apache#25147) (cherry picked from commit 58fcd29) * fix: REST API CSRF exempt list (apache#25590) (cherry picked from commit 549abb5) * fix(RLS): Fix Info Tooltip + Button Alignment on RLS Modal (apache#25400) (cherry picked from commit a6d0e6f) * fix: thubmnails loading - Talisman default config (apache#25486) (cherry picked from commit 52f631a) * fix(Presto): catch DatabaseError when testing Presto views (apache#25559) Co-authored-by: Rui Zhao <[email protected]> (cherry picked from commit be3714e) * fix(Charts): Set max row limit + removed the option to use an empty row limit value (apache#25579) (cherry picked from commit f556ef5) * fix(window): unavailable localStorage and sessionStorage (apache#25599) * fix: finestTemporalGrainFormatter (apache#25618) (cherry picked from commit 62bffaf) * fix: revert fix(sqllab): Force trino client async execution (apache#24859) (apache#25541) (cherry picked from commit e56e0de) * chore: Updates 3.0.1 CHANGELOG * fix(sqllab): Mistitled for new tab after rename (apache#25523) (cherry picked from commit a520124) * fix(sqllab): template validation error within comments (apache#25626) (cherry picked from commit b370c66) * fix: avoid 500 errors with SQLLAB_BACKEND_PERSISTENCE (apache#25553) (cherry picked from commit 99f79f5) * fix(import): Make sure query context is overwritten for overwriting imports (apache#25493) (cherry picked from commit a0a0d80) * fix: permalink save/overwrites in explore (apache#25112) Co-authored-by: Elizabeth Thompson <[email protected]> (cherry picked from commit e58a3ab) * fix(header navlinks): link navlinks to path prefix (apache#25495) (cherry picked from commit 51c56dd) * fix: improve upload ZIP file validation (apache#25658) * fix: warning of nth-child (apache#23638) (cherry picked from commit 16cc089) * fix(dremio): Fixes issue with Dremio SQL generation for Charts with Series Limit (apache#25657) (cherry picked from commit be82657) --------- Co-authored-by: Beto Dealmeida <[email protected]> Co-authored-by: John Bodley <[email protected]> Co-authored-by: Zef Lin <[email protected]> Co-authored-by: Kamil Gabryjelski <[email protected]> Co-authored-by: Jack Fragassi <[email protected]> Co-authored-by: Michael S. Molina <[email protected]> Co-authored-by: JUST.in DO IT <[email protected]> Co-authored-by: Jack <[email protected]> Co-authored-by: Daniel Vaz Gaspar <[email protected]> Co-authored-by: Stepan <[email protected]> Co-authored-by: Corbin Bullard <[email protected]> Co-authored-by: Gyuil Han <[email protected]> Co-authored-by: Celalettin Calis <[email protected]> Co-authored-by: Ville Brofeldt <[email protected]> Co-authored-by: ʈᵃᵢ <[email protected]> Co-authored-by: Michael S. Molina <[email protected]> Co-authored-by: mapledan <[email protected]> Co-authored-by: Igor Khrol <[email protected]> Co-authored-by: Rui Zhao <[email protected]> Co-authored-by: Fabien <[email protected]> Co-authored-by: Hugh A. Miles II <[email protected]> Co-authored-by: OskarNS <[email protected]>
Co-authored-by: Elizabeth Thompson <[email protected]>
Co-authored-by: Elizabeth Thompson <[email protected]>
SUMMARY
Fixing the bug whenever a user is trying to do an overwrite action from permalink state. The main issue is when using a permalink the explore
SaveModaldoesn't properly pass the slice_id to allow the reload of the update chart. To fix this i've added logic to make sure the slice_id is always present before redirecting.Screen.Recording.2023-09-07.at.1.26.31.PM.mov
Related PR: #23627
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION