Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

MM-24549 Fix for skipping user info calls for hidden GM's #5398

Merged
merged 7 commits into from
May 18, 2020

Conversation

sudheerDev
Copy link
Contributor

Summary

This PR fixes the issue with making unnecessary calls or members info in GM channels when hidden in LHS. This only skip calls if experimental sidebar settings are turned on

Ticket Link

https://mattermost.atlassian.net/browse/MM-24549

@sudheerDev sudheerDev added 2: Dev Review Requires review by a core commiter 3: QA Review Requires review by a QA tester labels Apr 26, 2020
@sudheerDev sudheerDev added this to the v5.24.0 milestone Apr 26, 2020
@sudheerDev sudheerDev requested review from devinbinnie and removed request for hmhealey April 27, 2020 09:56
@sudheerDev
Copy link
Contributor Author

/update-branch


import * as UserActions from 'actions/user_actions';

const mockStore = configureStore([thunk]);
const mockChannelsObj1 = [{id: 'gmChannel', type: 'G1'}];
Copy link
Member

Choose a reason for hiding this comment

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

If these are supposed to be gm channels, shouldn't those types be using General.GM_CHANNEL? G1 and G2 aren't valid channel types.

Copy link
Contributor Author

@sudheerDev sudheerDev Apr 29, 2020

Choose a reason for hiding this comment

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

It was a mock so it wouldn't have mattered all that much. That wasn't great in the way I had to hack in the first place. I spent quite a lot of time trying to figure out how to pass out of scope variable to mock and there is no way to do that so, I had to resort to writing to variables and checking for that. Honestly, the whole test case is odd. I couldn't think of a better way to do it.

Copy link
Member

Choose a reason for hiding this comment

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

I'm confused. We're mocking the constants? This test file is a mess, but I didn't know it was that bad.

@bradjcoughlin bradjcoughlin self-requested a review April 30, 2020 16:39
Copy link
Member

@hmhealey hmhealey left a comment

Choose a reason for hiding this comment

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

Can we actually test loadProfilesForGM to ensure that it doesn't load profiles for hidden DMs/GMs? The current tests tell us that it uses the mocked selectors, but it doesn't tell us that calling those selectors prevents the extra requests.

@@ -21,6 +26,19 @@ jest.mock('mattermost-redux/actions/users', () => {
};
});

jest.mock('mattermost-redux/selectors/entities/channel_categories', () => {
Copy link
Member

Choose a reason for hiding this comment

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

In particular, why mock these selectors?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we are calling the selectors then isn't that a good enough test? Selectors are supposed to filter and they have tests to cover that.

Copy link
Member

Choose a reason for hiding this comment

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

The main thing I'm concerned about is that the tests confirm that the code call the selectors, but it doesn't confirm that calling the selectors actually prevents the extra requests. In the end, they both cover the same thing assuming that the selectors work as expected, so while I personally think that testing for the bug would be better, doing it this way is probably fine as well, so 0/5 on whether or not we change it.

@deanwhillier deanwhillier requested a review from hmhealey May 4, 2020 13:03
@deanwhillier
Copy link
Contributor

deanwhillier commented May 4, 2020

Just noting that I've seen this, but am removing myself from review as Devin and Harrison have this. Thanks @sudheerDev!

@deanwhillier deanwhillier removed their request for review May 4, 2020 13:04
@bradjcoughlin bradjcoughlin removed their request for review May 6, 2020 07:16
@jgilliam17 jgilliam17 added the Setup Cloud Test Server Setup a test server using Mattermost Cloud label May 18, 2020
Copy link
Contributor

@jgilliam17 jgilliam17 left a comment

Choose a reason for hiding this comment

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

Thank you @sudheerDev
Unable to test on the PR server as system closed GMs are not present (GMs closed after 7 days with no messages)
QA will test on daily after merge.

@jgilliam17 jgilliam17 added 4: Reviews Complete All reviewers have approved the pull request and removed 3: QA Review Requires review by a QA tester Setup Cloud Test Server Setup a test server using Mattermost Cloud labels May 18, 2020
@mm-cloud-bot
Copy link

Test server destroyed

@sudheerDev sudheerDev removed the 2: Dev Review Requires review by a core commiter label May 18, 2020
@sudheerDev sudheerDev merged commit c9cb999 into mattermost:master May 18, 2020
@sudheerDev sudheerDev deleted the MM-24549 branch May 18, 2020 18:17
@amyblais amyblais added Changelog/Not Needed Does not require a changelog entry Docs/Not Needed Does not require documentation labels May 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
4: Reviews Complete All reviewers have approved the pull request Changelog/Not Needed Does not require a changelog entry Docs/Not Needed Does not require documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants