-
Notifications
You must be signed in to change notification settings - Fork 19
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
Migrate to RTK Query #553
base: main
Are you sure you want to change the base?
Migrate to RTK Query #553
Conversation
d2f14cc
to
5b4e295
Compare
a5f3ee1
to
8e06b0f
Compare
f9ebdd3
to
cd3d768
Compare
src/api/hooks/useGetAggregations.js
Outdated
@@ -0,0 +1,16 @@ | |||
import { useGetAggregationsQuery } from '../complaints/complaints'; |
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.
First off, I love that the API calls are now being implemented in hooks, which makes for more reusable functionality and smaller components. But I did notice that there is another hooks folder at src/hooks. Should we just have all our hooks in one place, at src/hooks? Then you could have a breakout of subfolders named api, etc.
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.
Yeah, i thought about this, I originally had it under the hooks folder, but I moved them here to keep them closer to the RTKQ API
src/utils/chart.js
Outdated
const parts = tooltip.title.split(':'); | ||
newTooltip.values = cloneDeep(tooltip.values); |
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.
Do we still need cloneDeep
as much, now that we can use mutable functionality through Redux Toolkit? Does the following work as expected for line 238?
newTooltip.values = cloneDeep(tooltip.values); | |
newTooltip.values = {...tooltip.values}; |
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.
That was giving an error since tooltip.values is an Array. I went ahead and switched it over to structuredClone and added a global polyfill in setupTests.js
// const newObj = { ...obj }; | ||
if (!Object.hasOwn(obj, 'colorIndex')) { | ||
obj.colorIndex = | ||
Object.values(colors.DataLens).indexOf(colorMap[obj.name]) || 0; |
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.
CouldObject.values(color.DataLens)
be put into a variable prior to the for loop at line 239? It just seems like calling Object.values
in a multiple times in a loop could affect performance, even in in a minor way.
Object.values(colors.DataLens).indexOf(colorMap[obj.name]) || 0; | |
const values = Object.values(colors.DataLens); | |
... | |
values.indexOf(colorMap[obj.name]) || 0; |
@@ -456,4 +457,23 @@ export function removeNullProperties(object) { | |||
} | |||
return acc; | |||
}, {}); | |||
|
|||
for (const key in myObject) { |
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.
Not sure if this would work, but it would be easier to read and follow. You could also chain it to line 449.
for (const key in myObject) { | |
Object.keys(myObject).filter(key => { | |
return !(Array.isArray(key) && key.length === 0) | |
}); |
@@ -6,12 +6,9 @@ import trends, { | |||
depthReset, | |||
focusChanged, | |||
focusRemoved, | |||
getDefaultState, | |||
mainNameLens, | |||
// getDefaultState, |
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.
Since lines 9 and 11 are commented, they can be removed
renderComponent(ownProps, aggs, filters); | ||
|
||
renderComponent(ownProps, filters); | ||
await screen.findByRole('checkbox'); | ||
expect(screen.getByRole('checkbox')).not.toBeChecked(); |
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.
Same as above. Can the checkbox be moved to a variable?
}); | ||
}); | ||
}); | ||
// describe('COMPLAINTS_RECEIVED actions', () => { |
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.
Can this commented code be deleted?
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.
That reminds me, I commented out these tests since these need to be moved over to validate the API.
}, | ||
); | ||
|
||
await screen.findByRole('button', { name: 'Show less' }); |
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.
Can button be used in one variable across both lines 118 and 119?
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.
This is intentional, this case, await returns a Promise and we use it here to allow the button to render asynchronously.
Normally in Cypress tests we're not supposed to be saving the selectors in a variable. They don't recommend it.
This is one of the primary reasons why we do not recommend using variables within your tests.
https://learn.cypress.io/cypress-fundamentals/understanding-the-asynchronous-nature-of-cypress
Typically I prefer to have the screen.getBy calls repeated explicitly instead of saving it in a variable because if the DOM somehow changes, each screen.getBy call is a new call to check the document instead of having a saved variable.
src/components/Trends/TrendDepthToggle/TrendDepthToggle.spec.js
Outdated
Show resolved
Hide resolved
src/components/Trends/TrendDepthToggle/TrendDepthToggle.spec.js
Outdated
Show resolved
Hide resolved
In addition to the feedback provided in each file, please also make sure to update the Cypress tests accordingly (if needed). When I tried running |
test update, restore detail slice temporary to test something remove detail slice working aggregations query standardize fetch aggs into single hook remove aggsslice remove queryManager middleware cleanup, remove more stuff working map tab logic to disable query hook remove message middleware list view working cleanup, passing query params to api so we can extract to transformResponse Save work save work move color map to api remove query manager things missing dep more loogic to prevent query from firing when not initialized working pagination, moved breakpoints to API, and passing them through pagination component remove breakpoints from querySlice cleanup remove persist clean up comments and errors complaint detail test updates save work, clearing out URL unused clode cleanup querySlice tests updated trends test fixes tile map test squash lines add prettier ignore file updating tests, refactor product save. working tests for Company filter refactor update dist fixing pill test issue test fix restructure files restore update tests save some work trend depth toggle unit test squash moved files focus header test fixes? save stuff searchpanel fix fixing pagination unit tests fixing app.spec test unit test actionbar aggregation item test condense aggregation item test aggregation item test trends panel tests print info tests move file unit test :( working map panel test simple filter fix data export unit test row test tour test line chart test unit test fixes delete detail test for redux store update unit tests test coverage update tests, fix condition causing url to not synch properly when copy/pasting url fix cypress tests fix url req call move api hooks to folder update dist update dist
cfc89ca
to
ea8a216
Compare
The tests were updated since some API calls changed. I wasn't seeing this. I can look into it further if you can provide a screenshot. The cypress tests are also running in CI. |
…76-rtk-query-upgrade # Conflicts: # dist/ccdb5.css.map # dist/ccdb5.js # dist/ccdb5.js.map
Additions
Removals
Changes
Testing
Screenshots
Notes
Todos
Checklist