-
Notifications
You must be signed in to change notification settings - Fork 13.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(chart): chart updates are not retained #23627
fix(chart): chart updates are not retained #23627
Conversation
Codecov Report
@@ Coverage Diff @@
## master #23627 +/- ##
===========================================
+ Coverage 53.58% 67.96% +14.37%
===========================================
Files 1938 1925 -13
Lines 74957 74390 -567
Branches 8140 8109 -31
===========================================
+ Hits 40167 50556 +10389
+ Misses 32706 21762 -10944
+ Partials 2084 2072 -12
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 381 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
3db7ce8
to
334c84e
Compare
c1d6ede
to
66537cb
Compare
expect(fetchMock.calls(exploreApiRoute).length).toBe(1), | ||
); | ||
expect(getByTestId('mock-explore-view-container')).toBeInTheDocument(); | ||
expect(store.getActions()).toContainEqual({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@justinpark React Testing Library has a different view on how to write tests. One of its main concerns is accessibility. It differs from Enzyme in the sense that it's more focused on how the user interacts with the app rather then implementation details. Check this quote from their site:
You want to write maintainable tests that give you high confidence that your components are working for your users. As a part of this goal, you want your tests to avoid including implementation details so refactors of your components (changes to implementation but not functionality) don't break your tests and slow you and your team down.
In your case, you could write tests that check if the "Show cell bars" is checked rather then test if an specific Redux action is fired. This will make your tests more durable in a scenario where the implementation details change, such as the redux action name, or the action structure, but the interface, and the way users interact with it, remain the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michael-s-molina I updated the test code as you suggested. (but using partial rendering since full ChartContainer requires a lot of dependancies)
|
||
import { JsonObject } from '@superset-ui/core'; | ||
|
||
export const getExploreFormData = (overrides: JsonObject = {}) => ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice improvement to extract the mock.
...overrides, | ||
}); | ||
|
||
export const getDashboardFormData = (overrides: JsonObject = {}) => ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be in its own file? Could this be used by another test that is not inside Explore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I will change this mock function location
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michael-s-molina could you review the PR again?
66537cb
to
2c12c6c
Compare
2c12c6c
to
e1f439d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
e1f439d
to
93a9b4c
Compare
@rusackas could you help to stamp this PR to release the blocker? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving cypress mods as code owner
(cherry picked from commit f5b1711)
(cherry picked from commit f5b1711)
SUMMARY
When a table chart saved on a dashboard and edited from the dashboard, the table reloads in the edit view and the updated option returns to the previous setting.
This bug is a regression of #20498, which reloads the fetchExploreData but always overrides it with the dashboardContext (which retains the original settings).
This hotfix adds the condition of overwrite saving to retrieve the changes from updated exploreFormData.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
after--retained-hotfix.mov
before--retained-hotfix.mov
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION
cc: @michael-s-molina @ktmud cc: @john-bodley