-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add microsoft teams support Signed-off-by: zhichao-aws <[email protected]> * microsoft teams unit test Signed-off-by: yuye-aws <[email protected]> * microsoft teams cypress test Signed-off-by: yuye-aws <[email protected]> * add snapshot for microsoft teams unit test Signed-off-by: yuye-aws <[email protected]> * add mockdata for microsoft teams unit test Signed-off-by: yuye-aws <[email protected]> * fix cypress mock teams url Signed-off-by: zhichao-aws <[email protected]> * extend pageload timeout for cy.visit Signed-off-by: zhichao-aws <[email protected]> --------- Signed-off-by: zhichao-aws <[email protected]> Signed-off-by: yuye-aws <[email protected]> Co-authored-by: yuye-aws <[email protected]>
- Loading branch information
1 parent
a108290
commit 5903c27
Showing
16 changed files
with
399 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"config": { | ||
"name": "Test microsoft teams channel", | ||
"description": "A test microsoft teams channel", | ||
"config_type": "microsoft_teams", | ||
"is_enabled": true, | ||
"microsoft_teams": { | ||
"url": "https://testdomain.webhook.office.com/123" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
public/pages/CreateChannel/__tests__/MicrosoftTeamsSettings.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { fireEvent, render } from '@testing-library/react'; | ||
import { configure } from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
import React from 'react'; | ||
import { MicrosoftTeamsSettings } from '../components/MicrosoftTeamsSettings'; | ||
import { CreateChannelContext } from '../CreateChannel'; | ||
|
||
describe('<MicrosoftTeamsSettings /> spec', () => { | ||
configure({ adapter: new Adapter() }); | ||
|
||
it('renders the component', () => { | ||
const setMicrosoftTeamsWebhook = jest.fn(); | ||
const utils = render( | ||
<CreateChannelContext.Provider | ||
value={{ | ||
edit: false, | ||
inputErrors: { microsoftTeamsWebhook: [] }, | ||
setInputErrors: jest.fn(), | ||
}} | ||
> | ||
<MicrosoftTeamsSettings | ||
microsoftTeamsWebhook="test webhook" | ||
setMicrosoftTeamsWebhook={setMicrosoftTeamsWebhook} | ||
/> | ||
</CreateChannelContext.Provider> | ||
); | ||
expect(utils.container.firstChild).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders the component with error', () => { | ||
const setMicrosoftTeamsWebhook = jest.fn(); | ||
const utils = render( | ||
<CreateChannelContext.Provider | ||
value={{ | ||
edit: false, | ||
inputErrors: { microsoftTeamsWebhook: ['test error'] }, | ||
setInputErrors: jest.fn(), | ||
}} | ||
> | ||
<MicrosoftTeamsSettings | ||
microsoftTeamsWebhook="test webhook" | ||
setMicrosoftTeamsWebhook={setMicrosoftTeamsWebhook} | ||
/> | ||
</CreateChannelContext.Provider> | ||
); | ||
expect(utils.container.firstChild).toMatchSnapshot(); | ||
}); | ||
|
||
it('changes input', () => { | ||
const setMicrosoftTeamsWebhook = jest.fn(); | ||
const setInputErrors = jest.fn(); | ||
const utils = render( | ||
<CreateChannelContext.Provider | ||
value={{ | ||
edit: false, | ||
inputErrors: { microsoftTeamsWebhook: [] }, | ||
setInputErrors, | ||
}} | ||
> | ||
<MicrosoftTeamsSettings | ||
microsoftTeamsWebhook="test webhook" | ||
setMicrosoftTeamsWebhook={setMicrosoftTeamsWebhook} | ||
/> | ||
</CreateChannelContext.Provider> | ||
); | ||
const input = utils.getByLabelText('Webhook URL'); | ||
fireEvent.change(input, { target: { value: 'https://test-microsoftTeams-url' } }); | ||
fireEvent.blur(input); | ||
expect(setMicrosoftTeamsWebhook).toBeCalledWith('https://test-microsoftTeams-url'); | ||
expect(setInputErrors).toBeCalled(); | ||
}); | ||
}); |
Oops, something went wrong.