-
Notifications
You must be signed in to change notification settings - Fork 386
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
Bug Fix: Renaming already uploaded profile #2810 #2843
Conversation
5326a5f
to
5042e9e
Compare
Codecov Report
@@ Coverage Diff @@
## main #2843 +/- ##
=======================================
Coverage 88.32% 88.33%
=======================================
Files 241 241
Lines 19126 19138 +12
Branches 4893 4896 +3
=======================================
+ Hits 16893 16905 +12
Misses 2070 2070
Partials 163 163
Continue to review full report at Codecov.
|
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.
Thanks, this looks quite solid to me!
I just left 2 or 3 suggestions, but I think this will be good to go after this. Thanks again!
src/actions/profile-view.js
Outdated
const hash = getHash(getState()); | ||
const storedProfile = await retrieveProfileData(hash); | ||
if (storedProfile && storedProfile.name !== profileName) { | ||
(storedProfile: any).name = profileName; |
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.
Instead of using any
it's a good idea to work in a "immutable" way. In this case this is as easy as :
const newProfileData = {
...storedProfile,
name: profileName,
};
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.
Fixed it based on your comments. Thanks
const newUrlState = stateFromLocation({ | ||
pathname: `/public/FAKE_1234/marker-chart/`, | ||
search: '', | ||
hash: '', | ||
}); | ||
store.dispatch({ | ||
type: 'UPDATE_URL_STATE', | ||
newUrlState, | ||
}); |
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.
I'm just wondering why that part is needed :-) can you please explain this? If that's not needed just remove it please!
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.
Suggestion: maybe that's because you're testing UploadedRecordingsHome
, maybe you should test ListOfPublishedProfiles
instead?
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 we are using const hash = getHash(getState());
in the changeProfileName action, It is giving hash as null untill we do above UPDATE_URL_STATE action
it('can rename stored profiles', async () => { | ||
// Store a single profile that we will rename. The data inside is mostly | ||
// arbirtrary except the "name" field. | ||
// mockDate('4 Jul 2020 15:00'); |
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.
I'd suggest to keep the mock, so that we don't have subtle problems later.
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.
Still there^
await storeProfileData({ | ||
profileToken: 'FAKE_1234', | ||
jwtToken: null, | ||
publishedDate: new Date('4 Jul 2020 13:00'), // This is the future! | ||
name: 'Initial Profile Name', | ||
preset: null, | ||
originHostname: 'https://mozilla.org', | ||
meta: { | ||
product: 'Firefox', | ||
platform: 'Macintosh', | ||
toolkit: 'cocoa', | ||
misc: 'rv:62.0', | ||
oscpu: 'Intel Mac OS X 10.12', | ||
}, | ||
urlPath: '/public/FAKE_1234/marker-chart/', | ||
publishedRange: { start: 2000, end: 40000 }, | ||
}); |
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.
If you move this test to ListOfPublishedProfiles.test.js
you can reuse listOfProfileInformations
, for example:
const profileData = {
...listOfProfileInformations[0],
name: 'XXXX',
};
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.
I still think this should be moved to ListOfPublishedProfiles.test.js
for simplicity...
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.
Thanks for your changes and explanations.
Here are a few more comments, mostly moving things around to make it more understandable. But I think we're getting really close. Thanks again!
src/actions/profile-view.js
Outdated
@@ -1357,12 +1357,15 @@ export function changeProfileName( | |||
profileName: string | null | |||
): ThunkAction<Promise<void>> { | |||
return async (dispatch, getState) => { | |||
if (window.indexedDB) { | |||
if (window.indexedDB && profileName) { |
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.
If profileName is null or empty, we should still store a blank string, otherwise we won't be able to remove it.
it('can rename stored profiles', async () => { | ||
// Store a single profile that we will rename. The data inside is mostly | ||
// arbirtrary except the "name" field. | ||
// mockDate('4 Jul 2020 15:00'); |
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.
Still there^
await storeProfileData({ | ||
profileToken: 'FAKE_1234', | ||
jwtToken: null, | ||
publishedDate: new Date('4 Jul 2020 13:00'), // This is the future! | ||
name: 'Initial Profile Name', | ||
preset: null, | ||
originHostname: 'https://mozilla.org', | ||
meta: { | ||
product: 'Firefox', | ||
platform: 'Macintosh', | ||
toolkit: 'cocoa', | ||
misc: 'rv:62.0', | ||
oscpu: 'Intel Mac OS X 10.12', | ||
}, | ||
urlPath: '/public/FAKE_1234/marker-chart/', | ||
publishedRange: { start: 2000, end: 40000 }, | ||
}); |
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.
I still think this should be moved to ListOfPublishedProfiles.test.js
for simplicity...
const newUrlState = stateFromLocation({ | ||
pathname: `/public/FAKE_1234/marker-chart/`, | ||
search: '', | ||
hash: '', | ||
}); | ||
store.dispatch(updateUrlState(newUrlState)); | ||
|
||
await store.dispatch(changeProfileName('My Profile Name')); |
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.
Thanks for the explanation!
To have a better test and easier to maintain, I believe we should have 2 different stores (to simulate 2 different pages):
- store 1 for the list of recordings => a
blankStore
is fine for that one. - store 2 for the profile viewer => you can use
blankStore
+ dispatch the url state change for this one like you already did, and dispatch the profile name change on this store.
hey @GrooChu , are you still interested in finishing this patch? thanks :-) |
d3a1f28
to
83d09b9
Compare
Hey @canova, I've moved forward and fixed my last issues in this patch. Would you be kind enough to look at it? Here is the STR I was looking at:
Thanks! update 1: I realized I missed something: after renaming, when opening the link, we still have the old profile name. |
83d09b9
to
8ef4c06
Compare
…use 2 different stores
8ef4c06
to
7a49a97
Compare
I implemented the changes myself and waiting for a review from another team member.
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.
Looks pretty good to me, thanks for working on it!
* This stores some profile data. The profileToken property is the primary key, | ||
* so this also updates any profile data already there with the same | ||
* profileToken information. | ||
*/ |
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.
Thanks for adding comments to the functions! It helped me to figure out about updating profile data with same profileToken
information.
|
PR for issue #2809
update the action
changeProfileName
to retrieve the profile and update the profile name. I have the tested the changes and it works fine without any issue.Fixes #2809