-
Notifications
You must be signed in to change notification settings - Fork 2.7k
MM 20547 user settings security ts #6216
MM 20547 user settings security ts #6216
Conversation
Hey @sridhar02, Thanks for your contribution. Heads up that CI failed with an type check error. You can find the logs here. Let me know if you need help resolving the error. |
bb5ebf1
to
84670aa
Compare
This PR has been automatically labelled "stale" because it hasn't had recent activity. /cc @jasonblais @jfrerich |
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 :)
Thanks @sridhar02 for the contribution! Let us know if we can with the type check error reported by our CI build. You can find the logs here. We'd be happy to help :) |
@jasonblais I am busy with some other work, so I was not able to do this, so I will complete it a week or two.If I need I will mention in this PR |
84670aa
to
f024dc1
Compare
@sridhar02 Heads up that CI is failing with https://app.circleci.com/pipelines/github/mattermost/mattermost-webapp/25391/workflows/0c4d5ec4-c3ec-4aeb-bc13-a3c01d3b2916/jobs/165162 |
f024dc1
to
4a940c5
Compare
@hanzei can you help me fixing the type errors in the test file, I am new to testing struggling with it and due to it, I was unable to complete this PR. |
@@ -125,7 +138,7 @@ describe('components/user_settings/display/UserSettingsDisplay', () => { | |||
preventDefault: jest.fn(), | |||
}; | |||
wrapper.setState({authorizedApps: apps}); | |||
wrapper.instance().deauthorizeApp(event); | |||
(wrapper.instance() as UserSettingsSecurity).deauthorizeApp(event); |
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.
You need to update the calls shallow
in this file to explicitly set the type to
const wrapper: ShallowWrapper<any, any, UserSettingsSecurity> = shallow(...
.
With that you can even remove these type cases.
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 have written in this const wrapper: any = shallow(<UserSettingsSecurity {...props}/>)
using this also I am not getting any errors while checking types will that be okay or I need to change it to const wrapper: ShallowWrapper<any, any, UserSettingsSecurity>
?
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 prefer you use ShallowWrapper<any, any, UserSettingsSecurity
but either way is fine.
@devinbinnie I'm not sure how to fix the issues with
|
@hanzei @sridhar02 You'll want to cast |
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 good overall, just had a few comments I'd like you to address.
Thanks for the awesome contribution @sridhar02!
|
||
function mapStateToProps(state, ownProps) { | ||
type 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.
Nit: space between Actions
and =
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.
Resolved
@@ -48,7 +62,7 @@ describe('components/user_settings/display/UserSettingsDisplay', () => { | |||
enableOAuthServiceProvider: true, | |||
}; | |||
|
|||
const wrapper = shallow(<UserSettingsSecurity {...props}/>); | |||
const wrapper: any = shallow(<UserSettingsSecurity {...props}/>); |
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 can actually be of type ShallowWrapper<any, any, UserSettingsSecurity>
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.
Resolved
@@ -65,48 +79,64 @@ describe('components/user_settings/display/UserSettingsDisplay', () => { | |||
enableOAuthServiceProvider: true, | |||
}; | |||
|
|||
const wrapper = shallow(<UserSettingsSecurity {...props}/>); | |||
const wrapper: any = shallow(<UserSettingsSecurity {...props}/>); |
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 with this one
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.
Resolved
currentPassword: string; | ||
newPassword: string; | ||
confirmPassword: string; | ||
passwordError: React.ReactNode | string; |
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.
string
is part of React.ReactNode
so you shouldn't need this as a union type.
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.
Resolved
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! Added a couple non-blocking comments but that's all.
Thanks again @sridhar02!
}); | ||
|
||
test('submitPassword() should not have called updateUserPassword', async () => { | ||
const wrapper = shallow(<UserSettingsSecurity {...requiredProps}/>); | ||
|
||
await wrapper.instance().submitPassword(); | ||
await (wrapper.instance() as UserSettingsSecurity).submitPassword(); |
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 use the same type as we added above, you can avoid this cast here.
@@ -125,7 +138,7 @@ describe('components/user_settings/display/UserSettingsDisplay', () => { | |||
preventDefault: jest.fn(), | |||
}; | |||
wrapper.setState({authorizedApps: apps}); | |||
wrapper.instance().deauthorizeApp(event); | |||
(wrapper.instance() as UserSettingsSecurity).deauthorizeApp(event); |
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 prefer you use ShallowWrapper<any, any, UserSettingsSecurity
but either way is fine.
@jgilliam17 A smote test around the security setting should be enough. |
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.
Thank you @sridhar02
Tested, looks good to merge.
- Tested User Security Settings, works as expected (password edits, sign in, access history, view/log out of active sessions)
@hanzei Can you please help merge? Thank you 🙂
Test server destroyed |
…o MM-20457 * 'master' of github.com:Tak-Iwamoto/mattermost-webapp: [MM-28680] fix blank page on undefined message (mattermost#6450) MM-28733 : Admin Advisor v2 (mattermost#6461) MM 20547 user settings security ts (mattermost#6216) MM-20904 Add E2E tests for custom categories (mattermost#5981) Update NOTICE.txt (mattermost#6550) Check if emojiMap is undefined before invoking method for it (mattermost#6495) [MM-28151] Cypress/E2E: Automate backlogs - System Console > User Password (mattermost#6538) [MM-28295] e2e/messaging/reactions: add reactions spec (mattermost#6535) [MM-28706] revert ordering change for `in:` auto-suggest search results (mattermost#6493) Remove usage of t function with useIntl (mattermost#6552) MM-28992 Remove unused notPresent and mustBePresent props from MultiSelectSetting (mattermost#6544) MM-27530 Fix for Multiselect items not scrolling into view on arrow keys (mattermost#6286) Demoting failed test from prod (mattermost#6534) migrate show_more to typescript (mattermost#6501) [MM-28878] Revert style change to remove next steps arrow (mattermost#6527) [MM-28972] Added 'Always On' option for new sidebar (mattermost#6530) MM-28839 Fix for hover of cursor on indicators (mattermost#6524) [MM-28790] allow plugins to open in a different tab (mattermost#6476) MM-28290 Always update team member unread counts when added to a channel (mattermost#6500)
…o MM-20462 * 'master' of github.com:Tak-Iwamoto/mattermost-webapp: fix getType is not a function (mattermost#6566) MM-29028 Remove findDOMNode from Slack import (mattermost#6554) MM-28997 Remove references to old context API (mattermost#6545) Add custom slash command tests (mattermost#6391) Cypress/E2E: Fix guest experience ui spec (mattermost#6563) [MM-28784] Migrate string refs to functional ones (mattermost#6494) [MM-28680] fix blank page on undefined message (mattermost#6450) MM-28733 : Admin Advisor v2 (mattermost#6461) MM 20547 user settings security ts (mattermost#6216) MM-20904 Add E2E tests for custom categories (mattermost#5981) Update NOTICE.txt (mattermost#6550) Check if emojiMap is undefined before invoking method for it (mattermost#6495) [MM-28151] Cypress/E2E: Automate backlogs - System Console > User Password (mattermost#6538) [MM-28295] e2e/messaging/reactions: add reactions spec (mattermost#6535) [MM-28706] revert ordering change for `in:` auto-suggest search results (mattermost#6493) Remove usage of t function with useIntl (mattermost#6552) MM-28992 Remove unused notPresent and mustBePresent props from MultiSelectSetting (mattermost#6544) MM-27530 Fix for Multiselect items not scrolling into view on arrow keys (mattermost#6286) Demoting failed test from prod (mattermost#6534)
* convert files to ts and resolved type errors * resolve type errors * resolved type errors * resolved type errors * type errors resolved * resolved type errors * resolved test type errors * type errors * type errors fix * fix lint error * resolved type errors * Resolved type errors * resolved comments
* convert files to ts and resolved type errors * resolve type errors * resolved type errors * resolved type errors * type errors resolved * resolved type errors * resolved test type errors * type errors * type errors fix * fix lint error * resolved type errors * Resolved type errors * resolved comments
Summary
Migrate 'components/user_settings/security' module and associated tests to TypeScript
Ticket Link
Fixes mattermost/mattermost#13694