Skip to content
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

Merged
merged 8 commits into from
Dec 3, 2020

Conversation

GrooChu
Copy link
Contributor

@GrooChu GrooChu commented Oct 6, 2020

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

@codecov
Copy link

codecov bot commented Oct 7, 2020

Codecov Report

Merging #2843 (51239bd) into main (2695e41) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           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           
Impacted Files Coverage Δ
src/actions/profile-view.js 85.08% <100.00%> (+0.15%) ⬆️
src/app-logic/published-profiles-store.js 88.63% <100.00%> (+2.14%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2695e41...51239bd. Read the comment docs.

Copy link
Contributor

@julienw julienw left a 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!

const hash = getHash(getState());
const storedProfile = await retrieveProfileData(hash);
if (storedProfile && storedProfile.name !== profileName) {
(storedProfile: any).name = profileName;
Copy link
Contributor

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,
};

Copy link
Contributor Author

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

Comment on lines 183 to 191
const newUrlState = stateFromLocation({
pathname: `/public/FAKE_1234/marker-chart/`,
search: '',
hash: '',
});
store.dispatch({
type: 'UPDATE_URL_STATE',
newUrlState,
});
Copy link
Contributor

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!

Copy link
Contributor

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?

Copy link
Contributor Author

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');
Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still there^

Comment on lines 155 to 171
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 },
});
Copy link
Contributor

@julienw julienw Oct 9, 2020

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',
};

Copy link
Contributor

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...

Copy link
Contributor

@julienw julienw left a 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!

@@ -1357,12 +1357,15 @@ export function changeProfileName(
profileName: string | null
): ThunkAction<Promise<void>> {
return async (dispatch, getState) => {
if (window.indexedDB) {
if (window.indexedDB && profileName) {
Copy link
Contributor

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');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still there^

Comment on lines 155 to 171
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 },
});
Copy link
Contributor

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...

Comment on lines 184 to 191
const newUrlState = stateFromLocation({
pathname: `/public/FAKE_1234/marker-chart/`,
search: '',
hash: '',
});
store.dispatch(updateUrlState(newUrlState));

await store.dispatch(changeProfileName('My Profile Name'));
Copy link
Contributor

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.

@julienw
Copy link
Contributor

julienw commented Oct 28, 2020

hey @GrooChu , are you still interested in finishing this patch? thanks :-)

@julienw
Copy link
Contributor

julienw commented Nov 9, 2020

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:

  1. Publish a profile, any profile, from the deploy preview, for example this profile
  2. Open the uploaded recordings view
  3. Open the profile in the list in a new tab
  4. Edit the profile's name from this new tab
  5. Come back to the previous tab => the name should be changed in the list
  6. Come back to the profile viewer tab and clear the name
  7. Come back to the previous tab => the name should be back to default

Thanks!

update 1: I realized I missed something: after renaming, when opening the link, we still have the old profile name.
update 2: This is now ready again. I added some more commits to fix this, and also adding analytics for this feature. It could be a good idea to look at individual commits before looking at the big picture.

@julienw julienw requested review from canova and removed request for canova November 9, 2020 16:38
@julienw julienw requested a review from canova November 10, 2020 14:12
@julienw julienw dismissed their stale review November 10, 2020 14:12

I implemented the changes myself and waiting for a review from another team member.

Copy link
Member

@canova canova left a 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.
*/
Copy link
Member

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.

@julienw
Copy link
Contributor

julienw commented Dec 3, 2020

update 1: I realized I missed something: after renaming, when opening the link, we still have the old profile name.

I'm confused, this seems to still be a problem...
ah nope, I had an old entry from before the fix.

@julienw julienw merged commit 767aa2f into firefox-devtools:main Dec 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Renaming an already uploaded profile should also rename it in the "uploaded recordings" page
3 participants