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
[MM-57726] Convert AddIncomingWebhook from Class Component to Function Component #26992
Conversation
@MeHow25: Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. I understand the commands that are listed here |
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.
Great work! One minor change, and a question.
@@ -26,16 +63,29 @@ describe('components/integrations/AddIncomingWebhook', () => { | |||
}); | |||
|
|||
test('should have called createIncomingHook', () => { | |||
const hook = TestHelper.getIncomingWebhookMock({ | |||
channel_id: 'channel_id', | |||
const hook = { |
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.
Why do we remove the call to the TestHelper?
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 call was returning an object with some additional properties like create_at
or delete_at
that I assumed they are not relevant in this test. Do you think this call should stay?
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 I am not mistaken, it should stay, yes. The idea of this call is to mock the default values so it looks like the object you would naturally receive out in the wild. If those extra values are creating any issue in terms of types or anything, we can look a bit deeper why that is, but it is better if we use it.
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.
Ok, I get it :) I've added these additional properties. Now the test is comparing whole objects, and it seems to work 👍.
|
||
addIncomingHook = async (hook: IncomingWebhook) => { | ||
this.setState({serverError: ''}); | ||
const addIncomingHook = async (hook: IncomingWebhook) => { |
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.
Let's use a useCallback
so we don't pass a new function on every render.
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.
Done
Not triggering E2E tests: this PR has 2 commit status(es) or check-runs that are not passing. Ensure all statuses aside from the E2E testing ones are green, before triggering E2E tests. |
/release-note-none |
/update-branch |
/e2e-tests |
E2E test triggered successfully for PR #26992. The corresponding commit's status check will be available shortly. |
E2E test run is starting for commit
|
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.
adding incoming webhook is working as expected.
Test server destroyed |
Test server destroyed |
Summary
Convert AddIncomingWebhook from Class Component to Function Component
Ticket Link
Fixes #26694
Jira https://mattermost.atlassian.net/browse/MM-57726
Release Note