level_0
int64
0
10k
index
int64
0
0
repo_id
stringlengths
22
152
file_path
stringlengths
41
203
content
stringlengths
11
11.5M
2,301
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/global_header/center_controls
petrpan-code/mattermost/mattermost/webapp/channels/src/components/global_header/center_controls/global_search_nav/global_search_nav.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import * as redux from 'react-redux'; import mockStore from 'tests/test_store'; import GlobalSearchNav from './global_search_nav'; describe('components/GlobalSearchNav', () => { const store = mockStore({}); jest.spyOn(React, 'useEffect').mockImplementation(() => {}); test('should match snapshot with active flagged posts', () => { const spy = jest.spyOn(redux, 'useSelector'); spy.mockReturnValue({rhsState: 'flag'}); spy.mockReturnValue({isRhsOpen: true}); const wrapper = shallow( <redux.Provider store={store}> <GlobalSearchNav/> </redux.Provider>, ); expect(wrapper).toMatchSnapshot(); }); test('should match snapshot with active mentions posts', () => { const spy = jest.spyOn(redux, 'useSelector'); spy.mockReturnValue({rhsState: 'mentions'}); spy.mockReturnValue({isRhsOpen: 'true'}); const wrapper = shallow( <redux.Provider store={store}> <GlobalSearchNav/> </redux.Provider>, ); expect(wrapper).toMatchSnapshot(); }); });
2,303
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/global_header/center_controls/global_search_nav
petrpan-code/mattermost/mattermost/webapp/channels/src/components/global_header/center_controls/global_search_nav/__snapshots__/global_search_nav.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/GlobalSearchNav should match snapshot with active flagged posts 1`] = ` <ContextProvider value={ Object { "store": Object { "clearActions": [Function], "dispatch": [Function], "getActions": [Function], "getState": [Function], "replaceReducer": [Function], "subscribe": [Function], }, "subscription": Subscription { "handleChangeWrapper": [Function], "listeners": Object { "notify": [Function], }, "onStateChange": [Function], "parentSub": undefined, "store": Object { "clearActions": [Function], "dispatch": [Function], "getActions": [Function], "getState": [Function], "replaceReducer": [Function], "subscribe": [Function], }, "unsubscribe": null, }, } } > <GlobalSearchNav /> </ContextProvider> `; exports[`components/GlobalSearchNav should match snapshot with active mentions posts 1`] = ` <ContextProvider value={ Object { "store": Object { "clearActions": [Function], "dispatch": [Function], "getActions": [Function], "getState": [Function], "replaceReducer": [Function], "subscribe": [Function], }, "subscription": Subscription { "handleChangeWrapper": [Function], "listeners": Object { "notify": [Function], }, "onStateChange": [Function], "parentSub": undefined, "store": Object { "clearActions": [Function], "dispatch": [Function], "getActions": [Function], "getState": [Function], "replaceReducer": [Function], "subscribe": [Function], }, "unsubscribe": null, }, } } > <GlobalSearchNav /> </ContextProvider> `;
2,305
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/global_header/center_controls
petrpan-code/mattermost/mattermost/webapp/channels/src/components/global_header/center_controls/user_guide_dropdown/user_guide_dropdown.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import React from 'react'; import {trackEvent} from 'actions/telemetry_actions.jsx'; import Menu from 'components/widgets/menu/menu'; import MenuWrapper from 'components/widgets/menu/menu_wrapper'; import {shallowWithIntl} from 'tests/helpers/intl-test-helper'; import UserGuideDropdown from './user_guide_dropdown'; jest.mock('actions/telemetry_actions.jsx', () => { const original = jest.requireActual('actions/telemetry_actions.jsx'); return { ...original, trackEvent: jest.fn(), }; }); describe('components/channel_header/components/UserGuideDropdown', () => { const baseProps = { helpLink: 'helpLink', isMobileView: false, reportAProblemLink: 'reportAProblemLink', enableAskCommunityLink: 'true', location: { pathname: '/team/channel/channelId', }, teamUrl: '/team', actions: { openModal: jest.fn(), }, pluginMenuItems: [], isFirstAdmin: false, onboardingFlowEnabled: false, }; test('should match snapshot', () => { const wrapper = shallowWithIntl( <UserGuideDropdown {...baseProps}/>, ); expect(wrapper).toMatchSnapshot(); }); test('should match snapshot for false of enableAskCommunityLink', () => { const props = { ...baseProps, enableAskCommunityLink: 'false', }; const wrapper = shallowWithIntl( <UserGuideDropdown {...props}/>, ); expect(wrapper).toMatchSnapshot(); }); test('should match snapshot when have plugin menu items', () => { const props = { ...baseProps, pluginMenuItems: [{id: 'testId', pluginId: 'testPluginId', text: 'Test Item', action: () => {}}, ], }; const wrapper = shallowWithIntl( <UserGuideDropdown {...props}/>, ); expect(wrapper).toMatchSnapshot(); }); test('Should set state buttonActive on toggle of MenuWrapper', () => { const wrapper = shallowWithIntl( <UserGuideDropdown {...baseProps}/>, ); expect(wrapper.state('buttonActive')).toBe(false); wrapper.find(MenuWrapper).prop('onToggle')!(true); expect(wrapper.state('buttonActive')).toBe(true); }); test('Should set state buttonActive on toggle of MenuWrapper', () => { const wrapper = shallowWithIntl( <UserGuideDropdown {...baseProps}/>, ); wrapper.find(Menu.ItemAction).find('#keyboardShortcuts').prop('onClick')!({preventDefault: jest.fn()} as unknown as React.MouseEvent); expect(baseProps.actions.openModal).toHaveBeenCalled(); }); test('Should call for track event on click of askTheCommunityLink', () => { const wrapper = shallowWithIntl( <UserGuideDropdown {...baseProps}/>, ); wrapper.find(Menu.ItemExternalLink).find('#askTheCommunityLink').prop('onClick')!({} as unknown as React.MouseEvent); expect(trackEvent).toBeCalledWith('ui', 'help_ask_the_community'); }); test('should have plugin menu items appended to the menu', () => { const props = { ...baseProps, pluginMenuItems: [{id: 'testId', pluginId: 'testPluginId', text: 'Test Plugin Item', action: () => {}}, ], }; const wrapper = shallowWithIntl( <UserGuideDropdown {...props}/>, ); // pluginMenuItems are appended, so our entry must be the last one. const pluginMenuItem = wrapper.find(Menu.ItemAction).last(); expect(pluginMenuItem.prop('text')).toEqual('Test Plugin Item'); }); test('should only render Report a Problem link when its value is non-empty', () => { const wrapper = shallowWithIntl( <UserGuideDropdown {...baseProps}/>, ); expect(wrapper.find('#reportAProblemLink').exists()).toBe(true); wrapper.setProps({ reportAProblemLink: '', }); expect(wrapper.find('#reportAProblemLink').exists()).toBe(false); }); });
2,307
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/global_header/center_controls/user_guide_dropdown
petrpan-code/mattermost/mattermost/webapp/channels/src/components/global_header/center_controls/user_guide_dropdown/__snapshots__/user_guide_dropdown.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/channel_header/components/UserGuideDropdown should match snapshot 1`] = ` <MenuWrapper animationComponent={[Function]} className="userGuideHelp" id="helpMenuPortal" onToggle={[Function]} > <OverlayTrigger defaultOverlayShown={false} delayShow={500} overlay={ <Tooltip className="hidden-xs" id="userGuideHelpTooltip" > <Memo(MemoizedFormattedMessage) defaultMessage="Help" id="channel_header.userHelpGuide" /> </Tooltip> } placement="bottom" trigger={ Array [ "hover", "focus", ] } > <ForwardRef active={false} aria-controls="AddChannelDropdown" aria-expanded={false} aria-label="Help" compact={true} icon="help-circle-outline" inverted={true} onClick={[Function]} size="sm" /> </OverlayTrigger> <Menu ariaLabel="Add Channel Dropdown" id="AddChannelDropdown" openLeft={false} openUp={false} > <Memo(MenuGroup)> <MenuItemExternalLink iconClassName="icon-file-text-outline" id="mattermostUserGuideLink" show={true} text="Mattermost user guide" url="https://docs.mattermost.com/guides/use-mattermost.html" /> <MenuItemExternalLink iconClassName="icon-lightbulb-outline" id="trainingResourcesLink" show={true} text="Training resources" url="https://academy.mattermost.com/" /> <MenuItemExternalLink iconClassName="icon-help" id="askTheCommunityLink" onClick={[Function]} show={true} text="Ask the community" url="https://mattermost.com/pl/default-ask-mattermost-community/" /> <MenuItemExternalLink iconClassName="icon-alert-outline" id="reportAProblemLink" show={true} text="Report a problem" url="reportAProblemLink" /> <MenuItemAction iconClassName="icon-keyboard-return" id="keyboardShortcuts" onClick={[Function]} show={true} text="Keyboard shortcuts" /> </Memo(MenuGroup)> </Menu> </MenuWrapper> `; exports[`components/channel_header/components/UserGuideDropdown should match snapshot for false of enableAskCommunityLink 1`] = ` <MenuWrapper animationComponent={[Function]} className="userGuideHelp" id="helpMenuPortal" onToggle={[Function]} > <OverlayTrigger defaultOverlayShown={false} delayShow={500} overlay={ <Tooltip className="hidden-xs" id="userGuideHelpTooltip" > <Memo(MemoizedFormattedMessage) defaultMessage="Help" id="channel_header.userHelpGuide" /> </Tooltip> } placement="bottom" trigger={ Array [ "hover", "focus", ] } > <ForwardRef active={false} aria-controls="AddChannelDropdown" aria-expanded={false} aria-label="Help" compact={true} icon="help-circle-outline" inverted={true} onClick={[Function]} size="sm" /> </OverlayTrigger> <Menu ariaLabel="Add Channel Dropdown" id="AddChannelDropdown" openLeft={false} openUp={false} > <Memo(MenuGroup)> <MenuItemExternalLink iconClassName="icon-file-text-outline" id="mattermostUserGuideLink" show={true} text="Mattermost user guide" url="https://docs.mattermost.com/guides/use-mattermost.html" /> <MenuItemExternalLink iconClassName="icon-lightbulb-outline" id="trainingResourcesLink" show={true} text="Training resources" url="https://academy.mattermost.com/" /> <MenuItemExternalLink iconClassName="icon-alert-outline" id="reportAProblemLink" show={true} text="Report a problem" url="reportAProblemLink" /> <MenuItemAction iconClassName="icon-keyboard-return" id="keyboardShortcuts" onClick={[Function]} show={true} text="Keyboard shortcuts" /> </Memo(MenuGroup)> </Menu> </MenuWrapper> `; exports[`components/channel_header/components/UserGuideDropdown should match snapshot when have plugin menu items 1`] = ` <MenuWrapper animationComponent={[Function]} className="userGuideHelp" id="helpMenuPortal" onToggle={[Function]} > <OverlayTrigger defaultOverlayShown={false} delayShow={500} overlay={ <Tooltip className="hidden-xs" id="userGuideHelpTooltip" > <Memo(MemoizedFormattedMessage) defaultMessage="Help" id="channel_header.userHelpGuide" /> </Tooltip> } placement="bottom" trigger={ Array [ "hover", "focus", ] } > <ForwardRef active={false} aria-controls="AddChannelDropdown" aria-expanded={false} aria-label="Help" compact={true} icon="help-circle-outline" inverted={true} onClick={[Function]} size="sm" /> </OverlayTrigger> <Menu ariaLabel="Add Channel Dropdown" id="AddChannelDropdown" openLeft={false} openUp={false} > <Memo(MenuGroup)> <MenuItemExternalLink iconClassName="icon-file-text-outline" id="mattermostUserGuideLink" show={true} text="Mattermost user guide" url="https://docs.mattermost.com/guides/use-mattermost.html" /> <MenuItemExternalLink iconClassName="icon-lightbulb-outline" id="trainingResourcesLink" show={true} text="Training resources" url="https://academy.mattermost.com/" /> <MenuItemExternalLink iconClassName="icon-help" id="askTheCommunityLink" onClick={[Function]} show={true} text="Ask the community" url="https://mattermost.com/pl/default-ask-mattermost-community/" /> <MenuItemExternalLink iconClassName="icon-alert-outline" id="reportAProblemLink" show={true} text="Report a problem" url="reportAProblemLink" /> <MenuItemAction iconClassName="icon-keyboard-return" id="keyboardShortcuts" onClick={[Function]} show={true} text="Keyboard shortcuts" /> <MenuItemAction iconClassName="icon-thumbs-up-down" id="testId_pluginmenuitem" key="testId_pluginmenuitem" onClick={[Function]} show={true} text="Test Item" /> </Memo(MenuGroup)> </Menu> </MenuWrapper> `;
2,312
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/global_header/left_controls
petrpan-code/mattermost/mattermost/webapp/channels/src/components/global_header/left_controls/product_menu/product_menu.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import * as reactRedux from 'react-redux'; import mockStore from 'tests/test_store'; import {TopLevelProducts} from 'utils/constants'; import * as productUtils from 'utils/products'; import {TestHelper} from 'utils/test_helper'; import ProductMenu, {ProductMenuButton, ProductMenuContainer} from './product_menu'; import ProductMenuItem from './product_menu_item'; import ProductMenuList from './product_menu_list'; const spyProduct = jest.spyOn(productUtils, 'useCurrentProductId'); spyProduct.mockReturnValue(null); describe('components/global/product_switcher', () => { const useDispatchMock = jest.spyOn(reactRedux, 'useDispatch'); const useSelectorMock = jest.spyOn(reactRedux, 'useSelector'); beforeEach(() => { const products = [ TestHelper.makeProduct(TopLevelProducts.BOARDS), TestHelper.makeProduct(TopLevelProducts.PLAYBOOKS), ]; const spyProducts = jest.spyOn(productUtils, 'useProducts'); spyProducts.mockReturnValue(products); useDispatchMock.mockClear(); useSelectorMock.mockClear(); }); it('should match snapshot', () => { const state = { views: { productMenu: { switcherOpen: false, }, }, }; const store = mockStore(state); const dummyDispatch = jest.fn(); useDispatchMock.mockReturnValue(dummyDispatch); const wrapper = shallow(<reactRedux.Provider store={store}><ProductMenu/></reactRedux.Provider>); expect(wrapper).toMatchSnapshot(); }); it('should render once when there are no top level products available', () => { const state = { users: { currentUserId: 'test_id', }, views: { productMenu: { switcherOpen: true, }, }, }; const store = mockStore(state); const dummyDispatch = jest.fn(); useDispatchMock.mockReturnValue(dummyDispatch); useSelectorMock.mockReturnValue(true); const wrapper = shallow(<ProductMenu/>, { wrappingComponent: reactRedux.Provider, wrappingComponentProps: {store}, }); const spyProducts = jest.spyOn(productUtils, 'useProducts'); spyProducts.mockReturnValue([]); expect(wrapper.find(ProductMenuItem).at(0)).toHaveLength(1); expect(wrapper).toMatchSnapshot(); }); it('should render the correct amount of times when there are products available', () => { const state = { views: { productMenu: { switcherOpen: true, }, }, }; const store = mockStore(state); const dummyDispatch = jest.fn(); useDispatchMock.mockReturnValue(dummyDispatch); useSelectorMock.mockReturnValue(true); const wrapper = shallow(<ProductMenu/>, { wrappingComponent: reactRedux.Provider, wrappingComponentProps: {store}, }); const products = [ TestHelper.makeProduct(TopLevelProducts.BOARDS), TestHelper.makeProduct(TopLevelProducts.PLAYBOOKS), ]; const spyProducts = jest.spyOn(productUtils, 'useProducts'); spyProducts.mockReturnValue(products); expect(wrapper.find(ProductMenuItem)).toHaveLength(3); expect(wrapper).toMatchSnapshot(); }); it('should have an active button state when the switcher menu is open', () => { const state = { views: { productMenu: { switcherOpen: true, }, }, }; const store = mockStore(state); const dummyDispatch = jest.fn(); useDispatchMock.mockReturnValue(dummyDispatch); useSelectorMock.mockReturnValue(true); const wrapper = shallow(<ProductMenu/>, { wrappingComponent: reactRedux.Provider, wrappingComponentProps: {store}, }); const setState = jest.fn(); const useStateSpy = jest.spyOn(React, 'useState'); useStateSpy.mockImplementation(() => [false, setState]); wrapper.find(ProductMenuContainer).simulate('click'); expect(wrapper.find(ProductMenuButton).props().active).toEqual(true); expect(wrapper).toMatchSnapshot(); }); it('should match snapshot with product switcher menu', () => { const state = { views: { productMenu: { switcherOpen: true, }, }, }; const store = mockStore(state); const dummyDispatch = jest.fn(); useDispatchMock.mockReturnValue(dummyDispatch); useSelectorMock.mockReturnValue(true); const wrapper = shallow(<ProductMenu/>, { wrappingComponent: reactRedux.Provider, wrappingComponentProps: {store}, }); expect(wrapper.find(ProductMenuList)).toHaveLength(1); expect(wrapper).toMatchSnapshot(); }); });
2,314
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/global_header/left_controls/product_menu
petrpan-code/mattermost/mattermost/webapp/channels/src/components/global_header/left_controls/product_menu/__snapshots__/product_menu.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/global/product_switcher should have an active button state when the switcher menu is open 1`] = ` <div> <MenuWrapper animationComponent={[Function]} className="" open={true} > <ProductMenuContainer onClick={[Function]} > <ProductMenuButton active={true} aria-controls="product-switcher-menu" aria-expanded={true} aria-label="Product switch menu" /> <ProductBranding /> </ProductMenuContainer> <Menu ariaLabel="switcherOpen" className="product-switcher-menu" id="product-switcher-menu" listId="product-switcher-menu-dropdown" > <ProductMenuItem active={true} destination="/" icon="product-channels" onClick={[Function]} text="Channels" /> <ProductMenuItem active={false} destination="" icon="product-boards" id="product-menu-item-Boards" key="Boards" onClick={[Function]} text="Boards" /> <ProductMenuItem active={false} destination="" icon="product-playbooks" id="product-menu-item-Playbooks" key="Playbooks" onClick={[Function]} text="Playbooks" /> <Connect(ProductMenuList) handleVisitConsoleClick={[Function]} isMessaging={true} onClick={[Function]} /> </Menu> </MenuWrapper> </div> `; exports[`components/global/product_switcher should match snapshot 1`] = ` <ContextProvider value={ Object { "store": Object { "clearActions": [Function], "dispatch": [Function], "getActions": [Function], "getState": [Function], "replaceReducer": [Function], "subscribe": [Function], }, "subscription": Subscription { "handleChangeWrapper": [Function], "listeners": Object { "notify": [Function], }, "onStateChange": [Function], "parentSub": undefined, "store": Object { "clearActions": [Function], "dispatch": [Function], "getActions": [Function], "getState": [Function], "replaceReducer": [Function], "subscribe": [Function], }, "unsubscribe": null, }, } } > <ProductMenu /> </ContextProvider> `; exports[`components/global/product_switcher should match snapshot with product switcher menu 1`] = ` <div> <MenuWrapper animationComponent={[Function]} className="" open={true} > <ProductMenuContainer onClick={[Function]} > <ProductMenuButton active={true} aria-controls="product-switcher-menu" aria-expanded={true} aria-label="Product switch menu" /> <ProductBranding /> </ProductMenuContainer> <Menu ariaLabel="switcherOpen" className="product-switcher-menu" id="product-switcher-menu" listId="product-switcher-menu-dropdown" > <ProductMenuItem active={true} destination="/" icon="product-channels" onClick={[Function]} text="Channels" /> <ProductMenuItem active={false} destination="" icon="product-boards" id="product-menu-item-Boards" key="Boards" onClick={[Function]} text="Boards" /> <ProductMenuItem active={false} destination="" icon="product-playbooks" id="product-menu-item-Playbooks" key="Playbooks" onClick={[Function]} text="Playbooks" /> <Connect(ProductMenuList) handleVisitConsoleClick={[Function]} isMessaging={true} onClick={[Function]} /> </Menu> </MenuWrapper> </div> `; exports[`components/global/product_switcher should render once when there are no top level products available 1`] = ` <div> <MenuWrapper animationComponent={[Function]} className="" open={true} > <ProductMenuContainer onClick={[Function]} > <ProductMenuButton active={true} aria-controls="product-switcher-menu" aria-expanded={true} aria-label="Product switch menu" /> <ProductBranding /> </ProductMenuContainer> <Menu ariaLabel="switcherOpen" className="product-switcher-menu" id="product-switcher-menu" listId="product-switcher-menu-dropdown" > <ProductMenuItem active={true} destination="/" icon="product-channels" onClick={[Function]} text="Channels" /> <ProductMenuItem active={false} destination="" icon="product-boards" id="product-menu-item-Boards" key="Boards" onClick={[Function]} text="Boards" /> <ProductMenuItem active={false} destination="" icon="product-playbooks" id="product-menu-item-Playbooks" key="Playbooks" onClick={[Function]} text="Playbooks" /> <Connect(ProductMenuList) handleVisitConsoleClick={[Function]} isMessaging={true} onClick={[Function]} /> </Menu> </MenuWrapper> </div> `; exports[`components/global/product_switcher should render the correct amount of times when there are products available 1`] = ` <div> <MenuWrapper animationComponent={[Function]} className="" open={true} > <ProductMenuContainer onClick={[Function]} > <ProductMenuButton active={true} aria-controls="product-switcher-menu" aria-expanded={true} aria-label="Product switch menu" /> <ProductBranding /> </ProductMenuContainer> <Menu ariaLabel="switcherOpen" className="product-switcher-menu" id="product-switcher-menu" listId="product-switcher-menu-dropdown" > <ProductMenuItem active={true} destination="/" icon="product-channels" onClick={[Function]} text="Channels" /> <ProductMenuItem active={false} destination="" icon="product-boards" id="product-menu-item-Boards" key="Boards" onClick={[Function]} text="Boards" /> <ProductMenuItem active={false} destination="" icon="product-playbooks" id="product-menu-item-Playbooks" key="Playbooks" onClick={[Function]} text="Playbooks" /> <Connect(ProductMenuList) handleVisitConsoleClick={[Function]} isMessaging={true} onClick={[Function]} /> </Menu> </MenuWrapper> </div> `;
2,316
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/global_header/left_controls/product_menu
petrpan-code/mattermost/mattermost/webapp/channels/src/components/global_header/left_controls/product_menu/product_branding/product_branding.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import {TopLevelProducts} from 'utils/constants'; import * as productUtils from 'utils/products'; import {TestHelper} from 'utils/test_helper'; import ProductBranding from './product_branding'; describe('components/ProductBranding', () => { test('should show correct icon glyph when we are on Channels', () => { const currentProductSpy = jest.spyOn(productUtils, 'useCurrentProduct'); currentProductSpy.mockReturnValue(null); const wrapper = shallow( <ProductBranding/>, ); expect(wrapper).toMatchSnapshot(); }); test('should show correct icon glyph when we are on Playbooks', () => { const currentProductSpy = jest.spyOn(productUtils, 'useCurrentProduct'); currentProductSpy.mockReturnValue(TestHelper.makeProduct(TopLevelProducts.PLAYBOOKS)); const wrapper = shallow( <ProductBranding/>, ); expect(wrapper).toMatchSnapshot(); }); test('should show correct icon glyph when we are on Boards', () => { const currentProductSpy = jest.spyOn(productUtils, 'useCurrentProduct'); currentProductSpy.mockReturnValue(TestHelper.makeProduct(TopLevelProducts.BOARDS)); const wrapper = shallow( <ProductBranding/>, ); expect(wrapper).toMatchSnapshot(); }); });
2,318
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/global_header/left_controls/product_menu/product_branding
petrpan-code/mattermost/mattermost/webapp/channels/src/components/global_header/left_controls/product_menu/product_branding/__snapshots__/product_branding.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/ProductBranding should show correct icon glyph when we are on Boards 1`] = ` <ProductBrandingContainer tabIndex={0} > <ProductBoardsIcon size={24} /> <Heading element="h1" margin="none" size={200} > Boards </Heading> </ProductBrandingContainer> `; exports[`components/ProductBranding should show correct icon glyph when we are on Channels 1`] = ` <ProductBrandingContainer tabIndex={0} > <ProductChannelsIcon size={24} /> <Heading element="h1" margin="none" size={200} > Channels </Heading> </ProductBrandingContainer> `; exports[`components/ProductBranding should show correct icon glyph when we are on Playbooks 1`] = ` <ProductBrandingContainer tabIndex={0} > <ProductPlaybooksIcon size={24} /> <Heading element="h1" margin="none" size={200} > Playbooks </Heading> </ProductBrandingContainer> `;
2,323
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/global_header/left_controls/product_menu
petrpan-code/mattermost/mattermost/webapp/channels/src/components/global_header/left_controls/product_menu/product_menu_list/product_menu_list.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import type {UserProfile} from '@mattermost/types/users'; import MenuGroup from 'components/widgets/menu/menu_group'; import {TestHelper} from 'utils/test_helper'; import ProductMenuList from './product_menu_list'; import type {Props as ProductMenuListProps} from './product_menu_list'; describe('components/global/product_switcher_menu', () => { // Necessary for components enhanced by HOCs due to issue with enzyme. // See https://github.com/enzymejs/enzyme/issues/539 const getMenuWrapper = (props: ProductMenuListProps) => { const wrapper = shallow(<ProductMenuList {...props}/>); return wrapper.find(MenuGroup).shallow(); }; const user = TestHelper.getUserMock({ id: 'test-user-id', username: 'username', }); const defaultProps: ProductMenuListProps = { isMobile: false, teamId: '', teamName: '', siteName: '', currentUser: user, appDownloadLink: 'test–link', isMessaging: true, enableCommands: false, enableIncomingWebhooks: false, enableOAuthServiceProvider: false, enableOutgoingWebhooks: false, canManageSystemBots: false, canManageIntegrations: true, enablePluginMarketplace: false, showVisitSystemConsoleTour: false, isStarterFree: false, isFreeTrial: false, onClick: () => jest.fn, handleVisitConsoleClick: () => jest.fn, enableCustomUserGroups: false, actions: { openModal: jest.fn(), getPrevTrialLicense: jest.fn(), }, }; test('should match snapshot with id', () => { const props = {...defaultProps, id: 'product-switcher-menu-test'}; const wrapper = shallow(<ProductMenuList {...props}/>); expect(wrapper).toMatchSnapshot(); }); test('should not render if the user is not logged in', () => { const props = {...defaultProps, currentUser: undefined as unknown as UserProfile}; const wrapper = shallow(<ProductMenuList {...props}/>); expect(wrapper.type()).toEqual(null); }); test('should match snapshot with most of the thing enabled', () => { const props = { ...defaultProps, enableCommands: true, enableIncomingWebhooks: true, enableOAuthServiceProvider: true, enableOutgoingWebhooks: true, canManageSystemBots: true, canManageIntegrations: true, enablePluginMarketplace: true, }; const wrapper = shallow(<ProductMenuList {...props}/>); expect(wrapper).toMatchSnapshot(); }); test('should match userGroups snapshot with cloud free', () => { const props = { ...defaultProps, enableCustomUserGroups: false, isStarterFree: true, isFreeTrial: false, }; const wrapper = shallow(<ProductMenuList {...props}/>); expect(wrapper.find('#userGroups')).toMatchSnapshot(); }); test('should match userGroups snapshot with cloud free trial', () => { const props = { ...defaultProps, enableCustomUserGroups: false, isStarterFree: false, isFreeTrial: true, }; const wrapper = shallow(<ProductMenuList {...props}/>); expect(wrapper.find('#userGroups')).toMatchSnapshot(); }); test('should match userGroups snapshot with EnableCustomGroups config', () => { const props = { ...defaultProps, enableCustomUserGroups: true, isStarterFree: false, isFreeTrial: false, }; const wrapper = shallow(<ProductMenuList {...props}/>); expect(wrapper.find('#userGroups')).toMatchSnapshot(); }); test('user groups button is disabled for free', () => { const props = { ...defaultProps, enableCustomUserGroups: true, isStarterFree: true, isFreeTrial: false, }; const wrapper = getMenuWrapper(props); expect(wrapper.find('#userGroups').prop('disabled')).toBe(true); }); describe('should show integrations', () => { it('when incoming webhooks enabled', () => { const props = {...defaultProps, enableIncomingWebhooks: true}; const wrapper = shallow(<ProductMenuList {...props}/>); expect(wrapper.find('#integrations').prop('show')).toBe(true); }); it('when outgoing webhooks enabled', () => { const props = {...defaultProps, enableOutgoingWebhooks: true}; const wrapper = shallow(<ProductMenuList {...props}/>); expect(wrapper.find('#integrations').prop('show')).toBe(true); }); it('when slash commands enabled', () => { const props = {...defaultProps, enableCommands: true}; const wrapper = getMenuWrapper(props); expect(wrapper.find('#integrations').prop('show')).toBe(true); }); it('when oauth providers enabled', () => { const props = {...defaultProps, enableOAuthServiceProvider: true}; const wrapper = getMenuWrapper(props); expect(wrapper.find('#integrations').prop('show')).toBe(true); }); it('when can manage system bots', () => { const props = {...defaultProps, canManageSystemBots: true}; const wrapper = getMenuWrapper(props); expect(wrapper.find('#integrations').prop('show')).toBe(true); }); it('unless cannot manage integrations', () => { const props = {...defaultProps, canManageIntegrations: false, enableCommands: true}; const wrapper = getMenuWrapper(props); expect(wrapper.find('#integrations').prop('show')).toBe(false); }); it('should show integrations modal', () => { const props = {...defaultProps, enableIncomingWebhooks: true}; const wrapper = getMenuWrapper(props); wrapper.find('#integrations').simulate('click'); expect(wrapper).toMatchSnapshot(); }); }); });
2,325
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/global_header/left_controls/product_menu/product_menu_list
petrpan-code/mattermost/mattermost/webapp/channels/src/components/global_header/left_controls/product_menu/product_menu_list/__snapshots__/product_menu_list.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/global/product_switcher_menu should match snapshot with id 1`] = ` <Memo(MenuGroup)> <div onClick={[Function]} > <MenuCloudTrial id="menuCloudTrial" /> <MenuItemCloudLimit id="menuItemCloudLimit" /> <Connect(SystemPermissionGate) permissions={ Array [ "sysconsole_write_about_edition_and_license", ] } > <MenuStartTrial id="startTrial" /> </Connect(SystemPermissionGate)> <Connect(SystemPermissionGate) permissions={ Array [ "sysconsole_read_about_edition_and_license", "sysconsole_read_billing", "sysconsole_read_reporting_site_statistics", "sysconsole_read_reporting_team_statistics", "sysconsole_read_reporting_server_logs", "sysconsole_read_user_management_users", "sysconsole_read_user_management_groups", "sysconsole_read_user_management_teams", "sysconsole_read_user_management_channels", "sysconsole_read_user_management_permissions", "sysconsole_read_site_customization", "sysconsole_read_site_localization", "sysconsole_read_site_users_and_teams", "sysconsole_read_site_notifications", "sysconsole_read_site_announcement_banner", "sysconsole_read_site_emoji", "sysconsole_read_site_posts", "sysconsole_read_site_file_sharing_and_downloads", "sysconsole_read_site_public_links", "sysconsole_read_site_notices", "sysconsole_read_environment_web_server", "sysconsole_read_environment_database", "sysconsole_read_environment_elasticsearch", "sysconsole_read_environment_file_storage", "sysconsole_read_environment_image_proxy", "sysconsole_read_environment_smtp", "sysconsole_read_environment_push_notification_server", "sysconsole_read_environment_high_availability", "sysconsole_read_environment_rate_limiting", "sysconsole_read_environment_logging", "sysconsole_read_environment_session_lengths", "sysconsole_read_environment_performance_monitoring", "sysconsole_read_environment_developer", "sysconsole_read_authentication_signup", "sysconsole_read_authentication_email", "sysconsole_read_authentication_password", "sysconsole_read_authentication_mfa", "sysconsole_read_authentication_ldap", "sysconsole_read_authentication_saml", "sysconsole_read_authentication_openid", "sysconsole_read_authentication_guest_access", "sysconsole_read_plugins", "sysconsole_read_integrations_integration_management", "sysconsole_read_integrations_bot_accounts", "sysconsole_read_integrations_gif", "sysconsole_read_integrations_cors", "sysconsole_read_compliance_data_retention_policy", "sysconsole_read_compliance_compliance_export", "sysconsole_read_compliance_compliance_monitoring", "sysconsole_read_compliance_custom_terms_of_service", "sysconsole_read_experimental_features", "sysconsole_read_experimental_feature_flags", "sysconsole_read_experimental_bleve", "sysconsole_read_products_boards", ] } > <MenuItemLink icon={ <ApplicationCogIcon size={18} /> } id="systemConsole" show={true} text={ <React.Fragment> System Console </React.Fragment> } to="/admin_console" /> </Connect(SystemPermissionGate)> <MenuItemLink icon={ <WebhookIncomingIcon size={18} /> } id="integrations" show={false} text="Integrations" to="//integrations" /> <MenuItemToggleModalRedux dialogProps={ Object { "backButtonAction": [Function], } } dialogType={ Object { "$$typeof": Symbol(react.forward_ref), "WrappedComponent": Object { "$$typeof": Symbol(react.memo), "compare": null, "type": [Function], }, "render": [Function], } } disabled={false} icon={ <AccountMultipleOutlineIcon size={18} /> } id="userGroups" modalId="user_groups" show={false} sibling={false} text="User Groups" /> <Connect(TeamPermissionGate) permissions={ Array [ "sysconsole_write_plugins", ] } teamId="" > <MenuItemToggleModalRedux dialogProps={ Object { "openedFrom": "product_menu", } } dialogType={[Function]} icon={ <ViewGridPlusOutlineIcon size={18} /> } id="marketplaceModal" modalId="plugin_marketplace" show={false} text="App Marketplace" /> </Connect(TeamPermissionGate)> <MenuItemExternalLink icon={ <DownloadOutlineIcon size={18} /> } id="nativeAppLink" show={true} text="Download Apps" url="test–link" /> <MenuItemToggleModalRedux dialogType={ Object { "$$typeof": Symbol(react.memo), "WrappedComponent": [Function], "compare": null, "type": [Function], } } icon={ <InformationOutlineIcon size={18} /> } id="about" modalId="about" show={true} text="About " /> </div> </Memo(MenuGroup)> `; exports[`components/global/product_switcher_menu should match snapshot with most of the thing enabled 1`] = ` <Memo(MenuGroup)> <div onClick={[Function]} > <MenuCloudTrial id="menuCloudTrial" /> <MenuItemCloudLimit id="menuItemCloudLimit" /> <Connect(SystemPermissionGate) permissions={ Array [ "sysconsole_write_about_edition_and_license", ] } > <MenuStartTrial id="startTrial" /> </Connect(SystemPermissionGate)> <Connect(SystemPermissionGate) permissions={ Array [ "sysconsole_read_about_edition_and_license", "sysconsole_read_billing", "sysconsole_read_reporting_site_statistics", "sysconsole_read_reporting_team_statistics", "sysconsole_read_reporting_server_logs", "sysconsole_read_user_management_users", "sysconsole_read_user_management_groups", "sysconsole_read_user_management_teams", "sysconsole_read_user_management_channels", "sysconsole_read_user_management_permissions", "sysconsole_read_site_customization", "sysconsole_read_site_localization", "sysconsole_read_site_users_and_teams", "sysconsole_read_site_notifications", "sysconsole_read_site_announcement_banner", "sysconsole_read_site_emoji", "sysconsole_read_site_posts", "sysconsole_read_site_file_sharing_and_downloads", "sysconsole_read_site_public_links", "sysconsole_read_site_notices", "sysconsole_read_environment_web_server", "sysconsole_read_environment_database", "sysconsole_read_environment_elasticsearch", "sysconsole_read_environment_file_storage", "sysconsole_read_environment_image_proxy", "sysconsole_read_environment_smtp", "sysconsole_read_environment_push_notification_server", "sysconsole_read_environment_high_availability", "sysconsole_read_environment_rate_limiting", "sysconsole_read_environment_logging", "sysconsole_read_environment_session_lengths", "sysconsole_read_environment_performance_monitoring", "sysconsole_read_environment_developer", "sysconsole_read_authentication_signup", "sysconsole_read_authentication_email", "sysconsole_read_authentication_password", "sysconsole_read_authentication_mfa", "sysconsole_read_authentication_ldap", "sysconsole_read_authentication_saml", "sysconsole_read_authentication_openid", "sysconsole_read_authentication_guest_access", "sysconsole_read_plugins", "sysconsole_read_integrations_integration_management", "sysconsole_read_integrations_bot_accounts", "sysconsole_read_integrations_gif", "sysconsole_read_integrations_cors", "sysconsole_read_compliance_data_retention_policy", "sysconsole_read_compliance_compliance_export", "sysconsole_read_compliance_compliance_monitoring", "sysconsole_read_compliance_custom_terms_of_service", "sysconsole_read_experimental_features", "sysconsole_read_experimental_feature_flags", "sysconsole_read_experimental_bleve", "sysconsole_read_products_boards", ] } > <MenuItemLink icon={ <ApplicationCogIcon size={18} /> } id="systemConsole" show={true} text={ <React.Fragment> System Console </React.Fragment> } to="/admin_console" /> </Connect(SystemPermissionGate)> <MenuItemLink icon={ <WebhookIncomingIcon size={18} /> } id="integrations" show={true} text="Integrations" to="//integrations" /> <MenuItemToggleModalRedux dialogProps={ Object { "backButtonAction": [Function], } } dialogType={ Object { "$$typeof": Symbol(react.forward_ref), "WrappedComponent": Object { "$$typeof": Symbol(react.memo), "compare": null, "type": [Function], }, "render": [Function], } } disabled={false} icon={ <AccountMultipleOutlineIcon size={18} /> } id="userGroups" modalId="user_groups" show={false} sibling={false} text="User Groups" /> <Connect(TeamPermissionGate) permissions={ Array [ "sysconsole_write_plugins", ] } teamId="" > <MenuItemToggleModalRedux dialogProps={ Object { "openedFrom": "product_menu", } } dialogType={[Function]} icon={ <ViewGridPlusOutlineIcon size={18} /> } id="marketplaceModal" modalId="plugin_marketplace" show={true} text="App Marketplace" /> </Connect(TeamPermissionGate)> <MenuItemExternalLink icon={ <DownloadOutlineIcon size={18} /> } id="nativeAppLink" show={true} text="Download Apps" url="test–link" /> <MenuItemToggleModalRedux dialogType={ Object { "$$typeof": Symbol(react.memo), "WrappedComponent": [Function], "compare": null, "type": [Function], } } icon={ <InformationOutlineIcon size={18} /> } id="about" modalId="about" show={true} text="About " /> </div> </Memo(MenuGroup)> `; exports[`components/global/product_switcher_menu should match userGroups snapshot with EnableCustomGroups config 1`] = ` <MenuItemToggleModalRedux dialogProps={ Object { "backButtonAction": [Function], } } dialogType={ Object { "$$typeof": Symbol(react.forward_ref), "WrappedComponent": Object { "$$typeof": Symbol(react.memo), "compare": null, "type": [Function], }, "render": [Function], } } disabled={false} icon={ <AccountMultipleOutlineIcon size={18} /> } id="userGroups" modalId="user_groups" show={true} sibling={false} text="User Groups" /> `; exports[`components/global/product_switcher_menu should match userGroups snapshot with cloud free 1`] = ` <MenuItemToggleModalRedux dialogProps={ Object { "backButtonAction": [Function], } } dialogType={ Object { "$$typeof": Symbol(react.forward_ref), "WrappedComponent": Object { "$$typeof": Symbol(react.memo), "compare": null, "type": [Function], }, "render": [Function], } } disabled={true} icon={ <AccountMultipleOutlineIcon size={18} /> } id="userGroups" modalId="user_groups" show={true} sibling={ <RestrictedIndicator blocked={true} feature="mattermost.feature.custom_user_groups" messageAdminPostTrial="User groups are a way to organize users and apply actions to all users within that group. Upgrade to the Professional plan to create unlimited user groups." messageAdminPreTrial="Create unlimited user groups with one of our paid plans. Get the full experience of Enterprise when you start a free, 30 day trial." messageEndUser="User groups are a way to organize users and apply actions to all users within that group." minimumPlanRequiredForFeature="professional" titleAdminPostTrial="Upgrade to create unlimited user groups" titleAdminPreTrial="Try unlimited user groups with a free trial" titleEndUser="User groups available in paid plans" tooltipMessage="During your trial you are able to create user groups. These user groups will be archived after your trial." /> } text="User Groups" /> `; exports[`components/global/product_switcher_menu should match userGroups snapshot with cloud free trial 1`] = ` <MenuItemToggleModalRedux dialogProps={ Object { "backButtonAction": [Function], } } dialogType={ Object { "$$typeof": Symbol(react.forward_ref), "WrappedComponent": Object { "$$typeof": Symbol(react.memo), "compare": null, "type": [Function], }, "render": [Function], } } disabled={false} icon={ <AccountMultipleOutlineIcon size={18} /> } id="userGroups" modalId="user_groups" show={true} sibling={ <RestrictedIndicator blocked={false} feature="mattermost.feature.custom_user_groups" messageAdminPostTrial="User groups are a way to organize users and apply actions to all users within that group. Upgrade to the Professional plan to create unlimited user groups." messageAdminPreTrial="Create unlimited user groups with one of our paid plans. Get the full experience of Enterprise when you start a free, 30 day trial." messageEndUser="User groups are a way to organize users and apply actions to all users within that group." minimumPlanRequiredForFeature="professional" titleAdminPostTrial="Upgrade to create unlimited user groups" titleAdminPreTrial="Try unlimited user groups with a free trial" titleEndUser="User groups available in paid plans" tooltipMessage="During your trial you are able to create user groups. These user groups will be archived after your trial." /> } text="User Groups" /> `; exports[`components/global/product_switcher_menu should show integrations should show integrations modal 1`] = ` <Fragment> <li className="MenuGroup menu-divider" onClick={[Function]} /> <div onClick={[Function]} > <MenuCloudTrial id="menuCloudTrial" /> <MenuItemCloudLimit id="menuItemCloudLimit" /> <Connect(SystemPermissionGate) permissions={ Array [ "sysconsole_write_about_edition_and_license", ] } > <MenuStartTrial id="startTrial" /> </Connect(SystemPermissionGate)> <Connect(SystemPermissionGate) permissions={ Array [ "sysconsole_read_about_edition_and_license", "sysconsole_read_billing", "sysconsole_read_reporting_site_statistics", "sysconsole_read_reporting_team_statistics", "sysconsole_read_reporting_server_logs", "sysconsole_read_user_management_users", "sysconsole_read_user_management_groups", "sysconsole_read_user_management_teams", "sysconsole_read_user_management_channels", "sysconsole_read_user_management_permissions", "sysconsole_read_site_customization", "sysconsole_read_site_localization", "sysconsole_read_site_users_and_teams", "sysconsole_read_site_notifications", "sysconsole_read_site_announcement_banner", "sysconsole_read_site_emoji", "sysconsole_read_site_posts", "sysconsole_read_site_file_sharing_and_downloads", "sysconsole_read_site_public_links", "sysconsole_read_site_notices", "sysconsole_read_environment_web_server", "sysconsole_read_environment_database", "sysconsole_read_environment_elasticsearch", "sysconsole_read_environment_file_storage", "sysconsole_read_environment_image_proxy", "sysconsole_read_environment_smtp", "sysconsole_read_environment_push_notification_server", "sysconsole_read_environment_high_availability", "sysconsole_read_environment_rate_limiting", "sysconsole_read_environment_logging", "sysconsole_read_environment_session_lengths", "sysconsole_read_environment_performance_monitoring", "sysconsole_read_environment_developer", "sysconsole_read_authentication_signup", "sysconsole_read_authentication_email", "sysconsole_read_authentication_password", "sysconsole_read_authentication_mfa", "sysconsole_read_authentication_ldap", "sysconsole_read_authentication_saml", "sysconsole_read_authentication_openid", "sysconsole_read_authentication_guest_access", "sysconsole_read_plugins", "sysconsole_read_integrations_integration_management", "sysconsole_read_integrations_bot_accounts", "sysconsole_read_integrations_gif", "sysconsole_read_integrations_cors", "sysconsole_read_compliance_data_retention_policy", "sysconsole_read_compliance_compliance_export", "sysconsole_read_compliance_compliance_monitoring", "sysconsole_read_compliance_custom_terms_of_service", "sysconsole_read_experimental_features", "sysconsole_read_experimental_feature_flags", "sysconsole_read_experimental_bleve", "sysconsole_read_products_boards", ] } > <MenuItemLink icon={ <ApplicationCogIcon size={18} /> } id="systemConsole" show={true} text={ <React.Fragment> System Console </React.Fragment> } to="/admin_console" /> </Connect(SystemPermissionGate)> <MenuItemLink icon={ <WebhookIncomingIcon size={18} /> } id="integrations" show={true} text="Integrations" to="//integrations" /> <MenuItemToggleModalRedux dialogProps={ Object { "backButtonAction": [Function], } } dialogType={ Object { "$$typeof": Symbol(react.forward_ref), "WrappedComponent": Object { "$$typeof": Symbol(react.memo), "compare": null, "type": [Function], }, "render": [Function], } } disabled={false} icon={ <AccountMultipleOutlineIcon size={18} /> } id="userGroups" modalId="user_groups" show={false} sibling={false} text="User Groups" /> <Connect(TeamPermissionGate) permissions={ Array [ "sysconsole_write_plugins", ] } teamId="" > <MenuItemToggleModalRedux dialogProps={ Object { "openedFrom": "product_menu", } } dialogType={[Function]} icon={ <ViewGridPlusOutlineIcon size={18} /> } id="marketplaceModal" modalId="plugin_marketplace" show={false} text="App Marketplace" /> </Connect(TeamPermissionGate)> <MenuItemExternalLink icon={ <DownloadOutlineIcon size={18} /> } id="nativeAppLink" show={true} text="Download Apps" url="test–link" /> <MenuItemToggleModalRedux dialogType={ Object { "$$typeof": Symbol(react.memo), "WrappedComponent": [Function], "compare": null, "type": [Function], } } icon={ <InformationOutlineIcon size={18} /> } id="about" modalId="about" show={true} text="About " /> </div> </Fragment> `;
2,327
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/global_header/right_controls
petrpan-code/mattermost/mattermost/webapp/channels/src/components/global_header/right_controls/at_mentions_button/at_mentions_button.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import IconButton from '@mattermost/compass-components/components/icon-button'; // eslint-disable-line no-restricted-imports import type {GlobalState} from 'types/store'; import AtMentionsButton from './at_mentions_button'; const mockDispatch = jest.fn(); let mockState: GlobalState; jest.mock('react-redux', () => ({ ...jest.requireActual('react-redux') as typeof import('react-redux'), useSelector: (selector: (state: typeof mockState) => unknown) => selector(mockState), useDispatch: () => mockDispatch, })); describe('components/global/AtMentionsButton', () => { beforeEach(() => { mockState = {views: {rhs: {isSidebarOpen: true}}} as GlobalState; }); test('should match snapshot', () => { const wrapper = shallow( <AtMentionsButton/>, ); expect(wrapper).toMatchSnapshot(); }); test('should show active mentions', () => { const wrapper = shallow( <AtMentionsButton/>, ); wrapper.find(IconButton).simulate('click', { preventDefault: jest.fn(), }); expect(mockDispatch).toHaveBeenCalledTimes(1); }); });
2,329
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/global_header/right_controls/at_mentions_button
petrpan-code/mattermost/mattermost/webapp/channels/src/components/global_header/right_controls/at_mentions_button/__snapshots__/at_mentions_button.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/global/AtMentionsButton should match snapshot 1`] = ` <OverlayTrigger defaultOverlayShown={false} delayShow={400} overlay={ <Tooltip id="recentMentions" > <Memo(MemoizedFormattedMessage) defaultMessage="Recent mentions" id="channel_header.recentMentions" /> <Memo(KeyboardShortcutSequence) hideDescription={true} isInsideTooltip={true} shortcut={ Object { "default": Object { "defaultMessage": "Recent mentions: Ctrl|Shift|M", "id": "shortcuts.nav.recent_mentions", }, "mac": Object { "defaultMessage": "Recent mentions: ⌘|Shift|M", "id": "shortcuts.nav.recent_mentions.mac", }, } } /> </Tooltip> } placement="bottom" trigger={ Array [ "hover", "focus", ] } > <ForwardRef aria-controls="searchContainer" aria-expanded={false} aria-label="Recent mentions" compact={true} icon="at" inverted={true} onClick={[Function]} size="sm" toggled={false} /> </OverlayTrigger> `;
2,331
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/global_header/right_controls
petrpan-code/mattermost/mattermost/webapp/channels/src/components/global_header/right_controls/plan_upgrade_button/plan_upgrade_button.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {mount} from 'enzyme'; import React from 'react'; import * as reactRedux from 'react-redux'; import * as cloudActions from 'mattermost-redux/actions/cloud'; import mockStore from 'tests/test_store'; import {CloudProducts} from 'utils/constants'; import PlanUpgradeButton from './index'; describe('components/global/PlanUpgradeButton', () => { const useDispatchMock = jest.spyOn(reactRedux, 'useDispatch'); beforeEach(() => { useDispatchMock.mockClear(); }); const initialState = { entities: { general: { license: { IsLicensed: 'true', Cloud: 'true', }, config: { BuildEnterpriseReady: 'true', }, }, users: { currentUserId: 'current_user_id', profiles: { current_user_id: {roles: 'system_admin'}, }, }, cloud: { subscription: { product_id: 'test_prod_1', }, products: { test_prod_1: { id: 'test_prod_1', sku: CloudProducts.STARTER, price_per_seat: 0, }, }, }, }, }; it('should show Upgrade button in global header for admin users, cloud free subscription', () => { const state = { ...initialState, }; const cloudSubscriptionSpy = jest.spyOn(cloudActions, 'getCloudSubscription'); const cloudProductsSpy = jest.spyOn(cloudActions, 'getCloudProducts'); const store = mockStore(state); const dummyDispatch = jest.fn(); useDispatchMock.mockReturnValue(dummyDispatch); const wrapper = mount( <reactRedux.Provider store={store}> <PlanUpgradeButton/> </reactRedux.Provider>, ); expect(cloudSubscriptionSpy).toHaveBeenCalledTimes(1); expect(cloudProductsSpy).toHaveBeenCalledTimes(1); expect(wrapper.find('UpgradeButton').exists()).toEqual(true); }); it('should show Upgrade button in global header for admin users, cloud and enterprise trial subscription', () => { const state = JSON.parse(JSON.stringify(initialState)); state.entities.cloud = { subscription: { product_id: 'test_prod_2', is_free_trial: 'true', }, products: { test_prod_2: { id: 'test_prod_2', sku: CloudProducts.ENTERPRISE, price_per_seat: 10, }, }, }; const store = mockStore(state); const dummyDispatch = jest.fn(); useDispatchMock.mockReturnValue(dummyDispatch); const wrapper = mount( <reactRedux.Provider store={store}> <PlanUpgradeButton/> </reactRedux.Provider>, ); expect(wrapper.find('UpgradeButton').exists()).toEqual(true); }); it('should not show for cloud enterprise non-trial', () => { const state = JSON.parse(JSON.stringify(initialState)); state.entities.cloud = { subscription: { product_id: 'test_prod_3', is_free_trial: 'false', }, products: { test_prod_3: { id: 'test_prod_3', sku: CloudProducts.ENTERPRISE, price_per_seat: 10, }, }, }; const store = mockStore(state); const dummyDispatch = jest.fn(); useDispatchMock.mockReturnValue(dummyDispatch); const wrapper = mount( <reactRedux.Provider store={store}> <PlanUpgradeButton/> </reactRedux.Provider>, ); expect(wrapper.find('UpgradeButton').exists()).toEqual(false); }); it('should not show for cloud professional product', () => { const state = JSON.parse(JSON.stringify(initialState)); state.entities.cloud = { subscription: { product_id: 'test_prod_4', is_free_trial: 'false', }, products: { test_prod_4: { id: 'test_prod_4', sku: CloudProducts.PROFESSIONAL, price_per_seat: 10, }, }, }; const store = mockStore(state); const dummyDispatch = jest.fn(); useDispatchMock.mockReturnValue(dummyDispatch); const wrapper = mount( <reactRedux.Provider store={store}> <PlanUpgradeButton/> </reactRedux.Provider>, ); expect(wrapper.find('UpgradeButton').exists()).toEqual(false); }); it('should not show Upgrade button in global header for non admin cloud users', () => { const state = JSON.parse(JSON.stringify(initialState)); state.entities.users = { currentUserId: 'current_user_id', profiles: { current_user_id: {roles: 'system_user'}, }, }; const store = mockStore(state); const dummyDispatch = jest.fn(); useDispatchMock.mockReturnValue(dummyDispatch); const wrapper = mount( <reactRedux.Provider store={store}> <PlanUpgradeButton/> </reactRedux.Provider>, ); expect(wrapper.find('UpgradeButton').exists()).toEqual(false); }); it('should not show Upgrade button in global header for non admin self hosted users', () => { const state = JSON.parse(JSON.stringify(initialState)); state.entities.users = { currentUserId: 'current_user_id', profiles: { current_user_id: {roles: 'system_user'}, }, }; state.entities.general.license = { IsLicensed: 'false', // starter Cloud: 'false', }; const store = mockStore(state); const dummyDispatch = jest.fn(); useDispatchMock.mockReturnValue(dummyDispatch); const wrapper = mount( <reactRedux.Provider store={store}> <PlanUpgradeButton/> </reactRedux.Provider>, ); expect(wrapper.find('UpgradeButton').exists()).toEqual(false); }); it('should not show Upgrade button in global header for non enterprise edition self hosted users', () => { const state = JSON.parse(JSON.stringify(initialState)); state.entities.users = { currentUserId: 'current_user_id', profiles: { current_user_id: {roles: 'system_user'}, }, }; state.entities.general.license = { IsLicensed: 'false', Cloud: 'false', }; state.entities.general.config = { BuildEnterpriseReady: 'false', }; const store = mockStore(state); const dummyDispatch = jest.fn(); useDispatchMock.mockReturnValue(dummyDispatch); const wrapper = mount( <reactRedux.Provider store={store}> <PlanUpgradeButton/> </reactRedux.Provider>, ); expect(wrapper.find('UpgradeButton').exists()).toEqual(false); }); it('should NOT show Upgrade button in global header for self hosted non trial and licensed', () => { const state = JSON.parse(JSON.stringify(initialState)); state.entities.general.license = { IsLicensed: 'true', Cloud: 'false', }; const cloudSubscriptionSpy = jest.spyOn(cloudActions, 'getCloudSubscription'); const cloudProductsSpy = jest.spyOn(cloudActions, 'getCloudProducts'); const store = mockStore(state); const dummyDispatch = jest.fn(); useDispatchMock.mockReturnValue(dummyDispatch); const wrapper = mount( <reactRedux.Provider store={store}> <PlanUpgradeButton/> </reactRedux.Provider>, ); expect(cloudSubscriptionSpy).toHaveBeenCalledTimes(0); // no calls to cloud endpoints for non cloud expect(cloudProductsSpy).toHaveBeenCalledTimes(0); expect(wrapper.find('UpgradeButton').exists()).toEqual(false); }); });
2,332
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/global_header/right_controls
petrpan-code/mattermost/mattermost/webapp/channels/src/components/global_header/right_controls/saved_posts_button/saved_posts_button.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import IconButton from '@mattermost/compass-components/components/icon-button'; // eslint-disable-line no-restricted-imports import type {GlobalState} from 'types/store'; import SavedPostsButton from './saved_posts_button'; const mockDispatch = jest.fn(); let mockState: GlobalState; jest.mock('react-redux', () => ({ ...jest.requireActual('react-redux') as typeof import('react-redux'), useSelector: (selector: (state: typeof mockState) => unknown) => selector(mockState), useDispatch: () => mockDispatch, })); describe('components/global/AtMentionsButton', () => { beforeEach(() => { mockState = {views: {rhs: {isSidebarOpen: true}}} as GlobalState; }); test('should match snapshot', () => { const wrapper = shallow( <SavedPostsButton/>, ); expect(wrapper).toMatchSnapshot(); }); test('should show active mentions', () => { const wrapper = shallow( <SavedPostsButton/>, ); wrapper.find(IconButton).simulate('click', { preventDefault: jest.fn(), }); expect(mockDispatch).toHaveBeenCalledTimes(1); }); });
2,334
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/global_header/right_controls/saved_posts_button
petrpan-code/mattermost/mattermost/webapp/channels/src/components/global_header/right_controls/saved_posts_button/__snapshots__/saved_posts_button.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/global/AtMentionsButton should match snapshot 1`] = ` <OverlayTrigger defaultOverlayShown={false} delayShow={400} overlay={ <Tooltip id="recentMentions" > <Memo(MemoizedFormattedMessage) defaultMessage="Saved messages" id="channel_header.flagged" /> </Tooltip> } placement="bottom" trigger={ Array [ "hover", "focus", ] } > <ForwardRef aria-controls="searchContainer" aria-expanded={false} aria-label="Saved messages" compact={true} icon="bookmark-outline" inverted={true} onClick={[Function]} size="sm" toggled={false} /> </OverlayTrigger> `;
2,344
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/header_footer_route
petrpan-code/mattermost/mattermost/webapp/channels/src/components/header_footer_route/content_layouts/alternate_link.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow, mount} from 'enzyme'; import React from 'react'; import {BrowserRouter} from 'react-router-dom'; import AlternateLink from './alternate_link'; describe('components/header_footer_route/content_layouts/alternate_link', () => { it('should return default', () => { const wrapper = shallow( <AlternateLink/>, ); expect(wrapper).toEqual({}); }); it('should show with message', () => { const alternateMessage = 'alternateMessage'; const wrapper = shallow( <AlternateLink alternateMessage={alternateMessage}/>, ); expect(wrapper.find('.alternate-link__message').text()).toEqual(alternateMessage); }); it('should show with link', () => { const alternateLinkPath = 'alternateLinkPath'; const alternateLinkLabel = 'alternateLinkLabel'; const wrapper = mount( <BrowserRouter> <AlternateLink alternateLinkPath={alternateLinkPath} alternateLinkLabel={alternateLinkLabel} /> </BrowserRouter>, ); const link = wrapper.find('.alternate-link__link').first(); expect(link.text()).toEqual(alternateLinkLabel); expect(link.props().to).toEqual({pathname: alternateLinkPath, search: ''}); }); });
2,348
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components
petrpan-code/mattermost/mattermost/webapp/channels/src/components/header_footer_template/header_footer_template.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import React from 'react'; import type {DeepPartial} from '@mattermost/types/utilities'; import mergeObjects from 'packages/mattermost-redux/test/merge_objects'; import {renderWithContext} from 'tests/react_testing_utils'; import type {GlobalState} from 'types/store'; import HeaderFooterNotLoggedIn from './header_footer_template'; describe('components/HeaderFooterTemplate', () => { const RealDate: DateConstructor = Date; function mockDate(date: Date) { function mock() { return new RealDate(date); } mock.now = () => date.getTime(); global.Date = mock as any; } const initialState: DeepPartial<GlobalState> = { entities: { general: { config: {}, }, users: { currentUserId: '', profiles: { user1: { id: 'user1', roles: '', }, }, }, teams: { currentTeamId: 'team1', teams: { team1: { id: 'team1', name: 'team-1', display_name: 'Team 1', }, }, myMembers: { team1: {roles: 'team_role'}, }, }, }, storage: { initialized: true, }, }; beforeEach(() => { mockDate(new Date(2017, 6, 1)); }); afterEach(() => { global.Date = RealDate; }); test('should match snapshot without children', () => { const {container} = renderWithContext(<HeaderFooterNotLoggedIn/>, initialState); expect(container).toMatchSnapshot(); }); test('should match snapshot with children', () => { const {container} = renderWithContext( <HeaderFooterNotLoggedIn> <p>{'test'}</p> </HeaderFooterNotLoggedIn>, initialState, ); expect(container).toMatchSnapshot(); }); test('should match snapshot with help link', () => { const state = mergeObjects(initialState, { entities: { general: { config: { HelpLink: 'http://testhelplink', }, }, }, }); const {container} = renderWithContext(<HeaderFooterNotLoggedIn/>, state); expect(container).toMatchSnapshot(); }); test('should match snapshot with term of service link', () => { const state = mergeObjects(initialState, { entities: { general: { config: { TermsOfServiceLink: 'http://testtermsofservicelink', }, }, }, }); const {container} = renderWithContext(<HeaderFooterNotLoggedIn/>, state); expect(container).toMatchSnapshot(); }); test('should match snapshot with privacy policy link', () => { const state = mergeObjects(initialState, { entities: { general: { config: { PrivacyPolicyLink: 'http://testprivacypolicylink', }, }, }, }); const {container} = renderWithContext(<HeaderFooterNotLoggedIn/>, state); expect(container).toMatchSnapshot(); }); test('should match snapshot with about link', () => { const state = mergeObjects(initialState, { entities: { general: { config: { AboutLink: 'http://testaboutlink', }, }, }, }); const {container} = renderWithContext(<HeaderFooterNotLoggedIn/>, state); expect(container).toMatchSnapshot(); }); test('should match snapshot with all links', () => { const state = mergeObjects(initialState, { entities: { general: { config: { HelpLink: 'http://testhelplink', TermsOfServiceLink: 'http://testtermsofservicelink', PrivacyPolicyLink: 'http://testprivacypolicylink', AboutLink: 'http://testaboutlink', }, }, }, }); const {container} = renderWithContext(<HeaderFooterNotLoggedIn/>, state); expect(container).toMatchSnapshot(); }); test('should set classes on body and #root on mount and unset on unmount', () => { const state = mergeObjects(initialState, { entities: { general: { config: { HelpLink: 'http://testhelplink', TermsOfServiceLink: 'http://testtermsofservicelink', PrivacyPolicyLink: 'http://testprivacypolicylink', AboutLink: 'http://testaboutlink', }, }, }, }); expect(document.body.classList.contains('sticky')).toBe(false); const {container, unmount} = renderWithContext(<HeaderFooterNotLoggedIn/>, state); expect(container).toMatchSnapshot(); expect(document.body.classList.contains('sticky')).toBe(true); unmount(); expect(document.body.classList.contains('sticky')).toBe(false); expect(container).toMatchSnapshot(); }); });
2,350
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/header_footer_template
petrpan-code/mattermost/mattermost/webapp/channels/src/components/header_footer_template/__snapshots__/header_footer_template.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/HeaderFooterTemplate should match snapshot with about link 1`] = ` <div> <div class="inner-wrap" > <div class="row content" /> <div class="row footer" > <div class="footer-pane col-xs-12" id="footer_section" > <div class="col-xs-12" > <span class="pull-right footer-site-name" id="company_name" > Mattermost </span> </div> <div class="col-xs-12" > <span class="pull-right footer-link copyright" id="copyright" > © 2015-2017 Mattermost, Inc. </span> <span class="pull-right" > <a class="footer-link" href="http://testaboutlink" id="about_link" location="header_footer_template" rel="noopener noreferrer" target="_blank" > About </a> </span> </div> </div> </div> </div> </div> `; exports[`components/HeaderFooterTemplate should match snapshot with all links 1`] = ` <div> <div class="inner-wrap" > <div class="row content" /> <div class="row footer" > <div class="footer-pane col-xs-12" id="footer_section" > <div class="col-xs-12" > <span class="pull-right footer-site-name" id="company_name" > Mattermost </span> </div> <div class="col-xs-12" > <span class="pull-right footer-link copyright" id="copyright" > © 2015-2017 Mattermost, Inc. </span> <span class="pull-right" > <a class="footer-link" href="http://testaboutlink" id="about_link" location="header_footer_template" rel="noopener noreferrer" target="_blank" > About </a> <a class="footer-link" href="http://testprivacypolicylink" id="privacy_link" location="header_footer_template" rel="noopener noreferrer" target="_blank" > Privacy Policy </a> <a class="footer-link" href="http://testtermsofservicelink" id="terms_link" location="header_footer_template" rel="noopener noreferrer" target="_blank" > Terms </a> <a class="footer-link" href="http://testhelplink" id="help_link" location="header_footer_template" rel="noopener noreferrer" target="_blank" > Help </a> </span> </div> </div> </div> </div> </div> `; exports[`components/HeaderFooterTemplate should match snapshot with children 1`] = ` <div> <div class="inner-wrap" > <div class="row content" > <p> test </p> </div> <div class="row footer" > <div class="footer-pane col-xs-12" id="footer_section" > <div class="col-xs-12" > <span class="pull-right footer-site-name" id="company_name" > Mattermost </span> </div> <div class="col-xs-12" > <span class="pull-right footer-link copyright" id="copyright" > © 2015-2017 Mattermost, Inc. </span> <span class="pull-right" /> </div> </div> </div> </div> </div> `; exports[`components/HeaderFooterTemplate should match snapshot with help link 1`] = ` <div> <div class="inner-wrap" > <div class="row content" /> <div class="row footer" > <div class="footer-pane col-xs-12" id="footer_section" > <div class="col-xs-12" > <span class="pull-right footer-site-name" id="company_name" > Mattermost </span> </div> <div class="col-xs-12" > <span class="pull-right footer-link copyright" id="copyright" > © 2015-2017 Mattermost, Inc. </span> <span class="pull-right" > <a class="footer-link" href="http://testhelplink" id="help_link" location="header_footer_template" rel="noopener noreferrer" target="_blank" > Help </a> </span> </div> </div> </div> </div> </div> `; exports[`components/HeaderFooterTemplate should match snapshot with privacy policy link 1`] = ` <div> <div class="inner-wrap" > <div class="row content" /> <div class="row footer" > <div class="footer-pane col-xs-12" id="footer_section" > <div class="col-xs-12" > <span class="pull-right footer-site-name" id="company_name" > Mattermost </span> </div> <div class="col-xs-12" > <span class="pull-right footer-link copyright" id="copyright" > © 2015-2017 Mattermost, Inc. </span> <span class="pull-right" > <a class="footer-link" href="http://testprivacypolicylink" id="privacy_link" location="header_footer_template" rel="noopener noreferrer" target="_blank" > Privacy Policy </a> </span> </div> </div> </div> </div> </div> `; exports[`components/HeaderFooterTemplate should match snapshot with term of service link 1`] = ` <div> <div class="inner-wrap" > <div class="row content" /> <div class="row footer" > <div class="footer-pane col-xs-12" id="footer_section" > <div class="col-xs-12" > <span class="pull-right footer-site-name" id="company_name" > Mattermost </span> </div> <div class="col-xs-12" > <span class="pull-right footer-link copyright" id="copyright" > © 2015-2017 Mattermost, Inc. </span> <span class="pull-right" > <a class="footer-link" href="http://testtermsofservicelink" id="terms_link" location="header_footer_template" rel="noopener noreferrer" target="_blank" > Terms </a> </span> </div> </div> </div> </div> </div> `; exports[`components/HeaderFooterTemplate should match snapshot without children 1`] = ` <div> <div class="inner-wrap" > <div class="row content" /> <div class="row footer" > <div class="footer-pane col-xs-12" id="footer_section" > <div class="col-xs-12" > <span class="pull-right footer-site-name" id="company_name" > Mattermost </span> </div> <div class="col-xs-12" > <span class="pull-right footer-link copyright" id="copyright" > © 2015-2017 Mattermost, Inc. </span> <span class="pull-right" /> </div> </div> </div> </div> </div> `; exports[`components/HeaderFooterTemplate should set classes on body and #root on mount and unset on unmount 1`] = ` <div> <div class="inner-wrap" > <div class="row content" /> <div class="row footer" > <div class="footer-pane col-xs-12" id="footer_section" > <div class="col-xs-12" > <span class="pull-right footer-site-name" id="company_name" > Mattermost </span> </div> <div class="col-xs-12" > <span class="pull-right footer-link copyright" id="copyright" > © 2015-2017 Mattermost, Inc. </span> <span class="pull-right" > <a class="footer-link" href="http://testaboutlink" id="about_link" location="header_footer_template" rel="noopener noreferrer" target="_blank" > About </a> <a class="footer-link" href="http://testprivacypolicylink" id="privacy_link" location="header_footer_template" rel="noopener noreferrer" target="_blank" > Privacy Policy </a> <a class="footer-link" href="http://testtermsofservicelink" id="terms_link" location="header_footer_template" rel="noopener noreferrer" target="_blank" > Terms </a> <a class="footer-link" href="http://testhelplink" id="help_link" location="header_footer_template" rel="noopener noreferrer" target="_blank" > Help </a> </span> </div> </div> </div> </div> </div> `; exports[`components/HeaderFooterTemplate should set classes on body and #root on mount and unset on unmount 2`] = `<div />`;
2,352
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components
petrpan-code/mattermost/mattermost/webapp/channels/src/components/hint-toast/hint_toast.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import {HintToast} from './hint_toast'; describe('components/HintToast', () => { test('should match snapshot', () => { const wrapper = shallow( <HintToast onDismiss={jest.fn()} >{'A hint'}</HintToast>, ); expect(wrapper).toMatchSnapshot(); }); test('should fire onDismiss callback', () => { const dismissHandler = jest.fn(); const wrapper = shallow( <HintToast onDismiss={dismissHandler} >{'A hint'}</HintToast>, ); wrapper.find('.hint-toast__dismiss').simulate('click'); expect(dismissHandler).toHaveBeenCalled(); }); });
2,354
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/hint-toast
petrpan-code/mattermost/mattermost/webapp/channels/src/components/hint-toast/__snapshots__/hint_toast.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/HintToast should match snapshot 1`] = ` <div className="hint-toast" data-testid="hint-toast" > <div className="hint-toast__message" > A hint </div> <div className="hint-toast__dismiss" data-testid="dismissHintToast" onClick={[Function]} > <CloseIcon className="close-btn" id="dismissHintToast" /> </div> </div> `;
2,359
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components
petrpan-code/mattermost/mattermost/webapp/channels/src/components/info_toast/info_toast.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import type {ComponentProps} from 'react'; import {CheckIcon} from '@mattermost/compass-icons/components'; import InfoToast from './info_toast'; describe('components/InfoToast', () => { const baseProps: ComponentProps<typeof InfoToast> = { content: { icon: <CheckIcon/>, message: 'test', undo: jest.fn(), }, className: 'className', onExited: jest.fn(), }; test('should match snapshot', () => { const wrapper = shallow( <InfoToast {...baseProps} />, ); expect(wrapper).toMatchSnapshot(); }); test('should close the toast on undo', () => { const wrapper = shallow( <InfoToast {...baseProps} />, ); wrapper.find('button').simulate('click'); expect(baseProps.onExited).toHaveBeenCalled(); }); test('should close the toast on close button click', () => { const wrapper = shallow( <InfoToast {...baseProps} />, ); wrapper.find('.info-toast__icon_button').simulate('click'); expect(baseProps.onExited).toHaveBeenCalled(); }); });
2,361
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/info_toast
petrpan-code/mattermost/mattermost/webapp/channels/src/components/info_toast/__snapshots__/info_toast.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/InfoToast should match snapshot 1`] = ` <CSSTransition appear={true} classNames="toast" in={true} mountOnEnter={true} timeout={300} unmountOnExit={true} > <div className="info-toast className" > <CheckIcon /> <span> test </span> <button className="info-toast__undo" onClick={[Function]} > Undo </button> <ForwardRef className="info-toast__icon_button" icon="close" inverted={true} onClick={[Function]} size="sm" /> </div> </CSSTransition> `;
2,362
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/abstract_command.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import React from 'react'; import type {FormEvent} from 'react'; import {FormattedMessage} from 'react-intl'; import AbstractCommand from 'components/integrations/abstract_command'; import type {AbstractCommand as AbstractCommandClass} from 'components/integrations/abstract_command'; import {shallowWithIntl} from 'tests/helpers/intl-test-helper'; import {TestHelper} from 'utils/test_helper'; describe('components/integrations/AbstractCommand', () => { const header = {id: 'Header', defaultMessage: 'Header'}; const footer = {id: 'Footer', defaultMessage: 'Footer'}; const loading = {id: 'Loading', defaultMessage: 'Loading'}; const method: 'G' | 'P' | '' = 'G'; const command = { id: 'r5tpgt4iepf45jt768jz84djic', display_name: 'display_name', description: 'description', trigger: 'trigger', auto_complete: true, auto_complete_hint: 'auto_complete_hint', auto_complete_desc: 'auto_complete_desc', token: 'jb6oyqh95irpbx8fo9zmndkp1r', create_at: 1499722850203, creator_id: '88oybd1dwfdoxpkpw1h5kpbyco', delete_at: 0, icon_url: 'https://google.com/icon', method, team_id: 'm5gix3oye3du8ghk4ko6h9cq7y', update_at: 1504468859001, url: 'https://google.com/command', username: 'username', }; const team = TestHelper.getTeamMock({name: 'test', id: command.team_id}); const action = jest.fn().mockImplementation( () => { return new Promise<void>((resolve) => { process.nextTick(() => resolve()); }); }, ); const baseProps = { team, header, footer, loading, renderExtra: <div>{'renderExtra'}</div>, serverError: '', initialCommand: command, action, }; test('should match snapshot', () => { const wrapper = shallowWithIntl( <AbstractCommand {...baseProps}/>, ); expect(wrapper).toMatchSnapshot(); }); test('should match snapshot when header/footer/loading is a string', () => { const wrapper = shallowWithIntl( <AbstractCommand {...baseProps} header='Header as string' loading={'Loading as string'} footer={'Footer as string'} />, ); expect(wrapper).toMatchSnapshot(); }); test('should match snapshot, displays client error', () => { const newSeverError = 'server error'; const props = {...baseProps, serverError: newSeverError}; const wrapper = shallowWithIntl( <AbstractCommand {...props}/>, ); wrapper.find('#trigger').simulate('change', {target: {value: ''}}); wrapper.find('.btn-primary').simulate('click', {preventDefault: jest.fn()}); expect(wrapper).toMatchSnapshot(); expect(action).not.toBeCalled(); }); test('should call action function', () => { const wrapper = shallowWithIntl( <AbstractCommand {...baseProps}/>, ); wrapper.find('#displayName').simulate('change', {target: {value: 'name'}}); wrapper.find('.btn-primary').simulate('click', {preventDefault: jest.fn()}); expect(action).toBeCalled(); }); test('should match object returned by getStateFromCommand', () => { const wrapper = shallowWithIntl( <AbstractCommand {...baseProps}/>, ); const instance = wrapper.instance() as AbstractCommandClass; const expectedOutput = { autocomplete: true, autocompleteDescription: 'auto_complete_desc', autocompleteHint: 'auto_complete_hint', clientError: null, description: 'description', displayName: 'display_name', iconUrl: 'https://google.com/icon', method: 'G', saving: false, trigger: 'trigger', url: 'https://google.com/command', username: 'username', }; expect(instance.getStateFromCommand(command)).toEqual(expectedOutput); }); test('should match state when method is called', () => { const wrapper = shallowWithIntl( <AbstractCommand {...baseProps}/>, ); const instance = wrapper.instance() as AbstractCommandClass; const displayName = 'new display_name'; const displayNameEvent = {preventDefault: jest.fn(), target: {value: displayName}} as any; instance.updateDisplayName(displayNameEvent); expect(wrapper.state('displayName')).toEqual(displayName); const description = 'new description'; const descriptionEvent = {preventDefault: jest.fn(), target: {value: description}} as any; instance.updateDescription(descriptionEvent); expect(wrapper.state('description')).toEqual(description); const trigger = 'new trigger'; const triggerEvent = {preventDefault: jest.fn(), target: {value: trigger}} as any; instance.updateTrigger(triggerEvent); expect(wrapper.state('trigger')).toEqual(trigger); const url = 'new url'; const urlEvent = {preventDefault: jest.fn(), target: {value: url}} as any; instance.updateUrl(urlEvent); expect(wrapper.state('url')).toEqual(url); const method = 'P'; const methodEvent = {preventDefault: jest.fn(), target: {value: method}} as any; instance.updateMethod(methodEvent); expect(wrapper.state('method')).toEqual(method); const username = 'new username'; const usernameEvent = {preventDefault: jest.fn(), target: {value: username}} as any; instance.updateUsername(usernameEvent); expect(wrapper.state('username')).toEqual(username); const iconUrl = 'new iconUrl'; const iconUrlEvent = {preventDefault: jest.fn(), target: {value: iconUrl}} as any; instance.updateIconUrl(iconUrlEvent); expect(wrapper.state('iconUrl')).toEqual(iconUrl); const trueUpdateAutocompleteEvent = {target: {checked: true}} as any; const falseeUpdateAutocompleteEvent = {target: {checked: false}} as any; instance.updateAutocomplete(trueUpdateAutocompleteEvent); expect(wrapper.state('autocomplete')).toEqual(true); instance.updateAutocomplete(falseeUpdateAutocompleteEvent); expect(wrapper.state('autocomplete')).toEqual(false); const autocompleteHint = 'new autocompleteHint'; const autocompleteHintEvent = {preventDefault: jest.fn(), target: {value: autocompleteHint}} as any; instance.updateAutocompleteHint(autocompleteHintEvent); expect(wrapper.state('autocompleteHint')).toEqual(autocompleteHint); const autocompleteDescription = 'new autocompleteDescription'; const autocompleteDescriptionEvent = {preventDefault: jest.fn(), target: {value: autocompleteDescription}} as any; instance.updateAutocompleteDescription(autocompleteDescriptionEvent); expect(wrapper.state('autocompleteDescription')).toEqual(autocompleteDescription); }); test('should match state when handleSubmit is called', () => { const newAction = jest.fn().mockImplementation( () => { return new Promise<void>((resolve) => { process.nextTick(() => resolve()); }); }, ); const props = {...baseProps, action: newAction}; const wrapper = shallowWithIntl( <AbstractCommand {...props}/>, ); const instance = wrapper.instance() as AbstractCommandClass; expect(newAction).toHaveBeenCalledTimes(0); const evt = {preventDefault: jest.fn()} as unknown as FormEvent<Element>; const handleSubmit = instance.handleSubmit; handleSubmit(evt); expect(wrapper.state('saving')).toEqual(true); expect(wrapper.state('clientError')).toEqual(''); expect(newAction).toHaveBeenCalledTimes(1); // saving is true wrapper.setState({saving: true}); handleSubmit(evt); expect(wrapper.state('clientError')).toEqual(''); expect(newAction).toHaveBeenCalledTimes(1); // empty trigger wrapper.setState({saving: false, trigger: ''}); handleSubmit(evt); expect(wrapper.state('clientError')).toEqual( <FormattedMessage defaultMessage='A trigger word is required' id='add_command.triggerRequired' />, ); expect(newAction).toHaveBeenCalledTimes(1); // trigger that starts with a slash '/' wrapper.setState({saving: false, trigger: '//startwithslash'}); handleSubmit(evt); expect(wrapper.state('clientError')).toEqual( <FormattedMessage defaultMessage='A trigger word cannot begin with a /' id='add_command.triggerInvalidSlash' />, ); expect(newAction).toHaveBeenCalledTimes(1); // trigger with space wrapper.setState({saving: false, trigger: '/trigger with space'}); handleSubmit(evt); expect(wrapper.state('clientError')).toEqual( <FormattedMessage defaultMessage='A trigger word must not contain spaces' id='add_command.triggerInvalidSpace' />, ); expect(newAction).toHaveBeenCalledTimes(1); // trigger above maximum length wrapper.setState({saving: false, trigger: '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'}); handleSubmit(evt); expect(wrapper.state('clientError')).toEqual( <FormattedMessage defaultMessage='A trigger word must contain between {min} and {max} characters' id='add_command.triggerInvalidLength' values={{max: 128, min: 1}} />, ); expect(newAction).toHaveBeenCalledTimes(1); // good triggers wrapper.setState({saving: false, trigger: '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678'}); handleSubmit(evt); expect(wrapper.state('clientError')).toEqual(''); expect(newAction).toHaveBeenCalledTimes(2); wrapper.setState({saving: false, trigger: '/trigger'}); handleSubmit(evt); expect(wrapper.state('clientError')).toEqual(''); expect(newAction).toHaveBeenCalledTimes(3); wrapper.setState({saving: false, trigger: 'trigger'}); handleSubmit(evt); expect(wrapper.state('clientError')).toEqual(''); expect(newAction).toHaveBeenCalledTimes(4); // empty url wrapper.setState({saving: false, trigger: 'trigger', url: ''}); handleSubmit(evt); expect(wrapper.state('clientError')).toEqual( <FormattedMessage defaultMessage='A request URL is required' id='add_command.urlRequired' />, ); expect(newAction).toHaveBeenCalledTimes(4); }); });
2,364
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/abstract_incoming_hook.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import type {Team} from '@mattermost/types/teams'; import ChannelSelect from 'components/channel_select'; import AbstractIncomingWebhook from 'components/integrations/abstract_incoming_webhook'; type AbstractIncomingWebhookProps = React.ComponentProps<typeof AbstractIncomingWebhook>; describe('components/integrations/AbstractIncomingWebhook', () => { const team: Team = {id: 'team_id', create_at: 0, update_at: 0, delete_at: 0, display_name: 'team_name', name: 'team_name', description: 'team_description', email: 'team_email', type: 'I', company_name: 'team_company_name', allowed_domains: 'team_allowed_domains', invite_id: 'team_invite_id', allow_open_invite: false, scheme_id: 'team_scheme_id', group_constrained: false, }; const header = {id: 'header_id', defaultMessage: 'Header'}; const footer = {id: 'footer_id', defaultMessage: 'Footer'}; const loading = {id: 'loading_id', defaultMessage: 'Loading'}; const serverError = ''; const initialHook = { display_name: 'testIncomingWebhook', channel_id: '88cxd9wpzpbpfp8pad78xj75pr', description: 'testing', id: 'test_id', team_id: 'test_team_id', create_at: 0, update_at: 0, delete_at: 0, user_id: 'test_user_id', username: '', icon_url: '', channel_locked: false, }; const enablePostUsernameOverride = true; const enablePostIconOverride = true; const action = jest.fn().mockImplementation( () => { return new Promise<void>((resolve) => { process.nextTick(() => resolve()); }); }, ); const requiredProps: AbstractIncomingWebhookProps = { team, header, footer, loading, serverError, initialHook, enablePostUsernameOverride, enablePostIconOverride, action, }; test('should match snapshot', () => { const wrapper = shallow(<AbstractIncomingWebhook {...requiredProps}/>); expect(wrapper).toMatchSnapshot(); }); test('should match snapshot, on serverError', () => { const newServerError = 'serverError'; const props = {...requiredProps, serverError: newServerError}; const wrapper = shallow(<AbstractIncomingWebhook {...props}/>); expect(wrapper).toMatchSnapshot(); }); test('should match snapshot, displays client error when no initial hook', () => { const props = {...requiredProps}; delete props.initialHook; const wrapper = shallow(<AbstractIncomingWebhook {...props}/>); wrapper.find('.btn-primary').simulate('click', {preventDefault() { return jest.fn(); }}); expect(action).not.toBeCalled(); expect(wrapper).toMatchSnapshot(); }); test('should match snapshot, hiding post username if not enabled', () => { const props = { ...requiredProps, enablePostUsernameOverride: false, }; const wrapper = shallow(<AbstractIncomingWebhook {...props}/>); expect(wrapper).toMatchSnapshot(); }); test('should match snapshot, hiding post icon url if not enabled', () => { const props = { ...requiredProps, enablePostIconOverride: false, }; const wrapper = shallow(<AbstractIncomingWebhook {...props}/>); expect(wrapper).toMatchSnapshot(); }); test('should call action function', () => { const wrapper = shallow(<AbstractIncomingWebhook {...requiredProps}/>); expect(wrapper).toMatchSnapshot(); wrapper.find('#displayName').simulate('change', {target: {value: 'name'}}); wrapper.find('.btn-primary').simulate('click', {preventDefault() { return jest.fn(); }}); expect(action).toBeCalled(); expect(action).toHaveBeenCalledTimes(1); }); test('should update state.channelId when on channel change', () => { const newChannelId = 'new_channel_id'; const evt = { preventDefault: jest.fn(), target: {value: newChannelId}, }; const wrapper = shallow(<AbstractIncomingWebhook {...requiredProps}/>); wrapper.find(ChannelSelect).simulate('change', evt); expect(wrapper.state('channelId')).toBe(newChannelId); }); test('should update state.description when on description change', () => { const newDescription = 'new_description'; const evt = { preventDefault: jest.fn(), target: {value: newDescription}, }; const wrapper = shallow(<AbstractIncomingWebhook {...requiredProps}/>); wrapper.find('#description').simulate('change', evt); expect(wrapper.state('description')).toBe(newDescription); }); test('should update state.username on post username change', () => { const newUsername = 'new_username'; const evt = { preventDefault: jest.fn(), target: {value: newUsername}, }; const wrapper = shallow(<AbstractIncomingWebhook {...requiredProps}/>); wrapper.find('#username').simulate('change', evt); expect(wrapper.state('username')).toBe(newUsername); }); test('should update state.iconURL on post icon url change', () => { const newIconURL = 'http://example.com/icon'; const evt = { preventDefault: jest.fn(), target: {value: newIconURL}, }; const wrapper = shallow(<AbstractIncomingWebhook {...requiredProps}/>); wrapper.find('#iconURL').simulate('change', evt); expect(wrapper.state('iconURL')).toBe(newIconURL); }); });
2,366
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/abstract_oauth_app.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React, {type ChangeEvent} from 'react'; import {FormattedMessage} from 'react-intl'; import AbstractOAuthApp from 'components/integrations/abstract_oauth_app'; import {TestHelper} from 'utils/test_helper'; describe('components/integrations/AbstractOAuthApp', () => { const header = {id: 'Header', defaultMessage: 'Header'}; const footer = {id: 'Footer', defaultMessage: 'Footer'}; const loading = {id: 'Loading', defaultMessage: 'Loading'}; const initialApp = { id: 'facxd9wpzpbpfp8pad78xj75pr', name: 'testApp', client_secret: '88cxd9wpzpbpfp8pad78xj75pr', create_at: 1501365458934, creator_id: '88oybd1dwfdoxpkpw1h5kpbyco', description: 'testing', homepage: 'https://test.com', icon_url: 'https://test.com/icon', is_trusted: true, update_at: 1501365458934, callback_urls: ['https://test.com/callback', 'https://test.com/callback2'], }; const action = jest.fn().mockImplementation( () => { return new Promise<void>((resolve) => { process.nextTick(() => resolve()); }); }, ); const team = TestHelper.getTeamMock({name: 'test', id: initialApp.id}); const baseProps = { team, header, footer, loading, renderExtra: <div>{'renderExtra'}</div>, serverError: '', initialApp, action: jest.fn(), }; test('should match snapshot', () => { const wrapper = shallow( <AbstractOAuthApp {...baseProps}/>, ); expect(wrapper).toMatchSnapshot(); }); test('should match snapshot, displays client error', () => { const newServerError = 'serverError'; const props = {...baseProps, serverError: newServerError}; const wrapper = shallow( <AbstractOAuthApp {...props}/>, ); wrapper.find('#callbackUrls').simulate('change', {target: {value: ''}}); wrapper.find('.btn-primary').simulate('click', {preventDefault() { return jest.fn(); }}); expect(action).not.toBeCalled(); expect(wrapper).toMatchSnapshot(); }); test('should call action function', () => { const props = {...baseProps, action}; const wrapper = shallow( <AbstractOAuthApp {...props}/>, ); wrapper.find('#name').simulate('change', {target: {value: 'name'}}); wrapper.find('.btn-primary').simulate('click', {preventDefault() { return jest.fn(); }}); expect(action).toBeCalled(); }); test('should have correct state when updateName is called', () => { const props = {...baseProps, action}; const wrapper = shallow<AbstractOAuthApp>( <AbstractOAuthApp {...props}/>, ); const evt = {preventDefault: jest.fn(), target: {value: 'new name'}} as unknown as ChangeEvent<HTMLInputElement>; wrapper.instance().updateName(evt); expect(wrapper.state('name')).toEqual('new name'); const evt2 = {preventDefault: jest.fn(), target: {value: 'another name'}} as unknown as ChangeEvent<HTMLInputElement>; wrapper.instance().updateName(evt2); expect(wrapper.state('name')).toEqual('another name'); }); test('should have correct state when updateTrusted is called', () => { const props = {...baseProps, action}; const wrapper = shallow<AbstractOAuthApp>( <AbstractOAuthApp {...props}/>, ); const evt = {preventDefault: jest.fn(), target: {value: 'false'}} as unknown as ChangeEvent<HTMLInputElement>; wrapper.instance().updateTrusted(evt); expect(wrapper.state('is_trusted')).toEqual(false); const evt2 = {preventDefault: jest.fn(), target: {value: 'true'}} as unknown as ChangeEvent<HTMLInputElement>; wrapper.instance().updateTrusted(evt2); expect(wrapper.state('is_trusted')).toEqual(true); }); test('should have correct state when updateDescription is called', () => { const props = {...baseProps, action}; const wrapper = shallow<AbstractOAuthApp>( <AbstractOAuthApp {...props}/>, ); const evt = {preventDefault: jest.fn(), target: {value: 'new description'}} as unknown as ChangeEvent<HTMLInputElement>; wrapper.instance().updateDescription(evt); expect(wrapper.state('description')).toEqual('new description'); const evt2 = {preventDefault: jest.fn(), target: {value: 'another description'}} as unknown as ChangeEvent<HTMLInputElement>; wrapper.instance().updateDescription(evt2); expect(wrapper.state('description')).toEqual('another description'); }); test('should have correct state when updateHomepage is called', () => { const props = {...baseProps, action}; const wrapper = shallow<AbstractOAuthApp>( <AbstractOAuthApp {...props}/>, ); const evt = {preventDefault: jest.fn(), target: {value: 'new homepage'}} as unknown as ChangeEvent<HTMLInputElement>; wrapper.instance().updateHomepage(evt); expect(wrapper.state('homepage')).toEqual('new homepage'); const evt2 = {preventDefault: jest.fn(), target: {value: 'another homepage'}} as unknown as ChangeEvent<HTMLInputElement>; wrapper.instance().updateHomepage(evt2); expect(wrapper.state('homepage')).toEqual('another homepage'); }); test('should have correct state when updateIconUrl is called', () => { const props = {...baseProps, action}; const wrapper = shallow<AbstractOAuthApp>( <AbstractOAuthApp {...props}/>, ); wrapper.setState({has_icon: true}); const evt = {preventDefault: jest.fn(), target: {value: 'https://test.com/new_icon_url'}} as unknown as ChangeEvent<HTMLInputElement>; wrapper.instance().updateIconUrl(evt); expect(wrapper.state('icon_url')).toEqual('https://test.com/new_icon_url'); expect(wrapper.state('has_icon')).toEqual(false); wrapper.setState({has_icon: true}); const evt2 = {preventDefault: jest.fn(), target: {value: 'https://test.com/another_icon_url'}} as unknown as ChangeEvent<HTMLInputElement>; wrapper.instance().updateIconUrl(evt2); expect(wrapper.state('icon_url')).toEqual('https://test.com/another_icon_url'); expect(wrapper.state('has_icon')).toEqual(false); }); test('should have correct state when handleSubmit is called', () => { const props = {...baseProps, action}; const wrapper = shallow<AbstractOAuthApp>( <AbstractOAuthApp {...props}/>, ); const newState = {saving: false, name: 'name', description: 'description', homepage: 'homepage'}; const evt = {preventDefault: jest.fn()} as any; wrapper.setState({saving: true}); wrapper.instance().handleSubmit(evt); expect(evt.preventDefault).toHaveBeenCalled(); wrapper.setState(newState); wrapper.instance().handleSubmit(evt); expect(wrapper.state('saving')).toEqual(true); expect(wrapper.state('clientError')).toEqual(''); wrapper.setState({...newState, name: ''}); wrapper.instance().handleSubmit(evt); expect(wrapper.state('saving')).toEqual(false); expect(wrapper.state('clientError')).toEqual( <FormattedMessage defaultMessage='Name for the OAuth 2.0 application is required.' id='add_oauth_app.nameRequired' />, ); wrapper.setState({...newState, description: ''}); wrapper.instance().handleSubmit(evt); expect(wrapper.state('saving')).toEqual(false); expect(wrapper.state('clientError')).toEqual( <FormattedMessage defaultMessage='Description for the OAuth 2.0 application is required.' id='add_oauth_app.descriptionRequired' />, ); wrapper.setState({...newState, homepage: ''}); wrapper.instance().handleSubmit(evt); expect(wrapper.state('saving')).toEqual(false); expect(wrapper.state('clientError')).toEqual( <FormattedMessage defaultMessage='Homepage for the OAuth 2.0 application is required.' id='add_oauth_app.homepageRequired' />, ); }); });
2,368
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/abstract_outgoing_webhook.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import type {Team} from '@mattermost/types/teams'; import ChannelSelect from 'components/channel_select'; import AbstractOutgoingWebhook from 'components/integrations/abstract_outgoing_webhook'; describe('components/integrations/AbstractOutgoingWebhook', () => { const team: Team = { id: 'team_id', create_at: 0, update_at: 0, delete_at: 0, display_name: 'team_name', name: 'team_name', description: 'team_description', email: 'team_email', type: 'I', company_name: 'team_company_name', allowed_domains: 'team_allowed_domains', invite_id: 'team_invite_id', allow_open_invite: false, scheme_id: 'team_scheme_id', group_constrained: false, }; const header = {id: 'header_id', defaultMessage: 'Header'}; const footer = {id: 'footer_id', defaultMessage: 'Footer'}; const loading = {id: 'loading_id', defaultMessage: 'Loading'}; const initialHook = { display_name: 'testOutgoingWebhook', channel_id: '88cxd9wpzpbpfp8pad78xj75pr', creator_id: 'test_creator_id', description: 'testing', id: 'test_id', team_id: 'test_team_id', token: 'test_token', trigger_words: ['test', 'trigger', 'word'], trigger_when: 0, callback_urls: ['callbackUrl1.com', 'callbackUrl2.com'], content_type: 'test_content_type', create_at: 0, update_at: 0, delete_at: 0, user_id: 'test_user_id', username: '', icon_url: '', channel_locked: false, }; const action = jest.fn().mockImplementation( () => { return new Promise<void>((resolve) => { process.nextTick(() => resolve()); }); }, ); const requiredProps = { team, header, footer, loading, initialHook, enablePostUsernameOverride: false, enablePostIconOverride: false, renderExtra: '', serverError: '', action, }; test('should match snapshot', () => { const wrapper = shallow(<AbstractOutgoingWebhook {...requiredProps}/>); expect(wrapper).toMatchSnapshot(); }); test('should not render username in case of enablePostUsernameOverride is false ', () => { const usernameTrueProps = {...requiredProps}; const wrapper = shallow(<AbstractOutgoingWebhook {...usernameTrueProps}/>); expect(wrapper.find('#username')).toHaveLength(0); }); test('should not render post icon override in case of enablePostIconOverride is false ', () => { const iconUrlTrueProps = {...requiredProps}; const wrapper = shallow(<AbstractOutgoingWebhook {...iconUrlTrueProps}/>); expect(wrapper.find('#iconURL')).toHaveLength(0); }); test('should render username in case of enablePostUsernameOverride is true ', () => { const usernameTrueProps = {...requiredProps, enablePostUsernameOverride: true}; const wrapper = shallow(<AbstractOutgoingWebhook {...usernameTrueProps}/>); expect(wrapper.find('#username')).toHaveLength(1); }); test('should render post icon override in case of enablePostIconOverride is true ', () => { const iconUrlTrueProps = {...requiredProps, enablePostIconOverride: true}; const wrapper = shallow(<AbstractOutgoingWebhook {...iconUrlTrueProps}/>); expect(wrapper.find('#iconURL')).toHaveLength(1); }); test('should update state.channelId when on channel change', () => { const newChannelId = 'new_channel_id'; const evt = { preventDefault: jest.fn(), target: {value: newChannelId}, }; const wrapper = shallow(<AbstractOutgoingWebhook {...requiredProps}/>); wrapper.find(ChannelSelect).simulate('change', evt); expect(wrapper.state('channelId')).toBe(newChannelId); }); test('should update state.description when on description change', () => { const newDescription = 'new_description'; const evt = { preventDefault: jest.fn(), target: {value: newDescription}, }; const wrapper = shallow(<AbstractOutgoingWebhook {...requiredProps}/>); wrapper.find('#description').simulate('change', evt); expect(wrapper.state('description')).toBe(newDescription); }); test('should update state.username on post username change', () => { const usernameTrueProps = {...requiredProps, enablePostUsernameOverride: true}; const newUsername = 'new_username'; const evt = { preventDefault: jest.fn(), target: {value: newUsername}, }; const wrapper = shallow(<AbstractOutgoingWebhook {...usernameTrueProps}/>); wrapper.find('#username').simulate('change', evt); expect(wrapper.state('username')).toBe(newUsername); }); test('should update state.triggerWhen on selection change', () => { const wrapper = shallow(<AbstractOutgoingWebhook {...requiredProps}/>); expect(wrapper.state('triggerWhen')).toBe(0); const selector = wrapper.find('#triggerWhen'); selector.simulate('change', {target: {value: 1}}); console.log('selector: ', selector.debug()); expect(wrapper.state('triggerWhen')).toBe(1); }); test('should call action function', () => { const wrapper = shallow(<AbstractOutgoingWebhook {...requiredProps}/>); wrapper.find('#displayName').simulate('change', {target: {value: 'name'}}); wrapper.find('.btn-primary').simulate('click', {preventDefault() { return jest.fn(); }}); expect(action).toBeCalled(); expect(action).toHaveBeenCalledTimes(1); }); });
2,371
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/installed_command.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import InstalledCommand from 'components/integrations/installed_command'; import {TestHelper} from 'utils/test_helper'; describe('components/integrations/InstalledCommand', () => { const team = TestHelper.getTeamMock({name: 'team_name'}); const command = TestHelper.getCommandMock({ id: 'r5tpgt4iepf45jt768jz84djic', display_name: 'display_name', description: 'description', trigger: 'trigger', auto_complete: true, auto_complete_hint: 'auto_complete_hint', token: 'testToken', create_at: 1499722850203, }); const creator = TestHelper.getUserMock({username: 'username'}); const requiredProps = { team, command, onRegenToken: jest.fn(), onDelete: jest.fn(), creator, canChange: false, }; test('should match snapshot', () => { const wrapper = shallow(<InstalledCommand {...requiredProps}/>); expect(wrapper).toMatchSnapshot(); const trigger = `- /${command.trigger} ${command.auto_complete_hint}`; expect(wrapper.find('.item-details__trigger').text()).toBe(trigger); expect(wrapper.find('.item-details__name').text()).toBe(command.display_name); expect(wrapper.find('.item-details__description').text()).toBe(command.description); }); test('should match snapshot, not autocomplete, no display_name/description/auto_complete_hint', () => { const minCommand = TestHelper.getCommandMock({ id: 'r5tpgt4iepf45jt768jz84djic', trigger: 'trigger', auto_complete: false, token: 'testToken', create_at: 1499722850203, }); const props = {...requiredProps, command: minCommand}; const wrapper = shallow(<InstalledCommand {...props}/>); expect(wrapper).toMatchSnapshot(); const trigger = `- /${command.trigger}`; expect(wrapper.find('.item-details__trigger').text()).toBe(trigger); }); test('should call onRegenToken function', () => { const onRegenToken = jest.fn(); const canChange = true; const props = {...requiredProps, onRegenToken, canChange}; const wrapper = shallow(<InstalledCommand {...props}/>); expect(wrapper).toMatchSnapshot(); wrapper.find('div.item-actions button').first().simulate('click', {preventDefault: jest.fn()}); expect(onRegenToken).toHaveBeenCalledTimes(1); expect(onRegenToken).toHaveBeenCalledWith(props.command); }); test('should call onDelete function', () => { const onDelete = jest.fn(); const canChange = true; const props = {...requiredProps, onDelete, canChange}; const wrapper = shallow<InstalledCommand>(<InstalledCommand {...props}/>); expect(wrapper).toMatchSnapshot(); wrapper.instance().handleDelete(); expect(onDelete).toHaveBeenCalledTimes(1); expect(onDelete).toHaveBeenCalledWith(props.command); }); test('should filter out command', () => { const filter = 'no_match'; const props = {...requiredProps, filter}; const wrapper = shallow(<InstalledCommand {...props}/>); expect(wrapper).toMatchSnapshot(); }); });
2,373
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/installed_incoming_webhook.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import {Link} from 'react-router-dom'; import type {IncomingWebhook} from '@mattermost/types/integrations'; import DeleteIntegrationLink from 'components/integrations/delete_integration_link'; import InstalledIncomingWebhook from 'components/integrations/installed_incoming_webhook'; describe('components/integrations/InstalledIncomingWebhook', () => { const incomingWebhook: IncomingWebhook = { id: '9w96t4nhbfdiij64wfqors4i1r', channel_id: '1jiw9kphbjrntfyrm7xpdcya4o', create_at: 1502455422406, delete_at: 0, description: 'build status', display_name: 'build', team_id: 'eatxocwc3bg9ffo9xyybnj4omr', update_at: 1502455422406, user_id: 'zaktnt8bpbgu8mb6ez9k64r7sa', username: 'username', icon_url: 'http://test/icon.png', channel_locked: false, }; const teamId = 'testteamid'; test('should match snapshot', () => { function emptyFunction() {} //eslint-disable-line no-empty-function const wrapper = shallow<InstalledIncomingWebhook>( <InstalledIncomingWebhook key={1} incomingWebhook={incomingWebhook} onDelete={emptyFunction} creator={{username: 'creator'}} canChange={true} team={{ id: teamId, name: 'test', create_at: 1502455422406, delete_at: 0, update_at: 1502455422406, type: 'O', display_name: 'name', scheme_id: 'id', allow_open_invite: false, group_constrained: false, description: '', email: '', company_name: '', allowed_domains: '', invite_id: '', }} channel={{ id: '1jiw9kphbjrntfyrm7xpdcya4o', name: 'town-square', create_at: 1502455422406, delete_at: 0, update_at: 1502455422406, team_id: teamId, type: 'O', display_name: 'name', header: 'header', purpose: 'purpose', last_post_at: 0, last_root_post_at: 0, creator_id: 'id', scheme_id: 'id', group_constrained: false, }} />, ); expect(wrapper).toMatchSnapshot(); }); test('should not have edit and delete actions if user does not have permissions to change', () => { function emptyFunction() {} //eslint-disable-line no-empty-function const wrapper = shallow<InstalledIncomingWebhook>( <InstalledIncomingWebhook key={1} incomingWebhook={incomingWebhook} onDelete={emptyFunction} creator={{username: 'creator'}} canChange={false} team={{ id: teamId, name: 'test', create_at: 1502455422406, delete_at: 0, update_at: 1502455422406, type: 'O', display_name: 'name', scheme_id: 'id', allow_open_invite: false, group_constrained: false, description: '', email: '', company_name: '', allowed_domains: '', invite_id: '', }} channel={{ id: '1jiw9kphbjrntfyrm7xpdcya4o', name: 'town-square', create_at: 1502455422406, delete_at: 0, update_at: 1502455422406, team_id: teamId, type: 'O', display_name: 'name', header: 'header', purpose: 'purpose', last_post_at: 0, last_root_post_at: 0, creator_id: 'id', scheme_id: 'id', group_constrained: false, }} />, ); expect(wrapper.find('.item-actions').length).toBe(0); }); test('should have edit and delete actions if user can change webhook', () => { function emptyFunction() {} //eslint-disable-line no-empty-function const wrapper = shallow<InstalledIncomingWebhook>( <InstalledIncomingWebhook key={1} incomingWebhook={incomingWebhook} onDelete={emptyFunction} creator={{username: 'creator'}} canChange={true} team={{ id: teamId, name: 'test', create_at: 1502455422406, delete_at: 0, update_at: 1502455422406, type: 'O', display_name: 'name', scheme_id: 'id', allow_open_invite: false, group_constrained: false, description: '', email: '', company_name: '', allowed_domains: '', invite_id: '', }} channel={{ id: '1jiw9kphbjrntfyrm7xpdcya4o', name: 'town-square', create_at: 1502455422406, delete_at: 0, update_at: 1502455422406, team_id: teamId, type: 'O', display_name: 'name', header: 'header', purpose: 'purpose', last_post_at: 0, last_root_post_at: 0, creator_id: 'id', scheme_id: 'id', group_constrained: false, }} />, ); expect(wrapper.find('.item-actions').find(Link).exists()).toBe(true); expect(wrapper.find('.item-actions').find(DeleteIntegrationLink).exists()).toBe(true); }); test('Should have the same name and description on view as it has in incomingWebhook', () => { function emptyFunction() {} //eslint-disable-line no-empty-function const wrapper = shallow<InstalledIncomingWebhook>( <InstalledIncomingWebhook key={1} incomingWebhook={incomingWebhook} onDelete={emptyFunction} creator={{username: 'creator'}} canChange={false} team={{ id: teamId, name: 'test', create_at: 1502455422406, delete_at: 0, update_at: 1502455422406, type: 'O', display_name: 'name', scheme_id: 'id', allow_open_invite: false, group_constrained: false, description: '', email: '', company_name: '', allowed_domains: '', invite_id: '', }} channel={{ id: '1jiw9kphbjrntfyrm7xpdcya4o', name: 'town-square', create_at: 1502455422406, delete_at: 0, update_at: 1502455422406, team_id: teamId, type: 'O', display_name: 'name', header: 'header', purpose: 'purpose', last_post_at: 0, last_root_post_at: 0, creator_id: 'id', scheme_id: 'id', group_constrained: false, }} />, ); expect(wrapper.find('.item-details__description').text()).toBe('build status'); expect(wrapper.find('.item-details__name').text()).toBe('build'); }); test('Should not display description as it is null', () => { function emptyFunction() {} //eslint-disable-line no-empty-function const newIncomingWebhook: IncomingWebhook = {...incomingWebhook, description: ''}; const wrapper = shallow<InstalledIncomingWebhook>( <InstalledIncomingWebhook key={1} incomingWebhook={newIncomingWebhook} onDelete={emptyFunction} creator={{username: 'creator'}} canChange={false} team={{ id: teamId, name: 'test', create_at: 1502455422406, delete_at: 0, update_at: 1502455422406, type: 'O', display_name: 'name', scheme_id: 'id', allow_open_invite: false, group_constrained: false, description: '', email: '', company_name: '', allowed_domains: '', invite_id: '', }} channel={{ id: '1jiw9kphbjrntfyrm7xpdcya4o', name: 'town-square', create_at: 1502455422406, delete_at: 0, update_at: 1502455422406, team_id: teamId, type: 'O', display_name: 'name', header: 'header', purpose: 'purpose', last_post_at: 0, last_root_post_at: 0, creator_id: 'id', scheme_id: 'id', group_constrained: false, }} />, ); expect(wrapper.find('.item-details__description').length).toBe(0); }); test('Should not render any nodes as there are no filtered results', () => { function emptyFunction() {} //eslint-disable-line no-empty-function const wrapper = shallow<InstalledIncomingWebhook>( <InstalledIncomingWebhook key={1} incomingWebhook={incomingWebhook} onDelete={emptyFunction} creator={{username: 'creator'}} filter={'someLongText'} canChange={false} team={{ id: teamId, name: 'test', create_at: 1502455422406, delete_at: 0, update_at: 1502455422406, type: 'O', display_name: 'name', scheme_id: 'id', allow_open_invite: false, group_constrained: false, description: '', email: '', company_name: '', allowed_domains: '', invite_id: '', }} channel={{ id: '1jiw9kphbjrntfyrm7xpdcya4o', name: 'town-square', create_at: 1502455422406, delete_at: 0, update_at: 1502455422406, team_id: teamId, type: 'O', display_name: 'name', header: 'header', purpose: 'purpose', last_post_at: 0, last_root_post_at: 0, creator_id: 'id', scheme_id: 'id', group_constrained: false, }} />, ); expect(wrapper.getElement()).toBe(null); }); test('Should render a webhook item as filtered result is true', () => { function emptyFunction() {} //eslint-disable-line no-empty-function const wrapper = shallow<InstalledIncomingWebhook>( <InstalledIncomingWebhook key={1} incomingWebhook={incomingWebhook} onDelete={emptyFunction} creator={{username: 'creator'}} filter={'buil'} canChange={true} team={{ id: teamId, name: 'test', create_at: 1502455422406, delete_at: 0, update_at: 1502455422406, type: 'O', display_name: 'name', scheme_id: 'id', allow_open_invite: false, group_constrained: false, description: '', email: '', company_name: '', allowed_domains: '', invite_id: '', }} channel={{ id: '1jiw9kphbjrntfyrm7xpdcya4o', name: 'town-square', create_at: 1502455422406, delete_at: 0, update_at: 1502455422406, team_id: teamId, type: 'O', display_name: 'name', header: 'header', purpose: 'purpose', last_post_at: 0, last_root_post_at: 0, creator_id: 'id', scheme_id: 'id', group_constrained: false, }} />, ); expect(wrapper.find('.item-details').exists()).toBe(true); }); });
2,375
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/installed_outgoing_webhook.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import {Link} from 'react-router-dom'; import type {Channel} from '@mattermost/types/channels'; import type {OutgoingWebhook} from '@mattermost/types/integrations'; import type {Team} from '@mattermost/types/teams'; import type {UserProfile} from '@mattermost/types/users'; import DeleteIntegrationLink from 'components/integrations/delete_integration_link'; import InstalledOutgoingWebhook, {matchesFilter} from 'components/integrations/installed_outgoing_webhook'; import {TestHelper} from 'utils/test_helper'; describe('components/integrations/InstalledOutgoingWebhook', () => { const team: Team = TestHelper.getTeamMock({ id: 'testteamid', name: 'test', }); const channel: Channel = TestHelper.getChannelMock({ id: '1jiw9kphbjrntfyrm7xpdcya4o', name: 'town-square', display_name: 'Town Square', }); const userProfile: UserProfile = TestHelper.getUserMock(); const outgoingWebhook: OutgoingWebhook = TestHelper.getOutgoingWebhookMock({ callback_urls: ['http://adsfdasd.com'], channel_id: 'mdpzfpfcxi85zkkqkzkch4b85h', content_type: 'application/x-www-form-urlencoded', create_at: 1508327769020, creator_id: 'zaktnt8bpbgu8mb6ez9k64r7sa', delete_at: 0, description: 'build status', display_name: 'build', id: '7h88x419ubbyuxzs7dfwtgkffr', team_id: 'eatxocwc3bg9ffo9xyybnj4omr', token: 'xoxz1z7c3tgi9xhrfudn638q9r', trigger_when: 0, trigger_words: ['build'], update_at: 1508329149618, username: 'hook_user_name', }); const baseProps = { outgoingWebhook, onRegenToken: () => {}, //eslint-disable-line no-empty-function onDelete: () => {}, //eslint-disable-line no-empty-function filter: '', creator: userProfile, canChange: true, team, channel, }; test('should match snapshot', () => { const wrapper = shallow( <InstalledOutgoingWebhook {...baseProps}/>, ); expect(wrapper).toMatchSnapshot(); }); test('should not have edit and delete actions if user does not have permissions to change', () => { const newCanChange = false; const props = {...baseProps, canChange: newCanChange}; const wrapper = shallow( <InstalledOutgoingWebhook {...props}/>, ); expect(wrapper.find('.item-actions').length).toBe(0); }); test('should have edit and delete actions if user can change webhook', () => { const wrapper = shallow( <InstalledOutgoingWebhook {...baseProps}/>, ); expect(wrapper.find('.item-actions').find(Link).exists()).toBe(true); expect(wrapper.find('.item-actions').find(DeleteIntegrationLink).exists()).toBe(true); }); test('Should have the same name and description on view as it has in outgoingWebhook', () => { const newCanChange = false; const props = {...baseProps, canChange: newCanChange}; const wrapper = shallow( <InstalledOutgoingWebhook {...props}/>, ); expect(wrapper.find('.item-details__description').text()).toBe('build status'); expect(wrapper.find('.item-details__name').text()).toBe('build'); }); test('Should not display description as it is null', () => { const newOutgoingWebhook = TestHelper.getOutgoingWebhookMock({...outgoingWebhook, description: undefined}); const props = {...baseProps, outgoingWebhook: newOutgoingWebhook}; const wrapper = shallow( <InstalledOutgoingWebhook {...props}/>, ); expect(wrapper.find('.item-details__description').length).toBe(0); }); test('Should not render any nodes as there are no filtered results', () => { const newFilter = 'someLongText'; const props = {...baseProps, filter: newFilter}; const wrapper = shallow( <InstalledOutgoingWebhook {...props}/>, ); expect(wrapper.getElement()).toBe(null); }); test('Should render a webhook item as filtered result is true', () => { const newFilter = 'buil'; const props = {...baseProps, filter: newFilter}; const wrapper = shallow( <InstalledOutgoingWebhook {...props}/>, ); expect(wrapper.find('.item-details').exists()).toBe(true); }); test('Should call onRegenToken function once', () => { const newFilter = 'buil'; const newOnRegenToken = jest.fn(); const props = {...baseProps, filter: newFilter, onRegenToken: newOnRegenToken}; const wrapper = shallow( <InstalledOutgoingWebhook {...props}/>, ); wrapper.find('.item-actions button').first().simulate('click', {preventDefault() { return jest.fn(); }}); expect(newOnRegenToken).toHaveBeenCalledTimes(1); }); test('Should call onDelete function once', () => { const newFilter = 'buil'; const newOnDelete = jest.fn(); const props = {...baseProps, filter: newFilter, onDelete: newOnDelete}; const wrapper = shallow( <InstalledOutgoingWebhook {...props}/>, ); wrapper.find(DeleteIntegrationLink).first().prop('onDelete')(); expect(newOnDelete).toHaveBeenCalledTimes(1); }); test('Should match snapshot of makeDisplayName', () => { const wrapper = shallow( <InstalledOutgoingWebhook {...baseProps}/>, ); const instance = wrapper.instance() as InstalledOutgoingWebhook; // displays webhook's display name expect(instance.makeDisplayName(TestHelper.getOutgoingWebhookMock({display_name: 'hook display name'}), TestHelper.getChannelMock())).toMatchSnapshot(); // displays channel's display name expect(instance.makeDisplayName(TestHelper.getOutgoingWebhookMock(), TestHelper.getChannelMock({display_name: 'channel display name'}))).toMatchSnapshot(); // displays a private hook expect(instance.makeDisplayName(TestHelper.getOutgoingWebhookMock(), TestHelper.getChannelMock())).toMatchSnapshot(); }); test('Should match result when matchesFilter is called', () => { expect(matchesFilter(TestHelper.getOutgoingWebhookMock(), TestHelper.getChannelMock(), 'word')).toEqual(false); expect(matchesFilter(TestHelper.getOutgoingWebhookMock({display_name: undefined}), TestHelper.getChannelMock(), 'word')).toEqual(false); expect(matchesFilter(TestHelper.getOutgoingWebhookMock({description: undefined}), TestHelper.getChannelMock(), 'word')).toEqual(false); expect(matchesFilter(TestHelper.getOutgoingWebhookMock({trigger_words: undefined}), TestHelper.getChannelMock(), 'word')).toEqual(false); expect(matchesFilter(TestHelper.getOutgoingWebhookMock(), TestHelper.getChannelMock({name: undefined}), 'channel')).toEqual(false); expect(matchesFilter(TestHelper.getOutgoingWebhookMock(), TestHelper.getChannelMock(), '')).toEqual(true); expect(matchesFilter(TestHelper.getOutgoingWebhookMock({display_name: 'Word'}), TestHelper.getChannelMock(), 'word')).toEqual(true); expect(matchesFilter(TestHelper.getOutgoingWebhookMock({display_name: 'word'}), TestHelper.getChannelMock(), 'word')).toEqual(true); expect(matchesFilter(TestHelper.getOutgoingWebhookMock({description: 'Trigger description'}), TestHelper.getChannelMock(), 'description')).toEqual(true); expect(matchesFilter(TestHelper.getOutgoingWebhookMock({trigger_words: ['Trigger']}), TestHelper.getChannelMock(), 'trigger')).toEqual(true); expect(matchesFilter(TestHelper.getOutgoingWebhookMock({trigger_words: ['word', 'Trigger']}), TestHelper.getChannelMock(), 'trigger')).toEqual(true); expect(matchesFilter(TestHelper.getOutgoingWebhookMock(), TestHelper.getChannelMock({name: 'channel_name'}), 'channel')).toEqual(true); }); });
2,379
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/__snapshots__/abstract_command.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/integrations/AbstractCommand should match snapshot 1`] = ` <div className="backstage-content row" > <BackstageHeader> <Link to="/test/integrations/commands" > <MemoizedFormattedMessage defaultMessage="Slash Commands" id="installed_command.header" /> </Link> <MemoizedFormattedMessage defaultMessage="Header" id="Header" /> </BackstageHeader> <div className="backstage-form" > <form className="form-horizontal" onSubmit={[Function]} > <div className="form-group" > <label className="control-label col-sm-4" htmlFor="displayName" > <MemoizedFormattedMessage defaultMessage="Title" id="add_command.displayName" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="displayName" maxLength={64} onChange={[Function]} type="text" value="display_name" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Specify a title, of up to 64 characters, for the slash command settings page." id="add_command.displayName.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="description" > <MemoizedFormattedMessage defaultMessage="Description" id="add_command.description" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="description" maxLength={128} onChange={[Function]} type="text" value="description" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Describe your slash command." id="add_command.description.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="trigger" > <MemoizedFormattedMessage defaultMessage="Command Trigger Word" id="add_command.trigger" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="trigger" maxLength={128} onChange={[Function]} placeholder="Command trigger e.g. \\"hello\\" not including the slash" type="text" value="trigger" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Specify a trigger word that is not a built-in command, does not contain spaces, and does not begin with the slash character." id="add_command.trigger.help" /> </div> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Examples: client, employee, patient, weather" id="add_command.trigger.helpExamples" /> </div> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Reserved: {link}" id="add_command.trigger.helpReserved" values={ Object { "link": <ExternalLink href="https://mattermost.com/pl/custom-slash-commands" location="abstract_command" > <Memo(MemoizedFormattedMessage) defaultMessage="See built-in slash commands" id="add_command.trigger.helpReservedLinkText" /> </ExternalLink>, } } /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="url" > <MemoizedFormattedMessage defaultMessage="Request URL" id="add_command.url" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="url" maxLength={1024} onChange={[Function]} placeholder="Must start with http:// or https://" type="text" value="https://google.com/command" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Specify the callback URL to receive the HTTP POST or GET event request when the slash command is run." id="add_command.url.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="method" > <MemoizedFormattedMessage defaultMessage="Request Method" id="add_command.method" /> </label> <div className="col-md-5 col-sm-8" > <select className="form-control" id="method" onChange={[Function]} value="G" > <option value="P" > POST </option> <option value="G" > GET </option> </select> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Specify the type of request, either POST or GET, sent to the endpoint that Mattermost hits to reach your application." id="add_command.method.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="username" > <MemoizedFormattedMessage defaultMessage="Response Username" id="add_command.username" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="username" maxLength={64} onChange={[Function]} placeholder="Username" type="text" value="username" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="(Optional) Specify the name to use when posting responses for this slash command. Usernames can be up to 22 characters, and contain lowercase letters, numbers, and the symbols \\\\\\"-\\\\\\", \\\\\\"_\\\\\\", and \\\\\\".\\\\\\". If left blank, your Mattermost username is used." id="add_command.username.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="iconUrl" > <MemoizedFormattedMessage defaultMessage="Response Icon" id="add_command.iconUrl" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="iconUrl" maxLength={1024} onChange={[Function]} placeholder="https://www.example.com/myicon.png" type="text" value="https://google.com/icon" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="(Optional) Enter the URL of a .png or .jpg file to use as the icon when posting responses to this slash command. The file must be at least 128 pixels by 128 pixels. If left blank, your profile picture is used." id="add_command.iconUrl.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="autocomplete" > <MemoizedFormattedMessage defaultMessage="Autocomplete" id="add_command.autocomplete" /> </label> <div className="col-md-5 col-sm-8 checkbox" > <input checked={true} id="autocomplete" onChange={[Function]} type="checkbox" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="(Optional) Show your slash command on the autocomplete list when someone types \\"/\\" in the input box." id="add_command.autocomplete.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="autocompleteHint" > <MemoizedFormattedMessage defaultMessage="Autocomplete Hint" id="add_command.autocompleteHint" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="autocompleteHint" maxLength={1024} onChange={[Function]} placeholder="Example: [Patient Name]" type="text" value="auto_complete_hint" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="(Optional) Specify the arguments associated with your slash command. These are displayed as help on the autocomplete list." id="add_command.autocompleteHint.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="autocompleteDescription" > <MemoizedFormattedMessage defaultMessage="Autocomplete Description" id="add_command.autocompleteDescription" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="description" maxLength={128} onChange={[Function]} placeholder="Example: \\"Returns search results for patient records\\"" type="text" value="auto_complete_desc" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="(Optional) Describe your slash command for the autocomplete list." id="add_command.autocompleteDescription.help" /> </div> </div> </div> <div className="backstage-form__footer" > <FormError error={null} errors={ Array [ "", null, ] } type="backstage" /> <Link className="btn btn-tertiary" to="/test/integrations/commands" > <MemoizedFormattedMessage defaultMessage="Cancel" id="add_command.cancel" /> </Link> <Memo(SpinnerButton) className="btn btn-primary" id="saveCommand" onClick={[Function]} spinning={false} spinningText="Loading" type="submit" > <MemoizedFormattedMessage defaultMessage="Footer" id="Footer" /> </Memo(SpinnerButton)> <div> renderExtra </div> </div> </form> </div> </div> `; exports[`components/integrations/AbstractCommand should match snapshot when header/footer/loading is a string 1`] = ` <div className="backstage-content row" > <BackstageHeader> <Link to="/test/integrations/commands" > <MemoizedFormattedMessage defaultMessage="Slash Commands" id="installed_command.header" /> </Link> <span> Header as string </span> </BackstageHeader> <div className="backstage-form" > <form className="form-horizontal" onSubmit={[Function]} > <div className="form-group" > <label className="control-label col-sm-4" htmlFor="displayName" > <MemoizedFormattedMessage defaultMessage="Title" id="add_command.displayName" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="displayName" maxLength={64} onChange={[Function]} type="text" value="display_name" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Specify a title, of up to 64 characters, for the slash command settings page." id="add_command.displayName.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="description" > <MemoizedFormattedMessage defaultMessage="Description" id="add_command.description" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="description" maxLength={128} onChange={[Function]} type="text" value="description" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Describe your slash command." id="add_command.description.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="trigger" > <MemoizedFormattedMessage defaultMessage="Command Trigger Word" id="add_command.trigger" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="trigger" maxLength={128} onChange={[Function]} placeholder="Command trigger e.g. \\"hello\\" not including the slash" type="text" value="trigger" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Specify a trigger word that is not a built-in command, does not contain spaces, and does not begin with the slash character." id="add_command.trigger.help" /> </div> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Examples: client, employee, patient, weather" id="add_command.trigger.helpExamples" /> </div> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Reserved: {link}" id="add_command.trigger.helpReserved" values={ Object { "link": <ExternalLink href="https://mattermost.com/pl/custom-slash-commands" location="abstract_command" > <Memo(MemoizedFormattedMessage) defaultMessage="See built-in slash commands" id="add_command.trigger.helpReservedLinkText" /> </ExternalLink>, } } /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="url" > <MemoizedFormattedMessage defaultMessage="Request URL" id="add_command.url" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="url" maxLength={1024} onChange={[Function]} placeholder="Must start with http:// or https://" type="text" value="https://google.com/command" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Specify the callback URL to receive the HTTP POST or GET event request when the slash command is run." id="add_command.url.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="method" > <MemoizedFormattedMessage defaultMessage="Request Method" id="add_command.method" /> </label> <div className="col-md-5 col-sm-8" > <select className="form-control" id="method" onChange={[Function]} value="G" > <option value="P" > POST </option> <option value="G" > GET </option> </select> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Specify the type of request, either POST or GET, sent to the endpoint that Mattermost hits to reach your application." id="add_command.method.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="username" > <MemoizedFormattedMessage defaultMessage="Response Username" id="add_command.username" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="username" maxLength={64} onChange={[Function]} placeholder="Username" type="text" value="username" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="(Optional) Specify the name to use when posting responses for this slash command. Usernames can be up to 22 characters, and contain lowercase letters, numbers, and the symbols \\\\\\"-\\\\\\", \\\\\\"_\\\\\\", and \\\\\\".\\\\\\". If left blank, your Mattermost username is used." id="add_command.username.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="iconUrl" > <MemoizedFormattedMessage defaultMessage="Response Icon" id="add_command.iconUrl" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="iconUrl" maxLength={1024} onChange={[Function]} placeholder="https://www.example.com/myicon.png" type="text" value="https://google.com/icon" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="(Optional) Enter the URL of a .png or .jpg file to use as the icon when posting responses to this slash command. The file must be at least 128 pixels by 128 pixels. If left blank, your profile picture is used." id="add_command.iconUrl.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="autocomplete" > <MemoizedFormattedMessage defaultMessage="Autocomplete" id="add_command.autocomplete" /> </label> <div className="col-md-5 col-sm-8 checkbox" > <input checked={true} id="autocomplete" onChange={[Function]} type="checkbox" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="(Optional) Show your slash command on the autocomplete list when someone types \\"/\\" in the input box." id="add_command.autocomplete.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="autocompleteHint" > <MemoizedFormattedMessage defaultMessage="Autocomplete Hint" id="add_command.autocompleteHint" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="autocompleteHint" maxLength={1024} onChange={[Function]} placeholder="Example: [Patient Name]" type="text" value="auto_complete_hint" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="(Optional) Specify the arguments associated with your slash command. These are displayed as help on the autocomplete list." id="add_command.autocompleteHint.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="autocompleteDescription" > <MemoizedFormattedMessage defaultMessage="Autocomplete Description" id="add_command.autocompleteDescription" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="description" maxLength={128} onChange={[Function]} placeholder="Example: \\"Returns search results for patient records\\"" type="text" value="auto_complete_desc" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="(Optional) Describe your slash command for the autocomplete list." id="add_command.autocompleteDescription.help" /> </div> </div> </div> <div className="backstage-form__footer" > <FormError error={null} errors={ Array [ "", null, ] } type="backstage" /> <Link className="btn btn-tertiary" to="/test/integrations/commands" > <MemoizedFormattedMessage defaultMessage="Cancel" id="add_command.cancel" /> </Link> <Memo(SpinnerButton) className="btn btn-primary" id="saveCommand" onClick={[Function]} spinning={false} spinningText="Loading as string" type="submit" > <span> Footer as string </span> </Memo(SpinnerButton)> <div> renderExtra </div> </div> </form> </div> </div> `; exports[`components/integrations/AbstractCommand should match snapshot, displays client error 1`] = ` <div className="backstage-content row" > <BackstageHeader> <Link to="/test/integrations/commands" > <MemoizedFormattedMessage defaultMessage="Slash Commands" id="installed_command.header" /> </Link> <MemoizedFormattedMessage defaultMessage="Header" id="Header" /> </BackstageHeader> <div className="backstage-form" > <form className="form-horizontal" onSubmit={[Function]} > <div className="form-group" > <label className="control-label col-sm-4" htmlFor="displayName" > <MemoizedFormattedMessage defaultMessage="Title" id="add_command.displayName" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="displayName" maxLength={64} onChange={[Function]} type="text" value="display_name" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Specify a title, of up to 64 characters, for the slash command settings page." id="add_command.displayName.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="description" > <MemoizedFormattedMessage defaultMessage="Description" id="add_command.description" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="description" maxLength={128} onChange={[Function]} type="text" value="description" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Describe your slash command." id="add_command.description.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="trigger" > <MemoizedFormattedMessage defaultMessage="Command Trigger Word" id="add_command.trigger" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="trigger" maxLength={128} onChange={[Function]} placeholder="Command trigger e.g. \\"hello\\" not including the slash" type="text" value="" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Specify a trigger word that is not a built-in command, does not contain spaces, and does not begin with the slash character." id="add_command.trigger.help" /> </div> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Examples: client, employee, patient, weather" id="add_command.trigger.helpExamples" /> </div> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Reserved: {link}" id="add_command.trigger.helpReserved" values={ Object { "link": <ExternalLink href="https://mattermost.com/pl/custom-slash-commands" location="abstract_command" > <Memo(MemoizedFormattedMessage) defaultMessage="See built-in slash commands" id="add_command.trigger.helpReservedLinkText" /> </ExternalLink>, } } /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="url" > <MemoizedFormattedMessage defaultMessage="Request URL" id="add_command.url" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="url" maxLength={1024} onChange={[Function]} placeholder="Must start with http:// or https://" type="text" value="https://google.com/command" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Specify the callback URL to receive the HTTP POST or GET event request when the slash command is run." id="add_command.url.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="method" > <MemoizedFormattedMessage defaultMessage="Request Method" id="add_command.method" /> </label> <div className="col-md-5 col-sm-8" > <select className="form-control" id="method" onChange={[Function]} value="G" > <option value="P" > POST </option> <option value="G" > GET </option> </select> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Specify the type of request, either POST or GET, sent to the endpoint that Mattermost hits to reach your application." id="add_command.method.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="username" > <MemoizedFormattedMessage defaultMessage="Response Username" id="add_command.username" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="username" maxLength={64} onChange={[Function]} placeholder="Username" type="text" value="username" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="(Optional) Specify the name to use when posting responses for this slash command. Usernames can be up to 22 characters, and contain lowercase letters, numbers, and the symbols \\\\\\"-\\\\\\", \\\\\\"_\\\\\\", and \\\\\\".\\\\\\". If left blank, your Mattermost username is used." id="add_command.username.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="iconUrl" > <MemoizedFormattedMessage defaultMessage="Response Icon" id="add_command.iconUrl" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="iconUrl" maxLength={1024} onChange={[Function]} placeholder="https://www.example.com/myicon.png" type="text" value="https://google.com/icon" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="(Optional) Enter the URL of a .png or .jpg file to use as the icon when posting responses to this slash command. The file must be at least 128 pixels by 128 pixels. If left blank, your profile picture is used." id="add_command.iconUrl.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="autocomplete" > <MemoizedFormattedMessage defaultMessage="Autocomplete" id="add_command.autocomplete" /> </label> <div className="col-md-5 col-sm-8 checkbox" > <input checked={true} id="autocomplete" onChange={[Function]} type="checkbox" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="(Optional) Show your slash command on the autocomplete list when someone types \\"/\\" in the input box." id="add_command.autocomplete.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="autocompleteHint" > <MemoizedFormattedMessage defaultMessage="Autocomplete Hint" id="add_command.autocompleteHint" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="autocompleteHint" maxLength={1024} onChange={[Function]} placeholder="Example: [Patient Name]" type="text" value="auto_complete_hint" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="(Optional) Specify the arguments associated with your slash command. These are displayed as help on the autocomplete list." id="add_command.autocompleteHint.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="autocompleteDescription" > <MemoizedFormattedMessage defaultMessage="Autocomplete Description" id="add_command.autocompleteDescription" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="description" maxLength={128} onChange={[Function]} placeholder="Example: \\"Returns search results for patient records\\"" type="text" value="auto_complete_desc" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="(Optional) Describe your slash command for the autocomplete list." id="add_command.autocompleteDescription.help" /> </div> </div> </div> <div className="backstage-form__footer" > <FormError error={null} errors={ Array [ "server error", <Memo(MemoizedFormattedMessage) defaultMessage="A trigger word is required" id="add_command.triggerRequired" />, ] } type="backstage" /> <Link className="btn btn-tertiary" to="/test/integrations/commands" > <MemoizedFormattedMessage defaultMessage="Cancel" id="add_command.cancel" /> </Link> <Memo(SpinnerButton) className="btn btn-primary" id="saveCommand" onClick={[Function]} spinning={false} spinningText="Loading" type="submit" > <MemoizedFormattedMessage defaultMessage="Footer" id="Footer" /> </Memo(SpinnerButton)> <div> renderExtra </div> </div> </form> </div> </div> `;
2,380
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/__snapshots__/abstract_incoming_hook.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/integrations/AbstractIncomingWebhook should call action function 1`] = ` <div className="backstage-content" > <BackstageHeader> <Link to="/team_name/integrations/incoming_webhooks" > <MemoizedFormattedMessage defaultMessage="Incoming Webhooks" id="incoming_webhooks.header" /> </Link> <MemoizedFormattedMessage defaultMessage="Header" id="header_id" /> </BackstageHeader> <div className="backstage-form" > <form className="form-horizontal" onSubmit={[Function]} > <div className="form-group" > <label className="control-label col-sm-4" htmlFor="displayName" > <MemoizedFormattedMessage defaultMessage="Title" id="add_incoming_webhook.displayName" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="displayName" maxLength={64} onChange={[Function]} type="text" value="testIncomingWebhook" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Specify a title, of up to 64 characters, for the webhook settings page." id="add_incoming_webhook.displayName.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="description" > <MemoizedFormattedMessage defaultMessage="Description" id="add_incoming_webhook.description" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="description" maxLength={500} onChange={[Function]} type="text" value="testing" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Describe your incoming webhook." id="add_incoming_webhook.description.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="channelId" > <MemoizedFormattedMessage defaultMessage="Channel" id="add_incoming_webhook.channel" /> </label> <div className="col-md-5 col-sm-8" > <Connect(ChannelSelect) onChange={[Function]} selectDm={false} selectOpen={true} selectPrivate={true} value="88cxd9wpzpbpfp8pad78xj75pr" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="This is the default public or private channel that receives the webhook payloads. When setting up the webhook, you must belong to the private channel." id="add_incoming_webhook.channel.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="channelLocked" > <MemoizedFormattedMessage defaultMessage="Lock to this channel" id="add_incoming_webhook.channelLocked" /> </label> <div className="col-md-5 col-sm-8 checkbox" > <input checked={false} id="channelLocked" onChange={[Function]} type="checkbox" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="If set, the incoming webhook can post only to the selected channel." id="add_incoming_webhook.channelLocked.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="username" > <MemoizedFormattedMessage defaultMessage="Username" id="add_incoming_webhook.username" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="username" maxLength={22} onChange={[Function]} type="text" value="" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Specify the username this integration will post as. Usernames can be up to 22 characters, and can contain lowercase letters, numbers and the symbols \\\\\\"-\\\\\\", \\\\\\"_\\\\\\", and \\\\\\".\\\\\\". If left blank, the name specified by the webhook creator is used." id="add_incoming_webhook.username.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="iconURL" > <MemoizedFormattedMessage defaultMessage="Profile Picture" id="add_incoming_webhook.icon_url" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="iconURL" maxLength={1024} onChange={[Function]} type="text" value="" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Enter the URL of a .png or .jpg file for the profile picture of this integration when posting. The file should be at least 128 pixels by 128 pixels. If left blank, the profile picture specified by the webhook creator is used." id="add_incoming_webhook.icon_url.help" /> </div> </div> </div> <div className="backstage-form__footer" > <FormError error={null} errors={ Array [ "", null, ] } type="backstage" /> <Link className="btn btn-tertiary" to="/team_name/integrations/incoming_webhooks" > <MemoizedFormattedMessage defaultMessage="Cancel" id="add_incoming_webhook.cancel" /> </Link> <Memo(SpinnerButton) className="btn btn-primary" id="saveWebhook" onClick={[Function]} spinning={false} spinningText="Loading" type="submit" > <MemoizedFormattedMessage defaultMessage="Footer" id="footer_id" /> </Memo(SpinnerButton)> </div> </form> </div> </div> `; exports[`components/integrations/AbstractIncomingWebhook should match snapshot 1`] = ` <div className="backstage-content" > <BackstageHeader> <Link to="/team_name/integrations/incoming_webhooks" > <MemoizedFormattedMessage defaultMessage="Incoming Webhooks" id="incoming_webhooks.header" /> </Link> <MemoizedFormattedMessage defaultMessage="Header" id="header_id" /> </BackstageHeader> <div className="backstage-form" > <form className="form-horizontal" onSubmit={[Function]} > <div className="form-group" > <label className="control-label col-sm-4" htmlFor="displayName" > <MemoizedFormattedMessage defaultMessage="Title" id="add_incoming_webhook.displayName" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="displayName" maxLength={64} onChange={[Function]} type="text" value="testIncomingWebhook" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Specify a title, of up to 64 characters, for the webhook settings page." id="add_incoming_webhook.displayName.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="description" > <MemoizedFormattedMessage defaultMessage="Description" id="add_incoming_webhook.description" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="description" maxLength={500} onChange={[Function]} type="text" value="testing" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Describe your incoming webhook." id="add_incoming_webhook.description.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="channelId" > <MemoizedFormattedMessage defaultMessage="Channel" id="add_incoming_webhook.channel" /> </label> <div className="col-md-5 col-sm-8" > <Connect(ChannelSelect) onChange={[Function]} selectDm={false} selectOpen={true} selectPrivate={true} value="88cxd9wpzpbpfp8pad78xj75pr" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="This is the default public or private channel that receives the webhook payloads. When setting up the webhook, you must belong to the private channel." id="add_incoming_webhook.channel.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="channelLocked" > <MemoizedFormattedMessage defaultMessage="Lock to this channel" id="add_incoming_webhook.channelLocked" /> </label> <div className="col-md-5 col-sm-8 checkbox" > <input checked={false} id="channelLocked" onChange={[Function]} type="checkbox" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="If set, the incoming webhook can post only to the selected channel." id="add_incoming_webhook.channelLocked.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="username" > <MemoizedFormattedMessage defaultMessage="Username" id="add_incoming_webhook.username" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="username" maxLength={22} onChange={[Function]} type="text" value="" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Specify the username this integration will post as. Usernames can be up to 22 characters, and can contain lowercase letters, numbers and the symbols \\\\\\"-\\\\\\", \\\\\\"_\\\\\\", and \\\\\\".\\\\\\". If left blank, the name specified by the webhook creator is used." id="add_incoming_webhook.username.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="iconURL" > <MemoizedFormattedMessage defaultMessage="Profile Picture" id="add_incoming_webhook.icon_url" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="iconURL" maxLength={1024} onChange={[Function]} type="text" value="" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Enter the URL of a .png or .jpg file for the profile picture of this integration when posting. The file should be at least 128 pixels by 128 pixels. If left blank, the profile picture specified by the webhook creator is used." id="add_incoming_webhook.icon_url.help" /> </div> </div> </div> <div className="backstage-form__footer" > <FormError error={null} errors={ Array [ "", null, ] } type="backstage" /> <Link className="btn btn-tertiary" to="/team_name/integrations/incoming_webhooks" > <MemoizedFormattedMessage defaultMessage="Cancel" id="add_incoming_webhook.cancel" /> </Link> <Memo(SpinnerButton) className="btn btn-primary" id="saveWebhook" onClick={[Function]} spinning={false} spinningText="Loading" type="submit" > <MemoizedFormattedMessage defaultMessage="Footer" id="footer_id" /> </Memo(SpinnerButton)> </div> </form> </div> </div> `; exports[`components/integrations/AbstractIncomingWebhook should match snapshot, displays client error when no initial hook 1`] = ` <div className="backstage-content" > <BackstageHeader> <Link to="/team_name/integrations/incoming_webhooks" > <MemoizedFormattedMessage defaultMessage="Incoming Webhooks" id="incoming_webhooks.header" /> </Link> <MemoizedFormattedMessage defaultMessage="Header" id="header_id" /> </BackstageHeader> <div className="backstage-form" > <form className="form-horizontal" onSubmit={[Function]} > <div className="form-group" > <label className="control-label col-sm-4" htmlFor="displayName" > <MemoizedFormattedMessage defaultMessage="Title" id="add_incoming_webhook.displayName" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="displayName" maxLength={64} onChange={[Function]} type="text" value="" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Specify a title, of up to 64 characters, for the webhook settings page." id="add_incoming_webhook.displayName.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="description" > <MemoizedFormattedMessage defaultMessage="Description" id="add_incoming_webhook.description" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="description" maxLength={500} onChange={[Function]} type="text" value="" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Describe your incoming webhook." id="add_incoming_webhook.description.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="channelId" > <MemoizedFormattedMessage defaultMessage="Channel" id="add_incoming_webhook.channel" /> </label> <div className="col-md-5 col-sm-8" > <Connect(ChannelSelect) onChange={[Function]} selectDm={false} selectOpen={true} selectPrivate={true} value="" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="This is the default public or private channel that receives the webhook payloads. When setting up the webhook, you must belong to the private channel." id="add_incoming_webhook.channel.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="channelLocked" > <MemoizedFormattedMessage defaultMessage="Lock to this channel" id="add_incoming_webhook.channelLocked" /> </label> <div className="col-md-5 col-sm-8 checkbox" > <input checked={false} id="channelLocked" onChange={[Function]} type="checkbox" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="If set, the incoming webhook can post only to the selected channel." id="add_incoming_webhook.channelLocked.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="username" > <MemoizedFormattedMessage defaultMessage="Username" id="add_incoming_webhook.username" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="username" maxLength={22} onChange={[Function]} type="text" value="" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Specify the username this integration will post as. Usernames can be up to 22 characters, and can contain lowercase letters, numbers and the symbols \\\\\\"-\\\\\\", \\\\\\"_\\\\\\", and \\\\\\".\\\\\\". If left blank, the name specified by the webhook creator is used." id="add_incoming_webhook.username.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="iconURL" > <MemoizedFormattedMessage defaultMessage="Profile Picture" id="add_incoming_webhook.icon_url" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="iconURL" maxLength={1024} onChange={[Function]} type="text" value="" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Enter the URL of a .png or .jpg file for the profile picture of this integration when posting. The file should be at least 128 pixels by 128 pixels. If left blank, the profile picture specified by the webhook creator is used." id="add_incoming_webhook.icon_url.help" /> </div> </div> </div> <div className="backstage-form__footer" > <FormError error={null} errors={ Array [ "", <Memo(MemoizedFormattedMessage) defaultMessage="A valid channel is required" id="add_incoming_webhook.channelRequired" />, ] } type="backstage" /> <Link className="btn btn-tertiary" to="/team_name/integrations/incoming_webhooks" > <MemoizedFormattedMessage defaultMessage="Cancel" id="add_incoming_webhook.cancel" /> </Link> <Memo(SpinnerButton) className="btn btn-primary" id="saveWebhook" onClick={[Function]} spinning={false} spinningText="Loading" type="submit" > <MemoizedFormattedMessage defaultMessage="Footer" id="footer_id" /> </Memo(SpinnerButton)> </div> </form> </div> </div> `; exports[`components/integrations/AbstractIncomingWebhook should match snapshot, hiding post icon url if not enabled 1`] = ` <div className="backstage-content" > <BackstageHeader> <Link to="/team_name/integrations/incoming_webhooks" > <MemoizedFormattedMessage defaultMessage="Incoming Webhooks" id="incoming_webhooks.header" /> </Link> <MemoizedFormattedMessage defaultMessage="Header" id="header_id" /> </BackstageHeader> <div className="backstage-form" > <form className="form-horizontal" onSubmit={[Function]} > <div className="form-group" > <label className="control-label col-sm-4" htmlFor="displayName" > <MemoizedFormattedMessage defaultMessage="Title" id="add_incoming_webhook.displayName" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="displayName" maxLength={64} onChange={[Function]} type="text" value="testIncomingWebhook" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Specify a title, of up to 64 characters, for the webhook settings page." id="add_incoming_webhook.displayName.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="description" > <MemoizedFormattedMessage defaultMessage="Description" id="add_incoming_webhook.description" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="description" maxLength={500} onChange={[Function]} type="text" value="testing" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Describe your incoming webhook." id="add_incoming_webhook.description.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="channelId" > <MemoizedFormattedMessage defaultMessage="Channel" id="add_incoming_webhook.channel" /> </label> <div className="col-md-5 col-sm-8" > <Connect(ChannelSelect) onChange={[Function]} selectDm={false} selectOpen={true} selectPrivate={true} value="88cxd9wpzpbpfp8pad78xj75pr" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="This is the default public or private channel that receives the webhook payloads. When setting up the webhook, you must belong to the private channel." id="add_incoming_webhook.channel.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="channelLocked" > <MemoizedFormattedMessage defaultMessage="Lock to this channel" id="add_incoming_webhook.channelLocked" /> </label> <div className="col-md-5 col-sm-8 checkbox" > <input checked={false} id="channelLocked" onChange={[Function]} type="checkbox" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="If set, the incoming webhook can post only to the selected channel." id="add_incoming_webhook.channelLocked.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="username" > <MemoizedFormattedMessage defaultMessage="Username" id="add_incoming_webhook.username" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="username" maxLength={22} onChange={[Function]} type="text" value="" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Specify the username this integration will post as. Usernames can be up to 22 characters, and can contain lowercase letters, numbers and the symbols \\\\\\"-\\\\\\", \\\\\\"_\\\\\\", and \\\\\\".\\\\\\". If left blank, the name specified by the webhook creator is used." id="add_incoming_webhook.username.help" /> </div> </div> </div> <div className="backstage-form__footer" > <FormError error={null} errors={ Array [ "", null, ] } type="backstage" /> <Link className="btn btn-tertiary" to="/team_name/integrations/incoming_webhooks" > <MemoizedFormattedMessage defaultMessage="Cancel" id="add_incoming_webhook.cancel" /> </Link> <Memo(SpinnerButton) className="btn btn-primary" id="saveWebhook" onClick={[Function]} spinning={false} spinningText="Loading" type="submit" > <MemoizedFormattedMessage defaultMessage="Footer" id="footer_id" /> </Memo(SpinnerButton)> </div> </form> </div> </div> `; exports[`components/integrations/AbstractIncomingWebhook should match snapshot, hiding post username if not enabled 1`] = ` <div className="backstage-content" > <BackstageHeader> <Link to="/team_name/integrations/incoming_webhooks" > <MemoizedFormattedMessage defaultMessage="Incoming Webhooks" id="incoming_webhooks.header" /> </Link> <MemoizedFormattedMessage defaultMessage="Header" id="header_id" /> </BackstageHeader> <div className="backstage-form" > <form className="form-horizontal" onSubmit={[Function]} > <div className="form-group" > <label className="control-label col-sm-4" htmlFor="displayName" > <MemoizedFormattedMessage defaultMessage="Title" id="add_incoming_webhook.displayName" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="displayName" maxLength={64} onChange={[Function]} type="text" value="testIncomingWebhook" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Specify a title, of up to 64 characters, for the webhook settings page." id="add_incoming_webhook.displayName.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="description" > <MemoizedFormattedMessage defaultMessage="Description" id="add_incoming_webhook.description" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="description" maxLength={500} onChange={[Function]} type="text" value="testing" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Describe your incoming webhook." id="add_incoming_webhook.description.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="channelId" > <MemoizedFormattedMessage defaultMessage="Channel" id="add_incoming_webhook.channel" /> </label> <div className="col-md-5 col-sm-8" > <Connect(ChannelSelect) onChange={[Function]} selectDm={false} selectOpen={true} selectPrivate={true} value="88cxd9wpzpbpfp8pad78xj75pr" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="This is the default public or private channel that receives the webhook payloads. When setting up the webhook, you must belong to the private channel." id="add_incoming_webhook.channel.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="channelLocked" > <MemoizedFormattedMessage defaultMessage="Lock to this channel" id="add_incoming_webhook.channelLocked" /> </label> <div className="col-md-5 col-sm-8 checkbox" > <input checked={false} id="channelLocked" onChange={[Function]} type="checkbox" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="If set, the incoming webhook can post only to the selected channel." id="add_incoming_webhook.channelLocked.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="iconURL" > <MemoizedFormattedMessage defaultMessage="Profile Picture" id="add_incoming_webhook.icon_url" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="iconURL" maxLength={1024} onChange={[Function]} type="text" value="" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Enter the URL of a .png or .jpg file for the profile picture of this integration when posting. The file should be at least 128 pixels by 128 pixels. If left blank, the profile picture specified by the webhook creator is used." id="add_incoming_webhook.icon_url.help" /> </div> </div> </div> <div className="backstage-form__footer" > <FormError error={null} errors={ Array [ "", null, ] } type="backstage" /> <Link className="btn btn-tertiary" to="/team_name/integrations/incoming_webhooks" > <MemoizedFormattedMessage defaultMessage="Cancel" id="add_incoming_webhook.cancel" /> </Link> <Memo(SpinnerButton) className="btn btn-primary" id="saveWebhook" onClick={[Function]} spinning={false} spinningText="Loading" type="submit" > <MemoizedFormattedMessage defaultMessage="Footer" id="footer_id" /> </Memo(SpinnerButton)> </div> </form> </div> </div> `; exports[`components/integrations/AbstractIncomingWebhook should match snapshot, on serverError 1`] = ` <div className="backstage-content" > <BackstageHeader> <Link to="/team_name/integrations/incoming_webhooks" > <MemoizedFormattedMessage defaultMessage="Incoming Webhooks" id="incoming_webhooks.header" /> </Link> <MemoizedFormattedMessage defaultMessage="Header" id="header_id" /> </BackstageHeader> <div className="backstage-form" > <form className="form-horizontal" onSubmit={[Function]} > <div className="form-group" > <label className="control-label col-sm-4" htmlFor="displayName" > <MemoizedFormattedMessage defaultMessage="Title" id="add_incoming_webhook.displayName" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="displayName" maxLength={64} onChange={[Function]} type="text" value="testIncomingWebhook" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Specify a title, of up to 64 characters, for the webhook settings page." id="add_incoming_webhook.displayName.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="description" > <MemoizedFormattedMessage defaultMessage="Description" id="add_incoming_webhook.description" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="description" maxLength={500} onChange={[Function]} type="text" value="testing" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Describe your incoming webhook." id="add_incoming_webhook.description.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="channelId" > <MemoizedFormattedMessage defaultMessage="Channel" id="add_incoming_webhook.channel" /> </label> <div className="col-md-5 col-sm-8" > <Connect(ChannelSelect) onChange={[Function]} selectDm={false} selectOpen={true} selectPrivate={true} value="88cxd9wpzpbpfp8pad78xj75pr" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="This is the default public or private channel that receives the webhook payloads. When setting up the webhook, you must belong to the private channel." id="add_incoming_webhook.channel.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="channelLocked" > <MemoizedFormattedMessage defaultMessage="Lock to this channel" id="add_incoming_webhook.channelLocked" /> </label> <div className="col-md-5 col-sm-8 checkbox" > <input checked={false} id="channelLocked" onChange={[Function]} type="checkbox" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="If set, the incoming webhook can post only to the selected channel." id="add_incoming_webhook.channelLocked.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="username" > <MemoizedFormattedMessage defaultMessage="Username" id="add_incoming_webhook.username" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="username" maxLength={22} onChange={[Function]} type="text" value="" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Specify the username this integration will post as. Usernames can be up to 22 characters, and can contain lowercase letters, numbers and the symbols \\\\\\"-\\\\\\", \\\\\\"_\\\\\\", and \\\\\\".\\\\\\". If left blank, the name specified by the webhook creator is used." id="add_incoming_webhook.username.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="iconURL" > <MemoizedFormattedMessage defaultMessage="Profile Picture" id="add_incoming_webhook.icon_url" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="iconURL" maxLength={1024} onChange={[Function]} type="text" value="" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Enter the URL of a .png or .jpg file for the profile picture of this integration when posting. The file should be at least 128 pixels by 128 pixels. If left blank, the profile picture specified by the webhook creator is used." id="add_incoming_webhook.icon_url.help" /> </div> </div> </div> <div className="backstage-form__footer" > <FormError error={null} errors={ Array [ "serverError", null, ] } type="backstage" /> <Link className="btn btn-tertiary" to="/team_name/integrations/incoming_webhooks" > <MemoizedFormattedMessage defaultMessage="Cancel" id="add_incoming_webhook.cancel" /> </Link> <Memo(SpinnerButton) className="btn btn-primary" id="saveWebhook" onClick={[Function]} spinning={false} spinningText="Loading" type="submit" > <MemoizedFormattedMessage defaultMessage="Footer" id="footer_id" /> </Memo(SpinnerButton)> </div> </form> </div> </div> `;
2,381
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/__snapshots__/abstract_oauth_app.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/integrations/AbstractOAuthApp should match snapshot 1`] = ` <div className="backstage-content" > <BackstageHeader> <Link to="/test/integrations/oauth2-apps" > <MemoizedFormattedMessage defaultMessage="Installed OAuth2 Apps" id="installed_oauth_apps.header" /> </Link> <MemoizedFormattedMessage defaultMessage="Header" id="Header" /> </BackstageHeader> <div className="backstage-form" > <div className="integration__icon" > <img alt="integration icon" src="https://test.com/icon" /> </div> <form className="form-horizontal" > <Connect(SystemPermissionGate) permissions={ Array [ "manage_system", ] } > <div className="form-group" > <label className="control-label col-sm-4" htmlFor="is_trusted" > <MemoizedFormattedMessage defaultMessage="Is Trusted" id="installed_oauth_apps.trusted" /> </label> <div className="col-md-5 col-sm-8" > <label className="radio-inline" > <input checked={true} name="is_trusted" onChange={[Function]} type="radio" value="true" /> <MemoizedFormattedMessage defaultMessage="Yes" id="installed_oauth_apps.trusted.yes" /> </label> <label className="radio-inline" > <input checked={false} name="is_trusted" onChange={[Function]} type="radio" value="false" /> <MemoizedFormattedMessage defaultMessage="No" id="installed_oauth_apps.trusted.no" /> </label> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="If true, the OAuth 2.0 application is considered trusted by the Mattermost server and does not require the user to accept authorization. If false, a window opens to ask the user to accept or deny the authorization." id="add_oauth_app.trusted.help" /> </div> </div> </div> </Connect(SystemPermissionGate)> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="name" > <MemoizedFormattedMessage defaultMessage="Display Name" id="installed_oauth_apps.name" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="name" maxLength={64} onChange={[Function]} type="text" value="testApp" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Specify the display name, of up to 64 characters, for your OAuth 2.0 application." id="add_oauth_app.name.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="description" > <MemoizedFormattedMessage defaultMessage="Description" id="installed_oauth_apps.description" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="description" maxLength={512} onChange={[Function]} type="text" value="testing" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Describe your OAuth 2.0 application." id="add_oauth_app.description.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="homepage" > <MemoizedFormattedMessage defaultMessage="Homepage" id="installed_oauth_apps.homepage" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="homepage" maxLength={256} onChange={[Function]} type="url" value="https://test.com" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="This is the URL for the homepage of the OAuth 2.0 application. Depending on your server configuration, use HTTP or HTTPS in the URL." id="add_oauth_app.homepage.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="icon_url" > <MemoizedFormattedMessage defaultMessage="Icon URL" id="installed_oauth_apps.iconUrl" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="icon_url" maxLength={512} onChange={[Function]} type="url" value="https://test.com/icon" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="(Optional) The URL of the image used for your OAuth 2.0 application. Make sure you use HTTP or HTTPS in your URL." id="add_oauth_app.icon.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="callbackUrls" > <MemoizedFormattedMessage defaultMessage="Callback URLs (One Per Line)" id="installed_oauth_apps.callbackUrls" /> </label> <div className="col-md-5 col-sm-8" > <textarea className="form-control" id="callbackUrls" maxLength={1024} onChange={[Function]} rows={3} value="https://test.com/callback https://test.com/callback2" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="The redirect URIs to which the service will redirect users after accepting or denying authorization of your application, and which will handle authorization codes or access tokens. Must be a valid URL and start with http:// or https://." id="add_oauth_app.callbackUrls.help" /> </div> </div> </div> <div className="backstage-form__footer" > <FormError error={null} errors={ Array [ "", null, ] } type="backstage" /> <Link className="btn btn-tertiary" to="/test/integrations/oauth2-apps" > <MemoizedFormattedMessage defaultMessage="Cancel" id="installed_oauth_apps.cancel" /> </Link> <Memo(SpinnerButton) className="btn btn-primary" id="saveOauthApp" onClick={[Function]} spinning={false} spinningText="Loading" type="submit" > <MemoizedFormattedMessage defaultMessage="Footer" id="Footer" /> </Memo(SpinnerButton)> <div> renderExtra </div> </div> </form> </div> </div> `; exports[`components/integrations/AbstractOAuthApp should match snapshot, displays client error 1`] = ` <div className="backstage-content" > <BackstageHeader> <Link to="/test/integrations/oauth2-apps" > <MemoizedFormattedMessage defaultMessage="Installed OAuth2 Apps" id="installed_oauth_apps.header" /> </Link> <MemoizedFormattedMessage defaultMessage="Header" id="Header" /> </BackstageHeader> <div className="backstage-form" > <div className="integration__icon" > <img alt="integration icon" src="https://test.com/icon" /> </div> <form className="form-horizontal" > <Connect(SystemPermissionGate) permissions={ Array [ "manage_system", ] } > <div className="form-group" > <label className="control-label col-sm-4" htmlFor="is_trusted" > <MemoizedFormattedMessage defaultMessage="Is Trusted" id="installed_oauth_apps.trusted" /> </label> <div className="col-md-5 col-sm-8" > <label className="radio-inline" > <input checked={true} name="is_trusted" onChange={[Function]} type="radio" value="true" /> <MemoizedFormattedMessage defaultMessage="Yes" id="installed_oauth_apps.trusted.yes" /> </label> <label className="radio-inline" > <input checked={false} name="is_trusted" onChange={[Function]} type="radio" value="false" /> <MemoizedFormattedMessage defaultMessage="No" id="installed_oauth_apps.trusted.no" /> </label> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="If true, the OAuth 2.0 application is considered trusted by the Mattermost server and does not require the user to accept authorization. If false, a window opens to ask the user to accept or deny the authorization." id="add_oauth_app.trusted.help" /> </div> </div> </div> </Connect(SystemPermissionGate)> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="name" > <MemoizedFormattedMessage defaultMessage="Display Name" id="installed_oauth_apps.name" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="name" maxLength={64} onChange={[Function]} type="text" value="testApp" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Specify the display name, of up to 64 characters, for your OAuth 2.0 application." id="add_oauth_app.name.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="description" > <MemoizedFormattedMessage defaultMessage="Description" id="installed_oauth_apps.description" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="description" maxLength={512} onChange={[Function]} type="text" value="testing" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Describe your OAuth 2.0 application." id="add_oauth_app.description.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="homepage" > <MemoizedFormattedMessage defaultMessage="Homepage" id="installed_oauth_apps.homepage" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="homepage" maxLength={256} onChange={[Function]} type="url" value="https://test.com" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="This is the URL for the homepage of the OAuth 2.0 application. Depending on your server configuration, use HTTP or HTTPS in the URL." id="add_oauth_app.homepage.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="icon_url" > <MemoizedFormattedMessage defaultMessage="Icon URL" id="installed_oauth_apps.iconUrl" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="icon_url" maxLength={512} onChange={[Function]} type="url" value="https://test.com/icon" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="(Optional) The URL of the image used for your OAuth 2.0 application. Make sure you use HTTP or HTTPS in your URL." id="add_oauth_app.icon.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="callbackUrls" > <MemoizedFormattedMessage defaultMessage="Callback URLs (One Per Line)" id="installed_oauth_apps.callbackUrls" /> </label> <div className="col-md-5 col-sm-8" > <textarea className="form-control" id="callbackUrls" maxLength={1024} onChange={[Function]} rows={3} value="" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="The redirect URIs to which the service will redirect users after accepting or denying authorization of your application, and which will handle authorization codes or access tokens. Must be a valid URL and start with http:// or https://." id="add_oauth_app.callbackUrls.help" /> </div> </div> </div> <div className="backstage-form__footer" > <FormError error={null} errors={ Array [ "serverError", <Memo(MemoizedFormattedMessage) defaultMessage="One or more callback URLs are required." id="add_oauth_app.callbackUrlsRequired" />, ] } type="backstage" /> <Link className="btn btn-tertiary" to="/test/integrations/oauth2-apps" > <MemoizedFormattedMessage defaultMessage="Cancel" id="installed_oauth_apps.cancel" /> </Link> <Memo(SpinnerButton) className="btn btn-primary" id="saveOauthApp" onClick={[Function]} spinning={false} spinningText="Loading" type="submit" > <MemoizedFormattedMessage defaultMessage="Footer" id="Footer" /> </Memo(SpinnerButton)> <div> renderExtra </div> </div> </form> </div> </div> `;
2,382
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/__snapshots__/abstract_outgoing_webhook.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/integrations/AbstractOutgoingWebhook should match snapshot 1`] = ` <div className="backstage-content" > <BackstageHeader> <Link to="/team_name/integrations/outgoing_webhooks" > <MemoizedFormattedMessage defaultMessage="Outgoing Webhooks" id="add_outgoing_webhook.header" /> </Link> <MemoizedFormattedMessage defaultMessage="Header" id="header_id" /> </BackstageHeader> <div className="backstage-form" > <form className="form-horizontal" onSubmit={[Function]} > <div className="form-group" > <label className="control-label col-sm-4" htmlFor="displayName" > <MemoizedFormattedMessage defaultMessage="Title" id="add_outgoing_webhook.displayName" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="displayName" maxLength={64} onChange={[Function]} type="text" value="testOutgoingWebhook" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Specify a title, of up to 64 characters, for the webhook settings page." id="add_outgoing_webhook.displayName.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="description" > <MemoizedFormattedMessage defaultMessage="Description" id="add_outgoing_webhook.description" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="description" maxLength={500} onChange={[Function]} type="text" value="testing" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Describe your outgoing webhook." id="add_outgoing_webhook.description.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="contentType" > <MemoizedFormattedMessage defaultMessage="Content Type" id="add_outgoing_webhook.content_Type" /> </label> <div className="col-md-5 col-sm-8" > <select className="form-control" onChange={[Function]} value="test_content_type" > <option value="application/x-www-form-urlencoded" > application/x-www-form-urlencoded </option> <option value="application/json" > application/json </option> </select> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Specify the content type by which to send the request." id="add_outgoing_webhook.contentType.help1" /> </div> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="For the server to encode the parameters in a URL format in the request body, select application/x-www-form-urlencoded." id="add_outgoing_webhook.contentType.help2" /> </div> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="For the server to format the request body as JSON, select application/json." id="add_outgoing_webhook.contentType.help3" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="channelId" > <MemoizedFormattedMessage defaultMessage="Channel" id="add_outgoing_webhook.channel" /> </label> <div className="col-md-5 col-sm-8" > <Connect(ChannelSelect) onChange={[Function]} selectDm={false} selectOpen={true} selectPrivate={false} value="88cxd9wpzpbpfp8pad78xj75pr" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="This field is optional if you specify at least one trigger word. Specify the public channel that delivers the payload to the webhook." id="add_outgoing_webhook.channel.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="triggerWords" > <MemoizedFormattedMessage defaultMessage="Trigger Words (One Per Line)" id="add_outgoing_webhook.triggerWords" /> </label> <div className="col-md-5 col-sm-8" > <textarea className="form-control" id="triggerWords" maxLength={1000} onChange={[Function]} rows={3} value="test trigger word " /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Specify the trigger words that send an HTTP POST request to your application. The trigger can be for the channel, the outgoing webhook, or both. If you select only Channel, trigger words are optional. If you select both, the message must match both values." id="add_outgoing_webhook.triggerWords.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="triggerWords" > <MemoizedFormattedMessage defaultMessage="Trigger When" id="add_outgoing_webhook.triggerWordsTriggerWhen" /> </label> <div className="col-md-5 col-sm-8" > <select className="form-control" id="triggerWhen" onChange={[Function]} value={0} > <option value="0" > First word matches a trigger word exactly </option> <option value="1" > First word starts with a trigger word </option> </select> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Specify when to trigger the outgoing webhook." id="add_outgoing_webhook.triggerWordsTriggerWhen.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="callbackUrls" > <MemoizedFormattedMessage defaultMessage="Callback URLs (One Per Line)" id="add_outgoing_webhook.callbackUrls" /> </label> <div className="col-md-5 col-sm-8" > <textarea className="form-control" id="callbackUrls" maxLength={1000} onChange={[Function]} rows={3} value="callbackUrl1.com callbackUrl2.com " /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Specify the URL that the messages will be sent to. If the URL is private, add it as a {link}." id="add_outgoing_webhook.callbackUrls.help" values={ Object { "link": <ExternalLink href="https://mattermost.com/pl/configure-session-lengths" location="abstract_outgoing_webhook" > <Memo(MemoizedFormattedMessage) defaultMessage="trusted internal connection" id="add_outgoing_webhook.callbackUrls.helpLinkText" /> </ExternalLink>, } } /> </div> </div> </div> <div className="backstage-form__footer" > <FormError error={null} errors={ Array [ "", null, ] } type="backstage" /> <Link className="btn btn-tertiary" to="/team_name/integrations/outgoing_webhooks" > <MemoizedFormattedMessage defaultMessage="Cancel" id="add_outgoing_webhook.cancel" /> </Link> <Memo(SpinnerButton) className="btn btn-primary" id="saveWebhook" onClick={[Function]} spinning={false} spinningText="Loading" type="submit" > <MemoizedFormattedMessage defaultMessage="Footer" id="footer_id" /> </Memo(SpinnerButton)> </div> </form> </div> </div> `;
2,383
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/__snapshots__/installed_command.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/integrations/InstalledCommand should call onDelete function 1`] = ` <div className="backstage-list__item" > <div className="item-details" > <div className="item-details__row d-flex flex-column flex-md-row justify-content-between" > <div> <strong className="item-details__name" > display_name </strong> <span className="item-details__trigger" > - /trigger auto_complete_hint </span> </div> <div className="item-actions" > <button className="style--none color--link" onClick={[Function]} > <MemoizedFormattedMessage defaultMessage="Regenerate Token" id="installed_integrations.regenToken" /> </button> - <Link to="/team_name/integrations/commands/edit?id=r5tpgt4iepf45jt768jz84djic" > <MemoizedFormattedMessage defaultMessage="Edit" id="installed_integrations.edit" /> </Link> - <Connect(DeleteIntegrationLink) modalMessage={ <Memo(MemoizedFormattedMessage) defaultMessage="This action permanently deletes the slash command and breaks any integrations using it. Are you sure you want to delete it?" id="installed_commands.delete.confirm" /> } onDelete={[Function]} /> </div> </div> <div className="item-details__row" > <span className="item-details__description" > description </span> </div> <div className="item-details__row" > <span className="item-details__token" > <MemoizedFormattedMessage defaultMessage="Token: {token}" id="installed_integrations.token" values={ Object { "token": "testToken", } } /> <Memo(CopyText) value="testToken" /> </span> </div> <div className="item-details__row" > <span className="item-details__creation" > <MemoizedFormattedMessage defaultMessage="Created by {creator} on {createAt, date, full}" id="installed_integrations.creation" values={ Object { "createAt": 1499722850203, "creator": "username", } } /> </span> </div> </div> </div> `; exports[`components/integrations/InstalledCommand should call onRegenToken function 1`] = ` <div className="backstage-list__item" > <div className="item-details" > <div className="item-details__row d-flex flex-column flex-md-row justify-content-between" > <div> <strong className="item-details__name" > display_name </strong> <span className="item-details__trigger" > - /trigger auto_complete_hint </span> </div> <div className="item-actions" > <button className="style--none color--link" onClick={[Function]} > <MemoizedFormattedMessage defaultMessage="Regenerate Token" id="installed_integrations.regenToken" /> </button> - <Link to="/team_name/integrations/commands/edit?id=r5tpgt4iepf45jt768jz84djic" > <MemoizedFormattedMessage defaultMessage="Edit" id="installed_integrations.edit" /> </Link> - <Connect(DeleteIntegrationLink) modalMessage={ <Memo(MemoizedFormattedMessage) defaultMessage="This action permanently deletes the slash command and breaks any integrations using it. Are you sure you want to delete it?" id="installed_commands.delete.confirm" /> } onDelete={[Function]} /> </div> </div> <div className="item-details__row" > <span className="item-details__description" > description </span> </div> <div className="item-details__row" > <span className="item-details__token" > <MemoizedFormattedMessage defaultMessage="Token: {token}" id="installed_integrations.token" values={ Object { "token": "testToken", } } /> <Memo(CopyText) value="testToken" /> </span> </div> <div className="item-details__row" > <span className="item-details__creation" > <MemoizedFormattedMessage defaultMessage="Created by {creator} on {createAt, date, full}" id="installed_integrations.creation" values={ Object { "createAt": 1499722850203, "creator": "username", } } /> </span> </div> </div> </div> `; exports[`components/integrations/InstalledCommand should filter out command 1`] = `""`; exports[`components/integrations/InstalledCommand should match snapshot 1`] = ` <div className="backstage-list__item" > <div className="item-details" > <div className="item-details__row d-flex flex-column flex-md-row justify-content-between" > <div> <strong className="item-details__name" > display_name </strong> <span className="item-details__trigger" > - /trigger auto_complete_hint </span> </div> </div> <div className="item-details__row" > <span className="item-details__description" > description </span> </div> <div className="item-details__row" > <span className="item-details__token" > <MemoizedFormattedMessage defaultMessage="Token: {token}" id="installed_integrations.token" values={ Object { "token": "testToken", } } /> <Memo(CopyText) value="testToken" /> </span> </div> <div className="item-details__row" > <span className="item-details__creation" > <MemoizedFormattedMessage defaultMessage="Created by {creator} on {createAt, date, full}" id="installed_integrations.creation" values={ Object { "createAt": 1499722850203, "creator": "username", } } /> </span> </div> </div> </div> `; exports[`components/integrations/InstalledCommand should match snapshot, not autocomplete, no display_name/description/auto_complete_hint 1`] = ` <div className="backstage-list__item" > <div className="item-details" > <div className="item-details__row d-flex flex-column flex-md-row justify-content-between" > <div> <strong className="item-details__name" > command_display_name </strong> <span className="item-details__trigger" > - /trigger </span> </div> </div> <div className="item-details__row" > <span className="item-details__description" > command_description </span> </div> <div className="item-details__row" > <span className="item-details__token" > <MemoizedFormattedMessage defaultMessage="Token: {token}" id="installed_integrations.token" values={ Object { "token": "testToken", } } /> <Memo(CopyText) value="testToken" /> </span> </div> <div className="item-details__row" > <span className="item-details__creation" > <MemoizedFormattedMessage defaultMessage="Created by {creator} on {createAt, date, full}" id="installed_integrations.creation" values={ Object { "createAt": 1499722850203, "creator": "username", } } /> </span> </div> </div> </div> `;
2,384
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/__snapshots__/installed_incoming_webhook.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/integrations/InstalledIncomingWebhook should match snapshot 1`] = ` <div className="backstage-list__item" > <div className="item-details" > <div className="item-details__row d-flex flex-column flex-md-row justify-content-between" > <strong className="item-details__name" > build </strong> <div className="item-actions" > <Link to="/test/integrations/incoming_webhooks/edit?id=9w96t4nhbfdiij64wfqors4i1r" > <MemoizedFormattedMessage defaultMessage="Edit" id="installed_integrations.edit" /> </Link> - <Connect(DeleteIntegrationLink) modalMessage={ <Memo(MemoizedFormattedMessage) defaultMessage="This action permanently deletes the incoming webhook and breaks any integrations using it. Are you sure you want to delete it?" id="installed_incoming_webhooks.delete.confirm" /> } onDelete={[Function]} /> </div> </div> <div className="item-details__row" > <span className="item-details__description" > build status </span> </div> <div className="item-details__row" > <span className="item-details__url word-break--all" > <MemoizedFormattedMessage defaultMessage="URL: {url}" id="installed_integrations.url" values={ Object { "url": "http://localhost:8065/hooks/9w96t4nhbfdiij64wfqors4i1r", } } /> <span> <Memo(CopyText) value="http://localhost:8065/hooks/9w96t4nhbfdiij64wfqors4i1r" /> </span> </span> </div> <div className="item-details__row" > <span className="item-details__creation" > <MemoizedFormattedMessage defaultMessage="Created by {creator} on {createAt, date, full}" id="installed_integrations.creation" values={ Object { "createAt": 1502455422406, "creator": "creator", } } /> </span> </div> </div> </div> `;
2,385
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/__snapshots__/installed_outgoing_webhook.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/integrations/InstalledOutgoingWebhook Should match snapshot of makeDisplayName 1`] = `"hook display name"`; exports[`components/integrations/InstalledOutgoingWebhook Should match snapshot of makeDisplayName 2`] = `"channel display name"`; exports[`components/integrations/InstalledOutgoingWebhook Should match snapshot of makeDisplayName 3`] = `"name"`; exports[`components/integrations/InstalledOutgoingWebhook should match snapshot 1`] = ` <div className="backstage-list__item" > <div className="item-details" > <div className="item-details__row d-flex flex-column flex-md-row justify-content-between" > <strong className="item-details__name" > build </strong> <div className="item-actions" > <button className="style--none color--link" onClick={[Function]} > <MemoizedFormattedMessage defaultMessage="Regenerate Token" id="installed_integrations.regenToken" /> </button> - <Link to="/test/integrations/outgoing_webhooks/edit?id=7h88x419ubbyuxzs7dfwtgkffr" > <MemoizedFormattedMessage defaultMessage="Edit" id="installed_integrations.edit" /> </Link> - <Connect(DeleteIntegrationLink) modalMessage={ <Memo(MemoizedFormattedMessage) defaultMessage="This action permanently deletes the outgoing webhook and breaks any integrations using it. Are you sure you want to delete it?" id="installed_outgoing_webhooks.delete.confirm" /> } onDelete={[Function]} /> </div> </div> <div className="item-details__row" > <span className="item-details__description" > build status </span> </div> <div className="item-details__row" > <span className="item-details__content_type" > <MemoizedFormattedMessage defaultMessage="Content-Type: {contentType}" id="installed_integrations.content_type" values={ Object { "contentType": "application/x-www-form-urlencoded", } } /> </span> </div> <div className="item-details__row" > <span className="item-details__trigger-words" > <MemoizedFormattedMessage defaultMessage="Trigger Words: {triggerWords}" id="installed_integrations.triggerWords" values={ Object { "triggerWords": "build", } } /> </span> </div> <div className="item-details__row" > <span className="item-details__trigger-when" > <MemoizedFormattedMessage defaultMessage="Trigger When: {triggerWhen}" id="installed_integrations.triggerWhen" values={ Object { "triggerWhen": <Memo(MemoizedFormattedMessage) defaultMessage="First word matches a trigger word exactly" id="add_outgoing_webhook.triggerWordsTriggerWhenFullWord" />, } } /> </span> </div> <div className="item-details__row" > <span className="item-details__token" > <MemoizedFormattedMessage defaultMessage="Token: {token}" id="installed_integrations.token" values={ Object { "token": "xoxz1z7c3tgi9xhrfudn638q9r", } } /> <Memo(CopyText) value="xoxz1z7c3tgi9xhrfudn638q9r" /> </span> </div> <div className="item-details__row" > <span className="item-details__creation" > <MemoizedFormattedMessage defaultMessage="Created by {creator} on {createAt, date, full}" id="installed_integrations.creation" values={ Object { "createAt": 1508327769020, "creator": "some-user", } } /> </span> </div> <div className="item-details__row" > <span className="item-details__url word-break--all" > <MemoizedFormattedMessage defaultMessage="Callback URLs: {urls}" id="installed_integrations.callback_urls" values={ Object { "urls": "http://adsfdasd.com", } } /> </span> </div> </div> </div> `;
2,386
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/add_command/add_command.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import AddCommand from 'components/integrations/add_command/add_command'; import {TestHelper} from 'utils/test_helper'; describe('components/integrations/AddCommand', () => { test('should match snapshot', () => { const emptyFunction = jest.fn(); const team = TestHelper.getTeamMock({name: 'test'}); const wrapper = shallow( <AddCommand team={team} actions={{addCommand: emptyFunction}} />, ); expect(wrapper).toMatchSnapshot(); }); });
2,389
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/add_command
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/add_command/__snapshots__/add_command.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/integrations/AddCommand should match snapshot 1`] = ` <injectIntl(AbstractCommand) action={[Function]} footer="Save" header="Add" loading="Saving..." serverError="" team={ Object { "allow_open_invite": false, "allowed_domains": "", "company_name": "", "create_at": 0, "delete_at": 0, "description": "", "display_name": "name", "email": "", "group_constrained": false, "id": "team_id", "invite_id": "", "name": "test", "scheme_id": "id", "type": "O", "update_at": 0, } } /> `;
2,390
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/add_incoming_webhook/add_incoming_webhook.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import AddIncomingWebhook from 'components/integrations/add_incoming_webhook/add_incoming_webhook'; import {TestHelper} from 'utils/test_helper'; describe('components/integrations/AddIncomingWebhook', () => { const createIncomingHook = jest.fn().mockResolvedValue({data: true}); const props = { team: TestHelper.getTeamMock({ id: 'testteamid', name: 'test', }), enablePostUsernameOverride: true, enablePostIconOverride: true, actions: {createIncomingHook}, }; test('should match snapshot', () => { const wrapper = shallow(<AddIncomingWebhook {...props}/>); expect(wrapper).toMatchSnapshot(); }); test('should have called createIncomingHook', () => { const hook = TestHelper.getIncomingWebhookMock({ channel_id: 'channel_id', display_name: 'display_name', description: 'description', username: 'username', icon_url: 'icon_url', }); const wrapper = shallow<AddIncomingWebhook>(<AddIncomingWebhook {...props}/>); wrapper.instance().addIncomingHook(hook); expect(createIncomingHook).toHaveBeenCalledTimes(1); expect(createIncomingHook).toBeCalledWith(hook); }); });
2,393
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/add_incoming_webhook
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/add_incoming_webhook/__snapshots__/add_incoming_webhook.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/integrations/AddIncomingWebhook should match snapshot 1`] = ` <AbstractIncomingWebhook action={[Function]} enablePostIconOverride={true} enablePostUsernameOverride={true} footer={ Object { "defaultMessage": "Save", "id": "add_incoming_webhook.save", } } header={ Object { "defaultMessage": "Add", "id": "integrations.add", } } loading={ Object { "defaultMessage": "Saving...", "id": "add_incoming_webhook.saving", } } serverError="" team={ Object { "allow_open_invite": false, "allowed_domains": "", "company_name": "", "create_at": 0, "delete_at": 0, "description": "", "display_name": "name", "email": "", "group_constrained": false, "id": "testteamid", "invite_id": "", "name": "test", "scheme_id": "id", "type": "O", "update_at": 0, } } /> `;
2,394
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/add_oauth_app/add_oauth_app.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import AddOAuthApp from 'components/integrations/add_oauth_app/add_oauth_app'; import {TestHelper} from 'utils/test_helper'; describe('components/integrations/AddOAuthApp', () => { const emptyFunction = jest.fn(); const team = TestHelper.getTeamMock({ id: 'dbcxd9wpzpbpfp8pad78xj12pr', name: 'test', }); test('should match snapshot', () => { const wrapper = shallow( <AddOAuthApp team={team} actions={{addOAuthApp: emptyFunction}} />, ); expect(wrapper).toMatchSnapshot(); }); });
2,397
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/add_oauth_app
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/add_oauth_app/__snapshots__/add_oauth_app.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/integrations/AddOAuthApp should match snapshot 1`] = ` <AbstractOAuthApp action={[Function]} footer={ Object { "defaultMessage": "Save", "id": "installed_oauth_apps.save", } } header={ Object { "defaultMessage": "Add", "id": "add_oauth_app.header", } } loading={ Object { "defaultMessage": "Saving...", "id": "installed_oauth_apps.saving", } } serverError="" team={ Object { "allow_open_invite": false, "allowed_domains": "", "company_name": "", "create_at": 0, "delete_at": 0, "description": "", "display_name": "name", "email": "", "group_constrained": false, "id": "dbcxd9wpzpbpfp8pad78xj12pr", "invite_id": "", "name": "test", "scheme_id": "id", "type": "O", "update_at": 0, } } /> `;
2,398
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/add_outgoing_webhook/add_outgoing_webhook.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import AddOutgoingWebhook from 'components/integrations/add_outgoing_webhook/add_outgoing_webhook'; import {TestHelper} from 'utils/test_helper'; describe('components/integrations/AddOutgoingWebhook', () => { test('should match snapshot', () => { const emptyFunction = jest.fn(); const team = TestHelper.getTeamMock({ id: 'testteamid', name: 'test', }); const wrapper = shallow( <AddOutgoingWebhook team={team} actions={{createOutgoingHook: emptyFunction}} enablePostUsernameOverride={false} enablePostIconOverride={false} />, ); expect(wrapper).toMatchSnapshot(); }); });
2,401
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/add_outgoing_webhook
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/add_outgoing_webhook/__snapshots__/add_outgoing_webhook.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/integrations/AddOutgoingWebhook should match snapshot 1`] = ` <AbstractOutgoingWebhook action={[Function]} enablePostIconOverride={false} enablePostUsernameOverride={false} footer={ Object { "defaultMessage": "Save", "id": "add_outgoing_webhook.save", } } header={ Object { "defaultMessage": "Add", "id": "integrations.add", } } loading={ Object { "defaultMessage": "Saving...", "id": "add_outgoing_webhook.saving", } } renderExtra="" serverError="" team={ Object { "allow_open_invite": false, "allowed_domains": "", "company_name": "", "create_at": 0, "delete_at": 0, "description": "", "display_name": "name", "email": "", "group_constrained": false, "id": "testteamid", "invite_id": "", "name": "test", "scheme_id": "id", "type": "O", "update_at": 0, } } /> `;
2,402
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/bots/bot.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import {FormattedMessage} from 'react-intl'; import {generateId} from 'mattermost-redux/utils/helpers'; import Markdown from 'components/markdown'; import {TestHelper as UtilsTestHelper} from 'utils/test_helper'; import Bot from './bot'; describe('components/integrations/bots/Bot', () => { const team = UtilsTestHelper.getTeamMock(); const actions = { disableBot: jest.fn(), enableBot: jest.fn(), createUserAccessToken: jest.fn(), revokeUserAccessToken: jest.fn(), enableUserAccessToken: jest.fn(), disableUserAccessToken: jest.fn(), }; it('regular bot', () => { const bot = UtilsTestHelper.getBotMock({user_id: '1'}); const user = UtilsTestHelper.getUserMock({id: bot.user_id}); const wrapper = shallow( <Bot bot={bot} user={user} owner={undefined} accessTokens={{}} team={team} actions={actions} fromApp={false} />, ); expect(wrapper.contains(bot.display_name + ' (@' + bot.username + ')')).toEqual(true); expect(wrapper.contains(<Markdown message={bot.description}/>)).toEqual(true); expect(wrapper.contains('plugin')).toEqual(true); // if bot managed by plugin, remove ability to edit from UI expect(wrapper.contains( <FormattedMessage id='bot.manage.create_token' defaultMessage='Create New Token' />, )).toEqual(false); expect(wrapper.contains( <FormattedMessage id='bots.manage.edit' defaultMessage='Edit' />, )).toEqual(false); expect(wrapper.contains( <FormattedMessage id='bot.manage.disable' defaultMessage='Disable' />, )).toEqual(false); expect(wrapper.contains( <FormattedMessage id='bot.manage.enable' defaultMessage='Enable' />, )).toEqual(false); }); it('app bot', () => { const bot = UtilsTestHelper.getBotMock({user_id: '1'}); const user = UtilsTestHelper.getUserMock({id: bot.user_id}); const wrapper = shallow( <Bot bot={bot} user={user} owner={undefined} accessTokens={{}} team={team} actions={actions} fromApp={true} />, ); expect(wrapper.contains(bot.display_name + ' (@' + bot.username + ')')).toEqual(true); expect(wrapper.contains(<Markdown message={bot.description}/>)).toEqual(true); expect(wrapper.contains('Apps Framework')).toEqual(true); // if bot managed by plugin, remove ability to edit from UI expect(wrapper.contains( <FormattedMessage id='bot.manage.create_token' defaultMessage='Create New Token' />, )).toEqual(true); expect(wrapper.contains( <FormattedMessage id='bots.manage.edit' defaultMessage='Edit' />, )).toEqual(true); expect(wrapper.contains( <FormattedMessage id='bot.manage.disable' defaultMessage='Disable' />, )).toEqual(true); expect(wrapper.contains( <FormattedMessage id='bot.manage.enable' defaultMessage='Enable' />, )).toEqual(false); }); it('disabled bot', () => { const bot = UtilsTestHelper.getBotMock({user_id: '1'}); bot.delete_at = 100; // disabled const user = UtilsTestHelper.getUserMock({id: bot.user_id}); const wrapper = shallow( <Bot bot={bot} user={user} owner={undefined} accessTokens={{}} team={team} actions={actions} fromApp={false} />, ); expect(wrapper.contains(bot.display_name + ' (@' + bot.username + ')')).toEqual(true); expect(wrapper.contains(<Markdown message={bot.description}/>)).toEqual(true); expect(wrapper.contains('plugin')).toEqual(true); expect(wrapper.contains( <FormattedMessage id='bot.manage.create_token' defaultMessage='Create New Token' />, )).toEqual(false); expect(wrapper.contains( <FormattedMessage id='bots.manage.edit' defaultMessage='Edit' />, )).toEqual(false); expect(wrapper.contains( <FormattedMessage id='bot.manage.disable' defaultMessage='Disable' />, )).toEqual(false); expect(wrapper.contains( <FormattedMessage id='bot.manage.enable' defaultMessage='Enable' />, )).toEqual(true); }); it('bot with owner', () => { const bot = UtilsTestHelper.getBotMock({user_id: '1', owner_id: '1'}); const owner = UtilsTestHelper.getUserMock({id: bot.owner_id}); const user = UtilsTestHelper.getUserMock({id: bot.user_id}); const wrapper = shallow( <Bot bot={bot} owner={owner} user={user} accessTokens={{}} team={team} actions={actions} fromApp={false} />, ); expect(wrapper.contains(owner.username)).toEqual(true); expect(wrapper.contains('plugin')).toEqual(false); // if bot is not managed by plugin, ability to edit from UI is retained expect(wrapper.contains( <FormattedMessage id='bot.manage.create_token' defaultMessage='Create New Token' />, )).toEqual(true); expect(wrapper.contains( <FormattedMessage id='bots.manage.edit' defaultMessage='Edit' />, )).toEqual(true); expect(wrapper.contains( <FormattedMessage id='bot.manage.disable' defaultMessage='Disable' />, )).toEqual(true); }); it('bot with access tokens', () => { const bot = UtilsTestHelper.getBotMock({user_id: '1'}); const tokenId = generateId(); const user = UtilsTestHelper.getUserMock({id: bot.user_id}); const accessTokens = { tokenId: UtilsTestHelper.getUserAccessTokenMock({ id: tokenId, user_id: bot.user_id, }), }; const wrapper = shallow( <Bot bot={bot} owner={undefined} user={user} accessTokens={accessTokens} team={team} actions={actions} fromApp={false} />, ); expect(wrapper.contains(tokenId)).toEqual(true); expect(wrapper.contains( <FormattedMessage id='user.settings.tokens.deactivate' defaultMessage='Disable' />, )).toEqual(true); expect(wrapper.contains( <FormattedMessage id='user.settings.tokens.activate' defaultMessage='Enable' />, )).toEqual(false); }); it('bot with disabled access tokens', () => { const bot = UtilsTestHelper.getBotMock({user_id: '1'}); const tokenId = generateId(); const user = UtilsTestHelper.getUserMock({id: bot.user_id}); const accessTokens = { tokenId: UtilsTestHelper.getUserAccessTokenMock({ id: tokenId, user_id: bot.user_id, is_active: false, }), }; const wrapper = shallow( <Bot bot={bot} owner={undefined} user={user} accessTokens={accessTokens} team={team} actions={actions} fromApp={false} />, ); expect(wrapper.contains(tokenId)).toEqual(true); expect(wrapper.contains( <FormattedMessage id='user.settings.tokens.deactivate' defaultMessage='Disable' />, )).toEqual(false); expect(wrapper.contains( <FormattedMessage id='user.settings.tokens.activate' defaultMessage='Enable' />, )).toEqual(true); }); });
2,404
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/bots/bots.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import {TestHelper} from 'utils/test_helper'; import Bot from './bot'; import Bots from './bots'; describe('components/integrations/bots/Bots', () => { const team = TestHelper.getTeamMock(); const actions = { loadBots: jest.fn().mockReturnValue(Promise.resolve({})), getUserAccessTokensForUser: jest.fn(), createUserAccessToken: jest.fn(), revokeUserAccessToken: jest.fn(), enableUserAccessToken: jest.fn(), disableUserAccessToken: jest.fn(), getUser: jest.fn(), disableBot: jest.fn(), enableBot: jest.fn(), fetchAppsBotIDs: jest.fn(), }; it('bots', () => { const bot1 = TestHelper.getBotMock({user_id: '1'}); const bot2 = TestHelper.getBotMock({user_id: '2'}); const bot3 = TestHelper.getBotMock({user_id: '3'}); const bots = { [bot1.user_id]: bot1, [bot2.user_id]: bot2, [bot3.user_id]: bot3, }; const users = { [bot1.user_id]: TestHelper.getUserMock({id: bot1.user_id}), [bot2.user_id]: TestHelper.getUserMock({id: bot2.user_id}), [bot3.user_id]: TestHelper.getUserMock({id: bot3.user_id}), }; const wrapperFull = shallow( <Bots bots={bots} team={team} accessTokens={{}} owners={{}} users={users} actions={actions} appsEnabled={false} appsBotIDs={[]} />, ); wrapperFull.instance().setState({loading: false}); const wrapper = shallow(<div>{(wrapperFull.instance() as Bots).bots()[0]}</div>); expect(wrapper.find('EnabledSection').shallow().contains( <Bot key={bot1.user_id} bot={bot1} owner={undefined} user={users[bot1.user_id]} accessTokens={{}} team={team} actions={actions} fromApp={false} />, )).toEqual(true); expect(wrapper.find('EnabledSection').shallow().contains( <Bot key={bot2.user_id} bot={bot2} owner={undefined} user={users[bot2.user_id]} accessTokens={{}} team={team} actions={actions} fromApp={false} />, )).toEqual(true); expect(wrapper.find('EnabledSection').shallow().contains( <Bot key={bot3.user_id} bot={bot3} owner={undefined} user={users[bot3.user_id]} accessTokens={{}} team={team} actions={actions} fromApp={false} />, )).toEqual(true); }); it('bots with bots from apps', () => { const bot1 = TestHelper.getBotMock({user_id: '1'}); const bot2 = TestHelper.getBotMock({user_id: '2'}); const bot3 = TestHelper.getBotMock({user_id: '3'}); const bots = { [bot1.user_id]: bot1, [bot2.user_id]: bot2, [bot3.user_id]: bot3, }; const users = { [bot1.user_id]: TestHelper.getUserMock({id: bot1.user_id}), [bot2.user_id]: TestHelper.getUserMock({id: bot2.user_id}), [bot3.user_id]: TestHelper.getUserMock({id: bot3.user_id}), }; const wrapperFull = shallow( <Bots bots={bots} team={team} accessTokens={{}} owners={{}} users={users} actions={actions} appsEnabled={true} appsBotIDs={[bot3.user_id]} />, ); wrapperFull.instance().setState({loading: false}); const wrapper = shallow(<div>{(wrapperFull.instance() as Bots).bots()[0]}</div>); expect(wrapper.find('EnabledSection').shallow().contains( <Bot key={bot1.user_id} bot={bot1} owner={undefined} user={users[bot1.user_id]} accessTokens={{}} team={team} actions={actions} fromApp={false} />, )).toEqual(true); expect(wrapper.find('EnabledSection').shallow().contains( <Bot key={bot2.user_id} bot={bot2} owner={undefined} user={users[bot2.user_id]} accessTokens={{}} team={team} actions={actions} fromApp={false} />, )).toEqual(true); expect(wrapper.find('EnabledSection').shallow().contains( <Bot key={bot3.user_id} bot={bot3} owner={undefined} user={users[bot3.user_id]} accessTokens={{}} team={team} actions={actions} fromApp={true} />, )).toEqual(true); }); it('bot owner tokens', () => { const bot1 = TestHelper.getBotMock({user_id: '1', owner_id: '1'}); const bots = { [bot1.user_id]: bot1, }; const owner = TestHelper.getUserMock({id: bot1.owner_id}); const user = TestHelper.getUserMock({id: bot1.user_id}); const passedTokens = { id: TestHelper.getUserAccessTokenMock(), }; const owners = { [bot1.user_id]: owner, }; const users = { [bot1.user_id]: user, }; const tokens = { [bot1.user_id]: passedTokens, }; const wrapperFull = shallow( <Bots bots={bots} team={team} accessTokens={tokens} owners={owners} users={users} actions={actions} appsEnabled={false} appsBotIDs={[]} />, ); wrapperFull.instance().setState({loading: false}); const wrapper = shallow(<div>{(wrapperFull.instance() as Bots).bots()[0]}</div>); expect(wrapper.find('EnabledSection').shallow().contains( <Bot key={bot1.user_id} bot={bot1} owner={owner} user={user} accessTokens={passedTokens} team={team} actions={actions} fromApp={false} />, )).toEqual(true); }); });
2,407
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/bots
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/bots/add_bot/add_bot.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import {TestHelper} from 'utils/test_helper'; import AddBot from './add_bot'; describe('components/integrations/bots/AddBot', () => { const team = TestHelper.getTeamMock(); const actions = { createBot: jest.fn(), patchBot: jest.fn(), uploadProfileImage: jest.fn(), setDefaultProfileImage: jest.fn(), createUserAccessToken: jest.fn(), updateUserRoles: jest.fn(), }; it('blank', () => { const wrapper = shallow( <AddBot maxFileSize={100} team={team} editingUserHasManageSystem={true} actions={actions} />, ); expect(wrapper.containsMatchingElement( <input id='username' value={''} />, )).toEqual(true); expect(wrapper.containsMatchingElement( <input id='displayName' value={''} />, )).toEqual(true); expect(wrapper.containsMatchingElement( <input id='description' value={''} />, )).toEqual(true); expect(wrapper).toMatchSnapshot(); }); it('edit bot', () => { const bot = TestHelper.getBotMock({}); const wrapper = shallow( <AddBot bot={bot} maxFileSize={100} team={team} editingUserHasManageSystem={true} actions={actions} />, ); expect(wrapper.containsMatchingElement( <input id='username' value={bot.username} />, )).toEqual(true); expect(wrapper.containsMatchingElement( <input id='displayName' value={bot.display_name} />, )).toEqual(true); expect(wrapper.containsMatchingElement( <input id='description' value={bot.description} />, )).toEqual(true); }); });
2,410
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/bots/add_bot
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/bots/add_bot/__snapshots__/add_bot.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/integrations/bots/AddBot blank 1`] = ` <div className="backstage-content" > <BackstageHeader> <Link to="/DN/integrations/bots" > <MemoizedFormattedMessage defaultMessage="Bot Accounts" id="bots.manage.header" /> </Link> <MemoizedFormattedMessage defaultMessage="Add" id="bots.manage.add.add" /> </BackstageHeader> <div className="backstage-form" > <form className="form-horizontal" onSubmit={[Function]} > <div className="form-group" > <label className="control-label col-sm-4" htmlFor="username" > <MemoizedFormattedMessage defaultMessage="Username" id="bots.add.username" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="username" maxLength={22} onChange={[Function]} type="text" value="" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="You can use lowercase letters, numbers, periods, dashes, and underscores." id="bot.add.username.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="boticon" > <MemoizedFormattedMessage defaultMessage="Bot Icon" id="bots.add.icon" /> </label> <div className="col-md-5 col-sm-8" > <div className="bot-img-container" > <img alt="bot image" className="bot-img" src={null} style={ Object { "transform": "", "transformOrigin": "", } } /> </div> <div className="btn btn-sm btn-primary btn-file" > <MemoizedFormattedMessage defaultMessage="Upload Image" id="bots.image.upload" /> <input accept=".jpeg,.jpg,.png,.bmp" onChange={[Function]} type="file" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="displayName" > <MemoizedFormattedMessage defaultMessage="Display Name" id="bots.add.displayName" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="displayName" maxLength={64} onChange={[Function]} type="text" value="" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="(Optional) You can choose to display your bot's full name rather than its username." id="bot.add.display_name.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="description" > <MemoizedFormattedMessage defaultMessage="Description" id="bot.add.description" /> </label> <div className="col-md-5 col-sm-8" > <input className="form-control" id="description" maxLength={1024} onChange={[Function]} type="text" value="" /> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="(Optional) Let others know what this bot does." id="bot.add.description.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="role" > <MemoizedFormattedMessage defaultMessage="Role" id="bot.add.role" /> </label> <div className="col-md-5 col-sm-8" > <select className="form-control" disabled={false} onChange={[Function]} value="Member" > <option value="Member" > Member </option> <option value="System Admin" > System Admin </option> </select> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Choose what role the bot should have." id="bot.add.role.help" /> </div> </div> </div> <div className="row bot-profile__section" > <div className="col-md-5 col-sm-8 col-sm-offset-4" > <MemoizedFormattedMessage defaultMessage="Select additional permissions for the account. <link>Read more about roles and permissions</link>." id="admin.manage_roles.botAdditionalRoles" values={ Object { "link": [Function], } } /> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="postAll" > <MemoizedFormattedMessage defaultMessage="post:all" id="bot.add.post_all" /> </label> <div className="col-md-5 col-sm-8 checkbox" > <div className="checkbox no-padding" > <label htmlFor="postAll" > <input checked={false} disabled={false} id="postAll" onChange={[Function]} type="checkbox" /> <MemoizedFormattedMessage defaultMessage="Enabled" id="bot.add.post_all.enabled" /> </label> </div> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Bot will have access to post to all Mattermost channels including direct messages." id="bot.add.post_all.help" /> </div> </div> </div> <div className="form-group" > <label className="control-label col-sm-4" htmlFor="postChannels" > <MemoizedFormattedMessage defaultMessage="post:channels" id="bot.add.post_channels" /> </label> <div className="col-md-5 col-sm-8 checkbox" > <div className="checkbox no-padding" > <label htmlFor="postChannels" > <input checked={false} disabled={false} id="postChannels" onChange={[Function]} type="checkbox" /> <MemoizedFormattedMessage defaultMessage="Enabled" id="bot.add.post_channels.enabled" /> </label> </div> <div className="form__help" > <MemoizedFormattedMessage defaultMessage="Bot will have access to post to all Mattermost public channels." id="bot.add.post_channels.help" /> </div> </div> </div> <div className="backstage-form__footer" > <FormError error={null} errors={ Array [ "", ] } type="backstage" /> <Link className="btn btn-tertiary" to="/DN/integrations/bots" > <MemoizedFormattedMessage defaultMessage="Cancel" id="bots.manage.add.cancel" /> </Link> <Memo(SpinnerButton) className="btn btn-primary" id="saveBot" onClick={[Function]} spinning={false} spinningText={ <Memo(MemoizedFormattedMessage) defaultMessage="Creating..." id="bots.manage.add.creating" /> } type="submit" > <MemoizedFormattedMessage defaultMessage="Create Bot Account" id="bots.manage.add.create" /> </Memo(SpinnerButton)> </div> </form> </div> </div> `;
2,413
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/confirm_integration/confirm_integration.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import type {Bot} from '@mattermost/types/bots'; import type {IncomingWebhook, OAuthApp, OutgoingWebhook} from '@mattermost/types/integrations'; import type {IDMappedObjects} from '@mattermost/types/utilities'; import ConfirmIntegration from 'components/integrations/confirm_integration/confirm_integration'; import {renderWithContext} from 'tests/react_testing_utils'; import {TestHelper} from 'utils/test_helper'; describe('components/integrations/ConfirmIntegration', () => { const id = 'r5tpgt4iepf45jt768jz84djic'; const token = 'jb6oyqh95irpbx8fo9zmndkp1r'; const getSearchString = (type: string, identifier = id) => `?type=${type}&id=${identifier}`; const initialState = { entities: { general: { config: {}, license: { Cloud: 'false', }, }, users: { currentUserId: 'currentUserId', }, }, }; const location = { search: '', }; const team = TestHelper.getTeamMock({ name: 'team_test', }); const oauthApp = { id, client_secret: '<==secret==>', callback_urls: ['https://someCallback', 'https://anotherCallback'], }; const userId = 'b5tpgt4iepf45jt768jz84djhd'; const bot = TestHelper.getBotMock({ user_id: userId, display_name: 'bot', }); const commands = {[id]: TestHelper.getCommandMock({id, token})}; const oauthApps = {[id]: oauthApp} as unknown as IDMappedObjects<OAuthApp>; const incomingHooks: IDMappedObjects<IncomingWebhook> = {[id]: TestHelper.getIncomingWebhookMock({id})}; const outgoingHooks = {[id]: {id, token}} as unknown as IDMappedObjects<OutgoingWebhook>; const bots: Record<string, Bot> = {[userId]: bot}; const props = { team, location, commands, oauthApps, incomingHooks, outgoingHooks, bots, }; test('should match snapshot, oauthApps case', () => { props.location.search = getSearchString('oauth2-apps'); const wrapper = shallow( <ConfirmIntegration {...props}/>, ); expect(wrapper).toMatchSnapshot(); }); test('should match callback URLs of OAuth Apps', () => { props.location.search = getSearchString('oauth2-apps'); const {container} = renderWithContext( <ConfirmIntegration {...props}/>, initialState, ); expect(container.querySelector('.word-break--all')).toHaveTextContent('URL(s): https://someCallback, https://anotherCallback'); }); test('should match snapshot, commands case', () => { props.location.search = getSearchString('commands'); const wrapper = shallow( <ConfirmIntegration {...props}/>, ); expect(wrapper).toMatchSnapshot(); }); test('should match snapshot, incomingHooks case', () => { props.location.search = getSearchString('incoming_webhooks'); const wrapper = shallow( <ConfirmIntegration {...props}/>, ); expect(wrapper).toMatchSnapshot(); }); test('should match snapshot, outgoingHooks case', () => { props.location.search = getSearchString('outgoing_webhooks'); const wrapper = shallow( <ConfirmIntegration {...props}/>, ); expect(wrapper).toMatchSnapshot(); }); test('should match snapshot, outgoingHooks and bad identifier case', () => { props.location.search = getSearchString('outgoing_webhooks', 'bad'); const wrapper = shallow( <ConfirmIntegration {...props}/>, ); expect(wrapper).toMatchSnapshot(); }); test('should match snapshot, bad integration type case', () => { props.location.search = getSearchString('bad'); const wrapper = shallow( <ConfirmIntegration {...props}/>, ); expect(wrapper).toMatchSnapshot(); }); });
2,416
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/confirm_integration
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/confirm_integration/__snapshots__/confirm_integration.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/integrations/ConfirmIntegration should match snapshot, bad integration type case 1`] = `""`; exports[`components/integrations/ConfirmIntegration should match snapshot, commands case 1`] = ` <div className="backstage-content row" > <BackstageHeader> <Link to="/team_test/integrations/commands" > <MemoizedFormattedMessage defaultMessage="Slash Commands" id="slash_commands.header" /> </Link> <MemoizedFormattedMessage defaultMessage="Add" id="integrations.add" /> </BackstageHeader> <div className="backstage-form backstage-form__confirmation" > <h4 className="backstage-form__title" id="formTitle" > <MemoizedFormattedMessage defaultMessage="Setup Successful" id="integrations.successful" /> </h4> <p> <MemoizedFormattedMessage defaultMessage="Your slash command is set up. The following token will be sent in the outgoing payload. Please use it to verify the request came from your Mattermost team (details at <link>Slash Commands</link>)." id="add_command.doneHelp" values={ Object { "link": [Function], } } /> </p> <p className="word-break--all" > <FormattedMarkdownMessage defaultMessage="**Token**: {token}" id="add_command.token" values={ Object { "token": "jb6oyqh95irpbx8fo9zmndkp1r", } } /> <Memo(CopyText) value="jb6oyqh95irpbx8fo9zmndkp1r" /> </p> <div className="backstage-form__footer" > <Link className="btn btn-primary" id="doneButton" to="/team_test/integrations/commands" type="submit" > <MemoizedFormattedMessage defaultMessage="Done" id="integrations.done" /> </Link> </div> </div> </div> `; exports[`components/integrations/ConfirmIntegration should match snapshot, incomingHooks case 1`] = ` <div className="backstage-content row" > <BackstageHeader> <Link to="/team_test/integrations/incoming_webhooks" > <MemoizedFormattedMessage defaultMessage="Incoming Webhooks" id="incoming_webhooks.header" /> </Link> <MemoizedFormattedMessage defaultMessage="Add" id="integrations.add" /> </BackstageHeader> <div className="backstage-form backstage-form__confirmation" > <h4 className="backstage-form__title" id="formTitle" > <MemoizedFormattedMessage defaultMessage="Setup Successful" id="integrations.successful" /> </h4> <p> <MemoizedFormattedMessage defaultMessage="Your incoming webhook is set up. Please send data to the following URL (details at <link>Incoming Webhooks</link>)." id="add_incoming_webhook.doneHelp" values={ Object { "link": [Function], } } /> </p> <p className="word-break--all" > <FormattedMarkdownMessage defaultMessage="**URL**: {url}" id="add_incoming_webhook.url" values={ Object { "url": "\`http://localhost:8065/hooks/r5tpgt4iepf45jt768jz84djic\`", } } /> <Memo(CopyText) value="http://localhost:8065/hooks/r5tpgt4iepf45jt768jz84djic" /> </p> <div className="backstage-form__footer" > <Link className="btn btn-primary" id="doneButton" to="/team_test/integrations/incoming_webhooks" type="submit" > <MemoizedFormattedMessage defaultMessage="Done" id="integrations.done" /> </Link> </div> </div> </div> `; exports[`components/integrations/ConfirmIntegration should match snapshot, oauthApps case 1`] = ` <div className="backstage-content row" > <BackstageHeader> <Link to="/team_test/integrations/oauth2-apps" > <MemoizedFormattedMessage defaultMessage="OAuth 2.0 Applications" id="installed_oauth2_apps.header" /> </Link> <MemoizedFormattedMessage defaultMessage="Add" id="integrations.add" /> </BackstageHeader> <div className="backstage-form backstage-form__confirmation" > <h4 className="backstage-form__title" id="formTitle" > <MemoizedFormattedMessage defaultMessage="Setup Successful" id="integrations.successful" /> </h4> <p key="add_oauth_app.doneHelp" > <MemoizedFormattedMessage defaultMessage="Your OAuth 2.0 application is set up. Please use the following Client ID and Client Secret when requesting authorization for your application (details at <link>oAuth 2 Applications</link>)." id="add_oauth_app.doneHelp" values={ Object { "link": [Function], } } /> </p> <p key="add_oauth_app.clientId" > <FormattedMarkdownMessage defaultMessage="**Client ID**: {id}" id="add_oauth_app.clientId" values={ Object { "id": "r5tpgt4iepf45jt768jz84djic", } } /> <Memo(CopyText) defaultMessage="Copy Client Id" idMessage="integrations.copy_client_id" value="r5tpgt4iepf45jt768jz84djic" /> <br /> <FormattedMarkdownMessage defaultMessage="**Client Secret**: {secret}" id="add_oauth_app.clientSecret" values={ Object { "secret": "<==secret==>", } } /> <Memo(CopyText) defaultMessage="Copy Client Secret" idMessage="integrations.copy_client_secret" value="<==secret==>" /> </p> <p key="add_oauth_app.doneUrlHelp" > <MemoizedFormattedMessage defaultMessage="Here are your authorized redirect URLs." id="add_oauth_app.doneUrlHelp" /> </p> <p className="word-break--all" > <FormattedMarkdownMessage defaultMessage="**URL(s)**: {url}" id="add_oauth_app.url" values={ Object { "url": "https://someCallback, https://anotherCallback", } } /> </p> <div className="backstage-form__footer" > <Link className="btn btn-primary" id="doneButton" to="/team_test/integrations/oauth2-apps" type="submit" > <MemoizedFormattedMessage defaultMessage="Done" id="integrations.done" /> </Link> </div> </div> </div> `; exports[`components/integrations/ConfirmIntegration should match snapshot, outgoingHooks and bad identifier case 1`] = `""`; exports[`components/integrations/ConfirmIntegration should match snapshot, outgoingHooks case 1`] = ` <div className="backstage-content row" > <BackstageHeader> <Link to="/team_test/integrations/outgoing_webhooks" > <MemoizedFormattedMessage defaultMessage="Outgoing Webhooks" id="add_outgoing_webhook.header" /> </Link> <MemoizedFormattedMessage defaultMessage="Add" id="integrations.add" /> </BackstageHeader> <div className="backstage-form backstage-form__confirmation" > <h4 className="backstage-form__title" id="formTitle" > <MemoizedFormattedMessage defaultMessage="Setup Successful" id="integrations.successful" /> </h4> <p> <MemoizedFormattedMessage defaultMessage="Your outgoing webhook is set up. The following token will be sent in the outgoing payload. Please use it to verify that the request came from your Mattermost team (details at <link>Outgoing Webhooks</link>)." id="add_outgoing_webhook.doneHelp" values={ Object { "link": [Function], } } /> </p> <p className="word-break--all" > <FormattedMarkdownMessage defaultMessage="**Token**: {token}" id="add_outgoing_webhook.token" values={ Object { "token": "jb6oyqh95irpbx8fo9zmndkp1r", } } /> <Memo(CopyText) value="jb6oyqh95irpbx8fo9zmndkp1r" /> </p> <div className="backstage-form__footer" > <Link className="btn btn-primary" id="doneButton" to="/team_test/integrations/outgoing_webhooks" type="submit" > <MemoizedFormattedMessage defaultMessage="Done" id="integrations.done" /> </Link> </div> </div> </div> `;
2,419
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/edit_command/edit_command.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import type {Command} from '@mattermost/types/integrations'; import type {Team} from '@mattermost/types/teams'; import EditCommand from 'components/integrations/edit_command/edit_command'; import {TestHelper} from 'utils/test_helper'; describe('components/integrations/EditCommand', () => { const getCustomTeamCommands = jest.fn( () => { return new Promise<Command[]>((resolve) => { process.nextTick(() => resolve([])); }); }, ); const commands = { r5tpgt4iepf45jt768jz84djic: TestHelper.getCommandMock({ id: 'r5tpgt4iepf45jt768jz84djic', display_name: 'display_name', description: 'description', trigger: 'trigger', auto_complete: true, auto_complete_hint: 'auto_complete_hint', auto_complete_desc: 'auto_complete_desc', token: 'jb6oyqh95irpbx8fo9zmndkp1r', create_at: 1499722850203, creator_id: '88oybd1dwfdoxpkpw1h5kpbyco', delete_at: 0, icon_url: 'https://google.com/icon', method: 'G', team_id: 'm5gix3oye3du8ghk4ko6h9cq7y', update_at: 1504468859001, url: 'https://google.com/command', username: 'username', }), }; const team: Team = TestHelper.getTeamMock({ name: 'test', id: 'm5gix3oye3du8ghk4ko6h9cq7y', }); const editCommandRequest = { status: 'not_started', error: null, }; const baseProps = { team, commandId: 'r5tpgt4iepf45jt768jz84djic', commands, editCommandRequest, actions: { getCustomTeamCommands, editCommand: jest.fn(), }, enableCommands: true, }; test('should match snapshot', () => { const wrapper = shallow( <EditCommand {...baseProps}/>, ); wrapper.setState({originalCommand: commands.r5tpgt4iepf45jt768jz84djic}); expect(wrapper).toMatchSnapshot(); expect(baseProps.actions.getCustomTeamCommands).toHaveBeenCalled(); expect(baseProps.actions.getCustomTeamCommands).toHaveBeenCalledWith(team.id); }); test('should match snapshot, loading', () => { const wrapper = shallow( <EditCommand {...baseProps}/>, ); expect(wrapper).toMatchSnapshot(); }); test('should match snapshot when EnableCommands is false', () => { const actions = { getCustomTeamCommands: jest.fn(), editCommand: jest.fn(), }; const props = {...baseProps, actions, enableCommands: false}; const wrapper = shallow( <EditCommand {...props}/>, ); expect(wrapper).toMatchSnapshot(); expect(actions.getCustomTeamCommands).not.toHaveBeenCalled(); }); test('should have match state when handleConfirmModal is called', () => { const props = {...baseProps, getCustomTeamCommands}; const wrapper = shallow<EditCommand>( <EditCommand {...props}/>, ); wrapper.setState({showConfirmModal: false}); wrapper.instance().handleConfirmModal(); expect(wrapper.state('showConfirmModal')).toEqual(true); }); test('should have match state when confirmModalDismissed is called', () => { const props = {...baseProps, getCustomTeamCommands}; const wrapper = shallow<EditCommand>( <EditCommand {...props}/>, ); wrapper.setState({showConfirmModal: true}); wrapper.instance().confirmModalDismissed(); expect(wrapper.state('showConfirmModal')).toEqual(false); }); test('should have match renderExtra', () => { const props = {...baseProps, getCustomTeamCommands}; const wrapper = shallow<EditCommand>( <EditCommand {...props}/>, ); expect(wrapper.instance().renderExtra()).toMatchSnapshot(); }); test('should have match when editCommand is called', () => { const props = {...baseProps, getCustomTeamCommands}; const wrapper = shallow<EditCommand>( <EditCommand {...props}/>, ); wrapper.setState({originalCommand: commands.r5tpgt4iepf45jt768jz84djic}); const instance = wrapper.instance(); instance.handleConfirmModal = jest.fn(); instance.submitCommand = jest.fn(); wrapper.instance().editCommand(commands.r5tpgt4iepf45jt768jz84djic); expect(instance.handleConfirmModal).not.toBeCalled(); expect(instance.submitCommand).toBeCalled(); }); });
2,422
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/edit_command
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/edit_command/__snapshots__/edit_command.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/integrations/EditCommand should have match renderExtra 1`] = ` <ConfirmModal confirmButtonClass="btn btn-primary" confirmButtonText={ <Memo(MemoizedFormattedMessage) defaultMessage="Update" id="update_command.update" /> } message={ <Memo(MemoizedFormattedMessage) defaultMessage="Your changes may break the existing slash command. Are you sure you would like to update it?" id="update_command.question" /> } modalClass="" onCancel={[Function]} onConfirm={[Function]} show={false} title={ <Memo(MemoizedFormattedMessage) defaultMessage="Edit Slash Command" id="update_command.confirm" /> } /> `; exports[`components/integrations/EditCommand should match snapshot 1`] = ` <injectIntl(AbstractCommand) action={[Function]} footer={ Object { "defaultMessage": "Update", "id": "edit_command.update", } } header={ Object { "defaultMessage": "Edit", "id": "integrations.edit", } } initialCommand={ Object { "auto_complete": true, "auto_complete_desc": "auto_complete_desc", "auto_complete_hint": "auto_complete_hint", "create_at": 1499722850203, "creator_id": "88oybd1dwfdoxpkpw1h5kpbyco", "delete_at": 0, "description": "description", "display_name": "display_name", "icon_url": "https://google.com/icon", "id": "r5tpgt4iepf45jt768jz84djic", "method": "G", "team_id": "m5gix3oye3du8ghk4ko6h9cq7y", "token": "jb6oyqh95irpbx8fo9zmndkp1r", "trigger": "trigger", "update_at": 1504468859001, "url": "https://google.com/command", "username": "username", } } loading={ Object { "defaultMessage": "Updating...", "id": "edit_command.updating", } } renderExtra={ <ConfirmModal confirmButtonClass="btn btn-primary" confirmButtonText={ <Memo(MemoizedFormattedMessage) defaultMessage="Update" id="update_command.update" /> } message={ <Memo(MemoizedFormattedMessage) defaultMessage="Your changes may break the existing slash command. Are you sure you would like to update it?" id="update_command.question" /> } modalClass="" onCancel={[Function]} onConfirm={[Function]} show={false} title={ <Memo(MemoizedFormattedMessage) defaultMessage="Edit Slash Command" id="update_command.confirm" /> } /> } serverError="" team={ Object { "allow_open_invite": false, "allowed_domains": "", "company_name": "", "create_at": 0, "delete_at": 0, "description": "", "display_name": "name", "email": "", "group_constrained": false, "id": "m5gix3oye3du8ghk4ko6h9cq7y", "invite_id": "", "name": "test", "scheme_id": "id", "type": "O", "update_at": 0, } } /> `; exports[`components/integrations/EditCommand should match snapshot when EnableCommands is false 1`] = `<LoadingScreen />`; exports[`components/integrations/EditCommand should match snapshot, loading 1`] = `<LoadingScreen />`;
2,423
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/edit_incoming_webhook/edit_incoming_webhook.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import type {IncomingWebhook} from '@mattermost/types/integrations'; import type {ActionResult} from 'mattermost-redux/types/actions'; import EditIncomingWebhook from 'components/integrations/edit_incoming_webhook/edit_incoming_webhook'; import {getHistory} from 'utils/browser_history'; import {TestHelper} from 'utils/test_helper'; describe('components/integrations/EditIncomingWebhook', () => { const hook = { id: 'id', create_at: 0, update_at: 10, delete_at: 20, user_id: 'user_id', channel_id: 'channel_id', team_id: 'team_id', display_name: 'display_name', description: 'description', username: 'username', icon_url: 'http://test/icon.png', channel_locked: false, }; const updateIncomingHook = jest.fn(); const getIncomingHook = jest.fn(); const actions = { updateIncomingHook: updateIncomingHook as (hook: IncomingWebhook) => Promise<ActionResult>, getIncomingHook: getIncomingHook as (hookId: string) => Promise<ActionResult>, }; const requiredProps = { hookId: 'somehookid', teamId: 'testteamid', team: TestHelper.getTeamMock(), updateIncomingHookRequest: { status: 'not_started', error: null, }, enableIncomingWebhooks: true, enablePostUsernameOverride: true, enablePostIconOverride: true, }; afterEach(() => { updateIncomingHook.mockReset(); getIncomingHook.mockReset(); }); test('should show Loading screen when no hook is provided', () => { const props = {...requiredProps, actions}; const wrapper = shallow(<EditIncomingWebhook {...props}/>); expect(wrapper).toMatchSnapshot(); expect(getIncomingHook).toHaveBeenCalledTimes(1); expect(getIncomingHook).toBeCalledWith(props.hookId); }); test('should show AbstractIncomingWebhook', () => { const props = {...requiredProps, actions, hook}; const wrapper = shallow(<EditIncomingWebhook {...props}/>); expect(wrapper).toMatchSnapshot(); }); test('should not call getIncomingHook', () => { const props = {...requiredProps, enableIncomingWebhooks: false, actions}; const wrapper = shallow(<EditIncomingWebhook {...props}/>); expect(wrapper).toMatchSnapshot(); expect(getIncomingHook).toHaveBeenCalledTimes(0); }); test('should have called submitHook when editIncomingHook is initiated (no server error)', async () => { const newUpdateIncomingHook = jest.fn().mockReturnValue({data: ''}); const newActions = {...actions, updateIncomingHook: newUpdateIncomingHook}; const asyncHook = {...hook}; const props = {...requiredProps, actions: newActions, hook}; const wrapper = shallow<EditIncomingWebhook>(<EditIncomingWebhook {...props}/>); const instance = wrapper.instance(); await instance.editIncomingHook(asyncHook); expect(wrapper).toMatchSnapshot(); expect(newActions.updateIncomingHook).toHaveBeenCalledTimes(1); expect(newActions.updateIncomingHook).toBeCalledWith(asyncHook); expect(wrapper.state('serverError')).toEqual(''); }); test('should have called submitHook when editIncomingHook is initiated (with server error)', async () => { const newUpdateIncomingHook = jest.fn().mockReturnValue({data: ''}); const newActions = {...actions, updateIncomingHook: newUpdateIncomingHook}; const asyncHook = {...hook}; const props = {...requiredProps, actions: newActions, hook}; const wrapper = shallow<EditIncomingWebhook>(<EditIncomingWebhook {...props}/>); const instance = wrapper.instance(); await instance.editIncomingHook(asyncHook); expect(wrapper).toMatchSnapshot(); expect(newActions.updateIncomingHook).toHaveBeenCalledTimes(1); expect(newActions.updateIncomingHook).toBeCalledWith(asyncHook); }); test('should have called submitHook when editIncomingHook is initiated (with data)', async () => { const newUpdateIncomingHook = jest.fn().mockReturnValue({data: 'data'}); const newActions = {...actions, updateIncomingHook: newUpdateIncomingHook}; const asyncHook = {...hook}; const props = {...requiredProps, actions: newActions, hook}; const wrapper = shallow<EditIncomingWebhook>(<EditIncomingWebhook {...props}/>); const instance = wrapper.instance(); await instance.editIncomingHook(asyncHook); expect(wrapper).toMatchSnapshot(); expect(newUpdateIncomingHook).toHaveBeenCalledTimes(1); expect(newUpdateIncomingHook).toBeCalledWith(asyncHook); expect(wrapper.state('serverError')).toEqual(''); expect(getHistory().push).toHaveBeenCalledWith(`/${requiredProps.team.name}/integrations/incoming_webhooks`); }); });
2,426
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/edit_incoming_webhook
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/edit_incoming_webhook/__snapshots__/edit_incoming_webhook.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/integrations/EditIncomingWebhook should have called submitHook when editIncomingHook is initiated (no server error) 1`] = ` <AbstractIncomingWebhook action={[Function]} enablePostIconOverride={true} enablePostUsernameOverride={true} footer={ Object { "defaultMessage": "Update", "id": "update_incoming_webhook.update", } } header={ Object { "defaultMessage": "Edit", "id": "integrations.edit", } } initialHook={ Object { "channel_id": "channel_id", "channel_locked": false, "create_at": 0, "delete_at": 20, "description": "description", "display_name": "display_name", "icon_url": "http://test/icon.png", "id": "id", "team_id": "team_id", "update_at": 10, "user_id": "user_id", "username": "username", } } loading={ Object { "defaultMessage": "Updating...", "id": "update_incoming_webhook.updating", } } serverError="" team={ Object { "allow_open_invite": false, "allowed_domains": "", "company_name": "", "create_at": 0, "delete_at": 0, "description": "", "display_name": "name", "email": "", "group_constrained": false, "id": "team_id", "invite_id": "", "name": "DN", "scheme_id": "id", "type": "O", "update_at": 0, } } /> `; exports[`components/integrations/EditIncomingWebhook should have called submitHook when editIncomingHook is initiated (with data) 1`] = ` <AbstractIncomingWebhook action={[Function]} enablePostIconOverride={true} enablePostUsernameOverride={true} footer={ Object { "defaultMessage": "Update", "id": "update_incoming_webhook.update", } } header={ Object { "defaultMessage": "Edit", "id": "integrations.edit", } } initialHook={ Object { "channel_id": "channel_id", "channel_locked": false, "create_at": 0, "delete_at": 20, "description": "description", "display_name": "display_name", "icon_url": "http://test/icon.png", "id": "id", "team_id": "team_id", "update_at": 10, "user_id": "user_id", "username": "username", } } loading={ Object { "defaultMessage": "Updating...", "id": "update_incoming_webhook.updating", } } serverError="" team={ Object { "allow_open_invite": false, "allowed_domains": "", "company_name": "", "create_at": 0, "delete_at": 0, "description": "", "display_name": "name", "email": "", "group_constrained": false, "id": "team_id", "invite_id": "", "name": "DN", "scheme_id": "id", "type": "O", "update_at": 0, } } /> `; exports[`components/integrations/EditIncomingWebhook should have called submitHook when editIncomingHook is initiated (with server error) 1`] = ` <AbstractIncomingWebhook action={[Function]} enablePostIconOverride={true} enablePostUsernameOverride={true} footer={ Object { "defaultMessage": "Update", "id": "update_incoming_webhook.update", } } header={ Object { "defaultMessage": "Edit", "id": "integrations.edit", } } initialHook={ Object { "channel_id": "channel_id", "channel_locked": false, "create_at": 0, "delete_at": 20, "description": "description", "display_name": "display_name", "icon_url": "http://test/icon.png", "id": "id", "team_id": "team_id", "update_at": 10, "user_id": "user_id", "username": "username", } } loading={ Object { "defaultMessage": "Updating...", "id": "update_incoming_webhook.updating", } } serverError="" team={ Object { "allow_open_invite": false, "allowed_domains": "", "company_name": "", "create_at": 0, "delete_at": 0, "description": "", "display_name": "name", "email": "", "group_constrained": false, "id": "team_id", "invite_id": "", "name": "DN", "scheme_id": "id", "type": "O", "update_at": 0, } } /> `; exports[`components/integrations/EditIncomingWebhook should not call getIncomingHook 1`] = `<LoadingScreen />`; exports[`components/integrations/EditIncomingWebhook should show AbstractIncomingWebhook 1`] = ` <AbstractIncomingWebhook action={[Function]} enablePostIconOverride={true} enablePostUsernameOverride={true} footer={ Object { "defaultMessage": "Update", "id": "update_incoming_webhook.update", } } header={ Object { "defaultMessage": "Edit", "id": "integrations.edit", } } initialHook={ Object { "channel_id": "channel_id", "channel_locked": false, "create_at": 0, "delete_at": 20, "description": "description", "display_name": "display_name", "icon_url": "http://test/icon.png", "id": "id", "team_id": "team_id", "update_at": 10, "user_id": "user_id", "username": "username", } } loading={ Object { "defaultMessage": "Updating...", "id": "update_incoming_webhook.updating", } } serverError="" team={ Object { "allow_open_invite": false, "allowed_domains": "", "company_name": "", "create_at": 0, "delete_at": 0, "description": "", "display_name": "name", "email": "", "group_constrained": false, "id": "team_id", "invite_id": "", "name": "DN", "scheme_id": "id", "type": "O", "update_at": 0, } } /> `; exports[`components/integrations/EditIncomingWebhook should show Loading screen when no hook is provided 1`] = `<LoadingScreen />`;
2,427
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/edit_oauth_app/edit_oauth_app.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import type {OAuthApp} from '@mattermost/types/integrations'; import type {Team} from '@mattermost/types/teams'; import EditOAuthApp from 'components/integrations/edit_oauth_app/edit_oauth_app'; import {getHistory} from 'utils/browser_history'; describe('components/integrations/EditOAuthApp', () => { const oauthApp: OAuthApp = { id: 'facxd9wpzpbpfp8pad78xj75pr', name: 'testApp', client_secret: '88cxd9wpzpbpfp8pad78xj75pr', create_at: 1501365458934, creator_id: '88oybd1dwfdoxpkpw1h5kpbyco', description: 'testing', homepage: 'https://test.com', icon_url: 'https://test.com/icon', is_trusted: true, update_at: 1501365458934, callback_urls: ['https://test.com/callback', 'https://test.com/callback2'], }; const team: Team = { id: 'dbcxd9wpzpbpfp8pad78xj12pr', name: 'test', } as Team; const editOAuthAppRequest = { status: 'not_started', error: null, }; const baseProps = { team, oauthAppId: oauthApp.id, editOAuthAppRequest, actions: { getOAuthApp: jest.fn(), editOAuthApp: jest.fn(), }, enableOAuthServiceProvider: true, }; test('should match snapshot, loading', () => { const props = {...baseProps, oauthApp}; const wrapper = shallow( <EditOAuthApp {...props}/>, ); expect(wrapper).toMatchSnapshot(); }); test('should match snapshot', () => { const props = {...baseProps, oauthApp}; const wrapper = shallow( <EditOAuthApp {...props}/>, ); expect(wrapper).toMatchSnapshot(); expect(props.actions.getOAuthApp).toHaveBeenCalledWith(oauthApp.id); }); test('should match snapshot when EnableOAuthServiceProvider is false', () => { const props = {...baseProps, oauthApp, enableOAuthServiceProvider: false}; const wrapper = shallow( <EditOAuthApp {...props}/>, ); expect(wrapper).toMatchSnapshot(); expect(props.actions.getOAuthApp).not.toHaveBeenCalledWith(); }); test('should have match state when handleConfirmModal is called', () => { const props = {...baseProps, oauthApp}; const wrapper = shallow<EditOAuthApp>( <EditOAuthApp {...props}/>, ); wrapper.setState({showConfirmModal: false}); wrapper.instance().handleConfirmModal(); expect(wrapper.state('showConfirmModal')).toEqual(true); }); test('should have match state when confirmModalDismissed is called', () => { const props = {...baseProps, oauthApp}; const wrapper = shallow<EditOAuthApp>( <EditOAuthApp {...props}/>, ); wrapper.setState({showConfirmModal: true}); wrapper.instance().confirmModalDismissed(); expect(wrapper.state('showConfirmModal')).toEqual(false); }); test('should have match renderExtra', () => { const props = {...baseProps, oauthApp}; const wrapper = shallow<EditOAuthApp>( <EditOAuthApp {...props}/>, ); expect(wrapper.instance().renderExtra()).toMatchSnapshot(); }); test('should have match when editOAuthApp is called', () => { const props = {...baseProps, oauthApp}; const wrapper = shallow<EditOAuthApp>( <EditOAuthApp {...props}/>, ); const instance = wrapper.instance(); instance.handleConfirmModal = jest.fn(); instance.submitOAuthApp = jest.fn(); instance.editOAuthApp(oauthApp); expect(instance.handleConfirmModal).not.toBeCalled(); expect(instance.submitOAuthApp).toBeCalled(); }); test('should have match when submitOAuthApp is called on success', async () => { baseProps.actions.editOAuthApp = jest.fn().mockImplementation( () => { return new Promise((resolve) => { process.nextTick(() => resolve({ data: 'data', error: null, })); }); }, ); const props = {...baseProps, oauthApp}; const wrapper = shallow<EditOAuthApp>( <EditOAuthApp {...props}/>, ); const instance = wrapper.instance(); wrapper.setState({showConfirmModal: true}); await instance.submitOAuthApp(); expect(wrapper.state('serverError')).toEqual(''); expect(getHistory().push).toHaveBeenCalledWith(`/${team.name}/integrations/oauth2-apps`); }); test('should have match when submitOAuthApp is called on error', async () => { baseProps.actions.editOAuthApp = jest.fn().mockImplementation( () => { return new Promise((resolve) => { process.nextTick(() => resolve({ data: null, error: {message: 'error message'}, })); }); }, ); const props = {...baseProps, oauthApp}; const wrapper = shallow<EditOAuthApp>( <EditOAuthApp {...props}/>, ); const instance = wrapper.instance(); wrapper.setState({showConfirmModal: true}); await instance.submitOAuthApp(); expect(wrapper.state('showConfirmModal')).toEqual(false); expect(wrapper.state('serverError')).toEqual('error message'); }); });
2,430
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/edit_oauth_app
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/edit_oauth_app/__snapshots__/edit_oauth_app.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/integrations/EditOAuthApp should have match renderExtra 1`] = ` <ConfirmModal confirmButtonClass="btn btn-primary" confirmButtonText={ <Memo(MemoizedFormattedMessage) defaultMessage="Update" id="update_command.update" /> } message={ <Memo(MemoizedFormattedMessage) defaultMessage="Your changes may break the existing OAuth 2.0 application. Are you sure you would like to update it?" id="update_oauth_app.question" /> } modalClass="" onCancel={[Function]} onConfirm={[Function]} show={false} title={ <Memo(MemoizedFormattedMessage) defaultMessage="Edit OAuth 2.0 application" id="update_oauth_app.confirm" /> } /> `; exports[`components/integrations/EditOAuthApp should match snapshot 1`] = ` <AbstractOAuthApp action={[Function]} footer={ Object { "defaultMessage": "Update", "id": "update_incoming_webhook.update", } } header={ Object { "defaultMessage": "Edit", "id": "integrations.edit", } } initialApp={ Object { "callback_urls": Array [ "https://test.com/callback", "https://test.com/callback2", ], "client_secret": "88cxd9wpzpbpfp8pad78xj75pr", "create_at": 1501365458934, "creator_id": "88oybd1dwfdoxpkpw1h5kpbyco", "description": "testing", "homepage": "https://test.com", "icon_url": "https://test.com/icon", "id": "facxd9wpzpbpfp8pad78xj75pr", "is_trusted": true, "name": "testApp", "update_at": 1501365458934, } } loading={ Object { "defaultMessage": "Updating...", "id": "update_incoming_webhook.updating", } } renderExtra={ <ConfirmModal confirmButtonClass="btn btn-primary" confirmButtonText={ <Memo(MemoizedFormattedMessage) defaultMessage="Update" id="update_command.update" /> } message={ <Memo(MemoizedFormattedMessage) defaultMessage="Your changes may break the existing OAuth 2.0 application. Are you sure you would like to update it?" id="update_oauth_app.question" /> } modalClass="" onCancel={[Function]} onConfirm={[Function]} show={false} title={ <Memo(MemoizedFormattedMessage) defaultMessage="Edit OAuth 2.0 application" id="update_oauth_app.confirm" /> } /> } serverError="" team={ Object { "id": "dbcxd9wpzpbpfp8pad78xj12pr", "name": "test", } } /> `; exports[`components/integrations/EditOAuthApp should match snapshot when EnableOAuthServiceProvider is false 1`] = ` <AbstractOAuthApp action={[Function]} footer={ Object { "defaultMessage": "Update", "id": "update_incoming_webhook.update", } } header={ Object { "defaultMessage": "Edit", "id": "integrations.edit", } } initialApp={ Object { "callback_urls": Array [ "https://test.com/callback", "https://test.com/callback2", ], "client_secret": "88cxd9wpzpbpfp8pad78xj75pr", "create_at": 1501365458934, "creator_id": "88oybd1dwfdoxpkpw1h5kpbyco", "description": "testing", "homepage": "https://test.com", "icon_url": "https://test.com/icon", "id": "facxd9wpzpbpfp8pad78xj75pr", "is_trusted": true, "name": "testApp", "update_at": 1501365458934, } } loading={ Object { "defaultMessage": "Updating...", "id": "update_incoming_webhook.updating", } } renderExtra={ <ConfirmModal confirmButtonClass="btn btn-primary" confirmButtonText={ <Memo(MemoizedFormattedMessage) defaultMessage="Update" id="update_command.update" /> } message={ <Memo(MemoizedFormattedMessage) defaultMessage="Your changes may break the existing OAuth 2.0 application. Are you sure you would like to update it?" id="update_oauth_app.question" /> } modalClass="" onCancel={[Function]} onConfirm={[Function]} show={false} title={ <Memo(MemoizedFormattedMessage) defaultMessage="Edit OAuth 2.0 application" id="update_oauth_app.confirm" /> } /> } serverError="" team={ Object { "id": "dbcxd9wpzpbpfp8pad78xj12pr", "name": "test", } } /> `; exports[`components/integrations/EditOAuthApp should match snapshot, loading 1`] = ` <AbstractOAuthApp action={[Function]} footer={ Object { "defaultMessage": "Update", "id": "update_incoming_webhook.update", } } header={ Object { "defaultMessage": "Edit", "id": "integrations.edit", } } initialApp={ Object { "callback_urls": Array [ "https://test.com/callback", "https://test.com/callback2", ], "client_secret": "88cxd9wpzpbpfp8pad78xj75pr", "create_at": 1501365458934, "creator_id": "88oybd1dwfdoxpkpw1h5kpbyco", "description": "testing", "homepage": "https://test.com", "icon_url": "https://test.com/icon", "id": "facxd9wpzpbpfp8pad78xj75pr", "is_trusted": true, "name": "testApp", "update_at": 1501365458934, } } loading={ Object { "defaultMessage": "Updating...", "id": "update_incoming_webhook.updating", } } renderExtra={ <ConfirmModal confirmButtonClass="btn btn-primary" confirmButtonText={ <Memo(MemoizedFormattedMessage) defaultMessage="Update" id="update_command.update" /> } message={ <Memo(MemoizedFormattedMessage) defaultMessage="Your changes may break the existing OAuth 2.0 application. Are you sure you would like to update it?" id="update_oauth_app.question" /> } modalClass="" onCancel={[Function]} onConfirm={[Function]} show={false} title={ <Memo(MemoizedFormattedMessage) defaultMessage="Edit OAuth 2.0 application" id="update_oauth_app.confirm" /> } /> } serverError="" team={ Object { "id": "dbcxd9wpzpbpfp8pad78xj12pr", "name": "test", } } /> `;
2,431
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/edit_outgoing_webhook/edit_outgoing_webhook.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import type {OutgoingWebhook} from '@mattermost/types/integrations'; import EditOutgoingWebhook from 'components/integrations/edit_outgoing_webhook/edit_outgoing_webhook'; import {getHistory} from 'utils/browser_history'; import {TestHelper} from 'utils/test_helper'; describe('components/integrations/EditOutgoingWebhook', () => { const team = TestHelper.getTeamMock(); const hook: OutgoingWebhook = { icon_url: '', username: '', id: 'ne8miib4dtde5jmgwqsoiwxpiy', token: 'nbxtx9hkhb8a5q83gw57jzi9cc', create_at: 1504447824673, update_at: 1504447824673, delete_at: 0, creator_id: '88oybd1dwfdoxpkpw1h5kpbyco', channel_id: 'r18hw9hgq3gtiymtpb6epf8qtr', team_id: 'm5gix3oye3du8ghk4ko6h9cq7y', trigger_words: ['trigger', 'trigger2'], trigger_when: 0, callback_urls: ['https://test.com/callback', 'https://test.com/callback2'], display_name: 'name', description: 'description', content_type: 'application/json', }; const updateOutgoingHookRequest = { status: 'not_started', error: null, }; const baseProps = { team, hookId: 'hook_id', updateOutgoingHookRequest, actions: { updateOutgoingHook: jest.fn(), getOutgoingHook: jest.fn(), }, enableOutgoingWebhooks: true, enablePostUsernameOverride: false, enablePostIconOverride: false, }; test('should match snapshot', () => { const props = {...baseProps, hook}; const wrapper = shallow( <EditOutgoingWebhook {...props}/>, ); expect(wrapper).toMatchSnapshot(); }); test('should match snapshot, loading', () => { const wrapper = shallow( <EditOutgoingWebhook {...baseProps}/>, ); expect(wrapper).toMatchSnapshot(); }); test('should match snapshot when EnableOutgoingWebhooks is false', () => { const props = {...baseProps, enableOutgoingWebhooks: false, hook}; const wrapper = shallow( <EditOutgoingWebhook {...props}/>, ); expect(wrapper).toMatchSnapshot(); }); test('should have match state when handleConfirmModal is called', () => { const props = {...baseProps, hook}; const wrapper = shallow<EditOutgoingWebhook>( <EditOutgoingWebhook {...props}/>, ); wrapper.setState({showConfirmModal: false}); wrapper.instance().handleConfirmModal(); expect(wrapper.state('showConfirmModal')).toEqual(true); }); test('should have match state when confirmModalDismissed is called', () => { const props = {...baseProps, hook}; const wrapper = shallow<EditOutgoingWebhook>( <EditOutgoingWebhook {...props}/>, ); wrapper.setState({showConfirmModal: true}); wrapper.instance().confirmModalDismissed(); expect(wrapper.state('showConfirmModal')).toEqual(false); }); test('should have match renderExtra', () => { const props = {...baseProps, hook}; const wrapper = shallow<EditOutgoingWebhook>( <EditOutgoingWebhook {...props}/>, ); expect(wrapper.instance().renderExtra()).toMatchSnapshot(); }); test('should have match when editOutgoingHook is called', () => { const props = {...baseProps, hook}; const wrapper = shallow<EditOutgoingWebhook>( <EditOutgoingWebhook {...props}/>, ); const instance = wrapper.instance(); instance.handleConfirmModal = jest.fn(); instance.submitHook = jest.fn(); wrapper.instance().editOutgoingHook(hook); expect(instance.handleConfirmModal).not.toBeCalled(); expect(instance.submitHook).toBeCalled(); }); test('should have match when submitHook is called on success', async () => { const newActions = { ...baseProps.actions, updateOutgoingHook: jest.fn().mockReturnValue({data: 'data'}), }; const props = {...baseProps, hook, actions: newActions}; const wrapper = shallow<EditOutgoingWebhook>( <EditOutgoingWebhook {...props}/>, ); const instance = wrapper.instance(); wrapper.setState({showConfirmModal: true}); await instance.submitHook(); expect(newActions.updateOutgoingHook).toHaveBeenCalledTimes(1); expect(wrapper.state('serverError')).toEqual(''); expect(getHistory().push).toHaveBeenCalledWith(`/${team.name}/integrations/outgoing_webhooks`); }); test('should have match when submitHook is called on error', async () => { const newActions = { ...baseProps.actions, updateOutgoingHook: jest.fn().mockReturnValue({data: ''}), }; const props = {...baseProps, hook, actions: newActions}; const wrapper = shallow<EditOutgoingWebhook>( <EditOutgoingWebhook {...props}/>, ); const instance = wrapper.instance(); wrapper.setState({showConfirmModal: true}); await instance.submitHook(); expect(wrapper.state('showConfirmModal')).toEqual(false); }); });
2,434
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/edit_outgoing_webhook
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/edit_outgoing_webhook/__snapshots__/edit_outgoing_webhook.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/integrations/EditOutgoingWebhook should have match renderExtra 1`] = ` <ConfirmModal confirmButtonClass="btn btn-primary" confirmButtonText={ <Memo(MemoizedFormattedMessage) defaultMessage="Update" id="update_outgoing_webhook.update" /> } message={ <Memo(MemoizedFormattedMessage) defaultMessage="Your changes may break the existing outgoing webhook. Are you sure you would like to update it?" id="update_outgoing_webhook.question" /> } modalClass="" onCancel={[Function]} onConfirm={[Function]} show={false} title={ <Memo(MemoizedFormattedMessage) defaultMessage="Edit Outgoing Webhook" id="update_outgoing_webhook.confirm" /> } /> `; exports[`components/integrations/EditOutgoingWebhook should match snapshot 1`] = ` <AbstractOutgoingWebhook action={[Function]} enablePostIconOverride={false} enablePostUsernameOverride={false} footer={ Object { "defaultMessage": "Update", "id": "update_outgoing_webhook.update", } } header={ Object { "defaultMessage": "Edit", "id": "integrations.edit", } } initialHook={ Object { "callback_urls": Array [ "https://test.com/callback", "https://test.com/callback2", ], "channel_id": "r18hw9hgq3gtiymtpb6epf8qtr", "content_type": "application/json", "create_at": 1504447824673, "creator_id": "88oybd1dwfdoxpkpw1h5kpbyco", "delete_at": 0, "description": "description", "display_name": "name", "icon_url": "", "id": "ne8miib4dtde5jmgwqsoiwxpiy", "team_id": "m5gix3oye3du8ghk4ko6h9cq7y", "token": "nbxtx9hkhb8a5q83gw57jzi9cc", "trigger_when": 0, "trigger_words": Array [ "trigger", "trigger2", ], "update_at": 1504447824673, "username": "", } } loading={ Object { "defaultMessage": "Updating...", "id": "update_outgoing_webhook.updating", } } renderExtra={ <ConfirmModal confirmButtonClass="btn btn-primary" confirmButtonText={ <Memo(MemoizedFormattedMessage) defaultMessage="Update" id="update_outgoing_webhook.update" /> } message={ <Memo(MemoizedFormattedMessage) defaultMessage="Your changes may break the existing outgoing webhook. Are you sure you would like to update it?" id="update_outgoing_webhook.question" /> } modalClass="" onCancel={[Function]} onConfirm={[Function]} show={false} title={ <Memo(MemoizedFormattedMessage) defaultMessage="Edit Outgoing Webhook" id="update_outgoing_webhook.confirm" /> } /> } serverError="" team={ Object { "allow_open_invite": false, "allowed_domains": "", "company_name": "", "create_at": 0, "delete_at": 0, "description": "", "display_name": "name", "email": "", "group_constrained": false, "id": "team_id", "invite_id": "", "name": "DN", "scheme_id": "id", "type": "O", "update_at": 0, } } /> `; exports[`components/integrations/EditOutgoingWebhook should match snapshot when EnableOutgoingWebhooks is false 1`] = ` <AbstractOutgoingWebhook action={[Function]} enablePostIconOverride={false} enablePostUsernameOverride={false} footer={ Object { "defaultMessage": "Update", "id": "update_outgoing_webhook.update", } } header={ Object { "defaultMessage": "Edit", "id": "integrations.edit", } } initialHook={ Object { "callback_urls": Array [ "https://test.com/callback", "https://test.com/callback2", ], "channel_id": "r18hw9hgq3gtiymtpb6epf8qtr", "content_type": "application/json", "create_at": 1504447824673, "creator_id": "88oybd1dwfdoxpkpw1h5kpbyco", "delete_at": 0, "description": "description", "display_name": "name", "icon_url": "", "id": "ne8miib4dtde5jmgwqsoiwxpiy", "team_id": "m5gix3oye3du8ghk4ko6h9cq7y", "token": "nbxtx9hkhb8a5q83gw57jzi9cc", "trigger_when": 0, "trigger_words": Array [ "trigger", "trigger2", ], "update_at": 1504447824673, "username": "", } } loading={ Object { "defaultMessage": "Updating...", "id": "update_outgoing_webhook.updating", } } renderExtra={ <ConfirmModal confirmButtonClass="btn btn-primary" confirmButtonText={ <Memo(MemoizedFormattedMessage) defaultMessage="Update" id="update_outgoing_webhook.update" /> } message={ <Memo(MemoizedFormattedMessage) defaultMessage="Your changes may break the existing outgoing webhook. Are you sure you would like to update it?" id="update_outgoing_webhook.question" /> } modalClass="" onCancel={[Function]} onConfirm={[Function]} show={false} title={ <Memo(MemoizedFormattedMessage) defaultMessage="Edit Outgoing Webhook" id="update_outgoing_webhook.confirm" /> } /> } serverError="" team={ Object { "allow_open_invite": false, "allowed_domains": "", "company_name": "", "create_at": 0, "delete_at": 0, "description": "", "display_name": "name", "email": "", "group_constrained": false, "id": "team_id", "invite_id": "", "name": "DN", "scheme_id": "id", "type": "O", "update_at": 0, } } /> `; exports[`components/integrations/EditOutgoingWebhook should match snapshot, loading 1`] = `<LoadingScreen />`;
2,440
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/installed_oauth_app/installed_oauth_app.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import DeleteIntegrationLink from 'components/integrations/delete_integration_link'; import InstalledOAuthApp from 'components/integrations/installed_oauth_app/installed_oauth_app'; describe('components/integrations/InstalledOAuthApp', () => { const FAKE_SECRET = '***************'; const team = {name: 'team_name'}; const oauthApp = { id: 'facxd9wpzpbpfp8pad78xj75pr', name: 'testApp', client_secret: '88cxd9wpzpbpfp8pad78xj75pr', create_at: 1501365458934, creator_id: '88oybd1dwfdoxpkpw1h5kpbyco', description: 'testing', homepage: 'https://test.com', icon_url: 'https://test.com/icon', is_trusted: true, update_at: 1501365458934, callback_urls: ['https://test.com/callback', 'https://test.com/callback2'], }; const regenOAuthAppSecretRequest = { status: 'not_started', error: null, }; const baseProps = { team, oauthApp, creatorName: 'somename', regenOAuthAppSecretRequest, onRegenerateSecret: jest.fn(), onDelete: jest.fn(), filter: '', fromApp: false, }; test('should match snapshot', () => { const props = {...baseProps, team}; const wrapper = shallow( <InstalledOAuthApp {...props}/>, ); expect(wrapper).toMatchSnapshot(); }); test('should match snapshot from app', () => { const props = {...baseProps, team, fromApp: true}; const wrapper = shallow( <InstalledOAuthApp {...props}/>, ); expect(wrapper).toMatchSnapshot(); }); test('should match snapshot, when oauthApp is without name and not trusted', () => { const props = {...baseProps, team}; props.oauthApp.name = ''; props.oauthApp.is_trusted = false; const wrapper = shallow( <InstalledOAuthApp {...props}/>, ); expect(wrapper).toMatchSnapshot(); }); test('should match snapshot, on error', () => { const props = {...baseProps, team}; const wrapper = shallow( <InstalledOAuthApp {...props}/>, ); wrapper.setState({error: 'error'}); expect(wrapper).toMatchSnapshot(); }); test('should call onRegenerateSecret function', () => { const props = { ...baseProps, team, }; baseProps.onRegenerateSecret.mockResolvedValue({}); const wrapper = shallow( <InstalledOAuthApp {...props}/>, ); wrapper.find('#regenerateSecretButton').simulate('click', {preventDefault: jest.fn()}); expect(baseProps.onRegenerateSecret).toBeCalled(); expect(baseProps.onRegenerateSecret).toHaveBeenCalledWith(oauthApp.id); }); test('should filter out OAuthApp', () => { const filter = 'filter'; const props = {...baseProps, filter}; const wrapper = shallow( <InstalledOAuthApp {...props}/>, ); expect(wrapper).toMatchSnapshot(); }); test('should match state on button clicks, both showSecretButton and hideSecretButton', () => { const props = {...baseProps, team}; const wrapper = shallow( <InstalledOAuthApp {...props}/>, ); expect(wrapper.find('#showSecretButton').exists()).toBe(true); expect(wrapper.find('#hideSecretButton').exists()).toBe(false); wrapper.find('#showSecretButton').simulate('click', {preventDefault: jest.fn()}); expect(wrapper.state('clientSecret')).toEqual(oauthApp.client_secret); expect(wrapper.find('#showSecretButton').exists()).toBe(false); expect(wrapper.find('#hideSecretButton').exists()).toBe(true); wrapper.find('#hideSecretButton').simulate('click', {preventDefault: jest.fn()}); expect(wrapper.state('clientSecret')).toEqual(FAKE_SECRET); expect(wrapper.find('#showSecretButton').exists()).toBe(true); expect(wrapper.find('#hideSecretButton').exists()).toBe(false); }); test('should match on handleRegenerate', () => { const props = { ...baseProps, team, }; baseProps.onRegenerateSecret.mockResolvedValue({}); const wrapper = shallow( <InstalledOAuthApp {...props}/>, ); expect(wrapper.find('#regenerateSecretButton').exists()).toBe(true); wrapper.find('#regenerateSecretButton').simulate('click', {preventDefault: jest.fn()}); expect(baseProps.onRegenerateSecret).toBeCalled(); expect(baseProps.onRegenerateSecret).toHaveBeenCalledWith(oauthApp.id); }); test('should have called props.onDelete on handleDelete ', () => { const newOnDelete = jest.fn(); const props = {...baseProps, team, onDelete: newOnDelete}; const wrapper = shallow( <InstalledOAuthApp {...props}/>, ); expect(wrapper.find(DeleteIntegrationLink).exists()).toBe(true); wrapper.find(DeleteIntegrationLink).props().onDelete(); expect(newOnDelete).toBeCalled(); expect(newOnDelete).toHaveBeenCalledWith(oauthApp); }); });
2,442
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/installed_oauth_app
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/installed_oauth_app/__snapshots__/installed_oauth_app.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/integrations/InstalledOAuthApp should filter out OAuthApp 1`] = `""`; exports[`components/integrations/InstalledOAuthApp should match snapshot 1`] = ` <div className="backstage-list__item" > <div className="integration__icon integration-list__icon" > <img alt="get app screenshot" src="https://test.com/icon" /> </div> <div className="item-details" > <div className="item-details__row d-flex flex-column flex-md-row justify-content-between" > <strong className="item-details__name" > testApp </strong> <div className="item-actions" > <button className="style--none color--link" id="showSecretButton" onClick={[Function]} > <MemoizedFormattedMessage defaultMessage="Show Secret" id="installed_integrations.showSecret" /> </button> - <button className="style--none color--link" id="regenerateSecretButton" onClick={[Function]} > <MemoizedFormattedMessage defaultMessage="Regenerate Secret" id="installed_integrations.regenSecret" /> </button> - <Link to="/team_name/integrations/oauth2-apps/edit?id=facxd9wpzpbpfp8pad78xj75pr" > <MemoizedFormattedMessage defaultMessage="Edit" id="installed_integrations.edit" /> </Link> - <Connect(DeleteIntegrationLink) modalMessage={ <Memo(MemoizedFormattedMessage) defaultMessage="This action permanently deletes the OAuth 2.0 application and breaks any integrations using it. Are you sure you want to delete it?" id="installed_oauth_apps.delete.confirm" /> } onDelete={[Function]} /> </div> </div> <div className="item-details__row" > <span className="item-details__description" > testing </span> </div> <div className="item-details__row" > <span className="item-details__url word-break--all" > <FormattedMarkdownMessage defaultMessage="Is Trusted: **{isTrusted}**" id="installed_oauth_apps.is_trusted" values={ Object { "isTrusted": "Yes", } } /> </span> </div> <div className="item-details__row" > <span className="item-details__token" > <FormattedMarkdownMessage defaultMessage="Client ID: **{clientId}**" id="installed_integrations.client_id" values={ Object { "clientId": "facxd9wpzpbpfp8pad78xj75pr", } } /> <Memo(CopyText) defaultMessage="Copy Client Id" idMessage="integrations.copy_client_id" value="facxd9wpzpbpfp8pad78xj75pr" /> </span> </div> <div className="item-details__row" > <span className="item-details__token" > <MemoizedFormattedMessage defaultMessage="Client Secret: **{clientSecret}**" id="installed_integrations.client_secret" values={ Object { "clientSecret": "***************", } } /> </span> </div> <div className="item-details__row" > <span className="item-details__url word-break--all" > <MemoizedFormattedMessage defaultMessage="Callback URLs: {urls}" id="installed_integrations.callback_urls" values={ Object { "urls": "https://test.com/callback, https://test.com/callback2", } } /> </span> </div> <div className="item-details__row" > <span className="item-details__creation" > <MemoizedFormattedMessage defaultMessage="Created by {creator} on {createAt, date, full}" id="installed_integrations.creation" values={ Object { "createAt": 1501365458934, "creator": "somename", } } /> </span> </div> </div> </div> `; exports[`components/integrations/InstalledOAuthApp should match snapshot from app 1`] = ` <div className="backstage-list__item" > <div className="integration__icon integration-list__icon" > <img alt="get app screenshot" src="https://test.com/icon" /> </div> <div className="item-details" > <div className="item-details__row d-flex flex-column flex-md-row justify-content-between" > <strong className="item-details__name" > testApp </strong> </div> <div className="item-details__row" > <span className="item-details__description" > testing </span> </div> <div className="item-details__row" > <span className="item-details__creation" > <MemoizedFormattedMessage defaultMessage="Managed by Apps Framework" id="installed_integrations.fromApp" /> </span> </div> </div> </div> `; exports[`components/integrations/InstalledOAuthApp should match snapshot, on error 1`] = ` <div className="backstage-list__item" > <div className="integration__icon integration-list__icon" > <img alt="get app screenshot" src="https://test.com/icon" /> </div> <div className="item-details" > <div className="item-details__row d-flex flex-column flex-md-row justify-content-between" > <strong className="item-details__name" > <MemoizedFormattedMessage defaultMessage="Unnamed OAuth 2.0 Application" id="installed_integrations.unnamed_oauth_app" /> </strong> <div className="item-actions" > <button className="style--none color--link" id="showSecretButton" onClick={[Function]} > <MemoizedFormattedMessage defaultMessage="Show Secret" id="installed_integrations.showSecret" /> </button> - <button className="style--none color--link" id="regenerateSecretButton" onClick={[Function]} > <MemoizedFormattedMessage defaultMessage="Regenerate Secret" id="installed_integrations.regenSecret" /> </button> - <Link to="/team_name/integrations/oauth2-apps/edit?id=facxd9wpzpbpfp8pad78xj75pr" > <MemoizedFormattedMessage defaultMessage="Edit" id="installed_integrations.edit" /> </Link> - <Connect(DeleteIntegrationLink) modalMessage={ <Memo(MemoizedFormattedMessage) defaultMessage="This action permanently deletes the OAuth 2.0 application and breaks any integrations using it. Are you sure you want to delete it?" id="installed_oauth_apps.delete.confirm" /> } onDelete={[Function]} /> </div> </div> <FormError error="error" errors={Array []} /> <div className="item-details__row" > <span className="item-details__description" > testing </span> </div> <div className="item-details__row" > <span className="item-details__url word-break--all" > <FormattedMarkdownMessage defaultMessage="Is Trusted: **{isTrusted}**" id="installed_oauth_apps.is_trusted" values={ Object { "isTrusted": "No", } } /> </span> </div> <div className="item-details__row" > <span className="item-details__token" > <FormattedMarkdownMessage defaultMessage="Client ID: **{clientId}**" id="installed_integrations.client_id" values={ Object { "clientId": "facxd9wpzpbpfp8pad78xj75pr", } } /> <Memo(CopyText) defaultMessage="Copy Client Id" idMessage="integrations.copy_client_id" value="facxd9wpzpbpfp8pad78xj75pr" /> </span> </div> <div className="item-details__row" > <span className="item-details__token" > <MemoizedFormattedMessage defaultMessage="Client Secret: **{clientSecret}**" id="installed_integrations.client_secret" values={ Object { "clientSecret": "***************", } } /> </span> </div> <div className="item-details__row" > <span className="item-details__url word-break--all" > <MemoizedFormattedMessage defaultMessage="Callback URLs: {urls}" id="installed_integrations.callback_urls" values={ Object { "urls": "https://test.com/callback, https://test.com/callback2", } } /> </span> </div> <div className="item-details__row" > <span className="item-details__creation" > <MemoizedFormattedMessage defaultMessage="Created by {creator} on {createAt, date, full}" id="installed_integrations.creation" values={ Object { "createAt": 1501365458934, "creator": "somename", } } /> </span> </div> </div> </div> `; exports[`components/integrations/InstalledOAuthApp should match snapshot, when oauthApp is without name and not trusted 1`] = ` <div className="backstage-list__item" > <div className="integration__icon integration-list__icon" > <img alt="get app screenshot" src="https://test.com/icon" /> </div> <div className="item-details" > <div className="item-details__row d-flex flex-column flex-md-row justify-content-between" > <strong className="item-details__name" > <MemoizedFormattedMessage defaultMessage="Unnamed OAuth 2.0 Application" id="installed_integrations.unnamed_oauth_app" /> </strong> <div className="item-actions" > <button className="style--none color--link" id="showSecretButton" onClick={[Function]} > <MemoizedFormattedMessage defaultMessage="Show Secret" id="installed_integrations.showSecret" /> </button> - <button className="style--none color--link" id="regenerateSecretButton" onClick={[Function]} > <MemoizedFormattedMessage defaultMessage="Regenerate Secret" id="installed_integrations.regenSecret" /> </button> - <Link to="/team_name/integrations/oauth2-apps/edit?id=facxd9wpzpbpfp8pad78xj75pr" > <MemoizedFormattedMessage defaultMessage="Edit" id="installed_integrations.edit" /> </Link> - <Connect(DeleteIntegrationLink) modalMessage={ <Memo(MemoizedFormattedMessage) defaultMessage="This action permanently deletes the OAuth 2.0 application and breaks any integrations using it. Are you sure you want to delete it?" id="installed_oauth_apps.delete.confirm" /> } onDelete={[Function]} /> </div> </div> <div className="item-details__row" > <span className="item-details__description" > testing </span> </div> <div className="item-details__row" > <span className="item-details__url word-break--all" > <FormattedMarkdownMessage defaultMessage="Is Trusted: **{isTrusted}**" id="installed_oauth_apps.is_trusted" values={ Object { "isTrusted": "No", } } /> </span> </div> <div className="item-details__row" > <span className="item-details__token" > <FormattedMarkdownMessage defaultMessage="Client ID: **{clientId}**" id="installed_integrations.client_id" values={ Object { "clientId": "facxd9wpzpbpfp8pad78xj75pr", } } /> <Memo(CopyText) defaultMessage="Copy Client Id" idMessage="integrations.copy_client_id" value="facxd9wpzpbpfp8pad78xj75pr" /> </span> </div> <div className="item-details__row" > <span className="item-details__token" > <MemoizedFormattedMessage defaultMessage="Client Secret: **{clientSecret}**" id="installed_integrations.client_secret" values={ Object { "clientSecret": "***************", } } /> </span> </div> <div className="item-details__row" > <span className="item-details__url word-break--all" > <MemoizedFormattedMessage defaultMessage="Callback URLs: {urls}" id="installed_integrations.callback_urls" values={ Object { "urls": "https://test.com/callback, https://test.com/callback2", } } /> </span> </div> <div className="item-details__row" > <span className="item-details__creation" > <MemoizedFormattedMessage defaultMessage="Created by {creator} on {createAt, date, full}" id="installed_integrations.creation" values={ Object { "createAt": 1501365458934, "creator": "somename", } } /> </span> </div> </div> </div> `;
2,444
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/installed_oauth_apps/installed_oauth_apps.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import BackstageList from 'components/backstage/components/backstage_list'; import InstalledOAuthApps from 'components/integrations/installed_oauth_apps/installed_oauth_apps'; describe('components/integrations/InstalledOAuthApps', () => { const oauthApps = { facxd9wpzpbpfp8pad78xj75pr: { id: 'facxd9wpzpbpfp8pad78xj75pr', name: 'firstApp', client_secret: '88cxd9wpzpbpfp8pad78xj75pr', create_at: 1501365458934, creator_id: '88oybd1dwfdoxpkpw1h5kpbyco', description: 'testing', homepage: 'https://test.com', icon_url: 'https://test.com/icon', is_trusted: false, update_at: 1501365458934, callback_urls: ['https://test.com/callback'], }, fzcxd9wpzpbpfp8pad78xj75pr: { id: 'fzcxd9wpzpbpfp8pad78xj75pr', name: 'secondApp', client_secret: 'decxd9wpzpbpfp8pad78xj75pr', create_at: 1501365459984, creator_id: '88oybd2dwfdoxpkpw1h5kpbyco', description: 'testing2', homepage: 'https://test2.com', icon_url: 'https://test2.com/icon', is_trusted: true, update_at: 1501365479988, callback_urls: ['https://test2.com/callback', 'https://test2.com/callback2'], }, }; const baseProps = { team: { name: 'test', }, oauthApps, canManageOauth: true, actions: { loadOAuthAppsAndProfiles: jest.fn(), regenOAuthAppSecret: jest.fn(), deleteOAuthApp: jest.fn(), }, enableOAuthServiceProvider: true, appsOAuthAppIDs: [], }; test('should match snapshot', () => { const newGetOAuthApps = jest.fn().mockImplementation( () => { return new Promise((resolve) => { process.nextTick(() => resolve({})); }); }, ); const props = {...baseProps}; props.actions.loadOAuthAppsAndProfiles = newGetOAuthApps; const wrapper = shallow<InstalledOAuthApps>(<InstalledOAuthApps {...props}/>); expect(wrapper).toMatchSnapshot(); expect(shallow(<div>{wrapper.instance().oauthApps('first')}</div>)).toMatchSnapshot(); // successful filter expect(shallow(<div>{wrapper.instance().oauthApps('ZZZ')}</div>)).toMatchSnapshot(); // unsuccessful filter expect(shallow(<div>{wrapper.instance().oauthApps()}</div>).find('Connect(InstalledOAuthApp)').length).toBe(2); // no filter, should return all expect(wrapper.find(BackstageList).props().addLink).toEqual('/test/integrations/oauth2-apps/add'); expect(wrapper.find(BackstageList).props().addText).toEqual('Add OAuth 2.0 Application'); wrapper.setProps({canManageOauth: false}); expect(wrapper.find(BackstageList).props().addLink).toBeFalsy(); expect(wrapper.find(BackstageList).props().addText).toBeFalsy(); }); test('should match snapshot for Apps', () => { const newGetOAuthApps = jest.fn().mockImplementation( () => { return new Promise((resolve) => { process.nextTick(() => resolve({})); }); }, ); const props = { ...baseProps, appsOAuthAppIDs: ['fzcxd9wpzpbpfp8pad78xj75pr'], }; props.actions.loadOAuthAppsAndProfiles = newGetOAuthApps; const wrapper = shallow<InstalledOAuthApps>(<InstalledOAuthApps {...props}/>); expect(shallow(<div>{wrapper.instance().oauthApps('second')}</div>)).toMatchSnapshot(); // successful filter }); test('should props.deleteOAuthApp on deleteOAuthApp', () => { const newDeleteOAuthApp = jest.fn(); const props = {...baseProps}; props.actions.deleteOAuthApp = newDeleteOAuthApp; const wrapper = shallow<InstalledOAuthApps>( <InstalledOAuthApps {...props}/>, ); wrapper.instance().deleteOAuthApp(oauthApps.facxd9wpzpbpfp8pad78xj75pr); expect(newDeleteOAuthApp).toHaveBeenCalled(); expect(newDeleteOAuthApp).toHaveBeenCalledWith(oauthApps.facxd9wpzpbpfp8pad78xj75pr.id); }); });
2,446
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/installed_oauth_apps
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/installed_oauth_apps/__snapshots__/installed_oauth_apps.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/integrations/InstalledOAuthApps should match snapshot 1`] = ` <BackstageList addButtonId="addOauthApp" addLink="/test/integrations/oauth2-apps/add" addText="Add OAuth 2.0 Application" emptyText={ <Memo(MemoizedFormattedMessage) defaultMessage="No OAuth 2.0 Applications found" id="installed_oauth_apps.empty" /> } emptyTextSearch={ <FormattedMarkdownMessage defaultMessage="No OAuth 2.0 Applications match {searchTerm}" id="installed_oauth_apps.emptySearch" /> } header={ <Memo(MemoizedFormattedMessage) defaultMessage="OAuth 2.0 Applications" id="installed_oauth2_apps.header" /> } helpText={ <Memo(MemoizedFormattedMessage) defaultMessage="Create {oauthApplications} to securely integrate bots and third-party apps with Mattermost. Visit the {appDirectory} to find available self-hosted apps." id="installed_oauth_apps.help" values={ Object { "appDirectory": <ExternalLink href="https://mattermost.com/marketplace/" location="installed_oauth_apps" > <Memo(MemoizedFormattedMessage) defaultMessage="App Directory" id="installed_oauth_apps.help.appDirectory" /> </ExternalLink>, "oauthApplications": <ExternalLink href="https://mattermost.com/pl/setup-oauth-2.0" location="installed_oauth_apps" > <Memo(MemoizedFormattedMessage) defaultMessage="OAuth 2.0 applications" id="installed_oauth_apps.help.oauthApplications" /> </ExternalLink>, } } /> } loading={true} searchPlaceholder="Search OAuth 2.0 Applications" > <Component /> </BackstageList> `; exports[`components/integrations/InstalledOAuthApps should match snapshot 2`] = ` <div> <Connect(InstalledOAuthApp) creatorName="" fromApp={false} key="facxd9wpzpbpfp8pad78xj75pr" oauthApp={ Object { "callback_urls": Array [ "https://test.com/callback", ], "client_secret": "88cxd9wpzpbpfp8pad78xj75pr", "create_at": 1501365458934, "creator_id": "88oybd1dwfdoxpkpw1h5kpbyco", "description": "testing", "homepage": "https://test.com", "icon_url": "https://test.com/icon", "id": "facxd9wpzpbpfp8pad78xj75pr", "is_trusted": false, "name": "firstApp", "update_at": 1501365458934, } } onDelete={[Function]} onRegenerateSecret={[MockFunction]} team={ Object { "name": "test", } } /> </div> `; exports[`components/integrations/InstalledOAuthApps should match snapshot 3`] = `<div />`; exports[`components/integrations/InstalledOAuthApps should match snapshot for Apps 1`] = ` <div> <Connect(InstalledOAuthApp) creatorName="" fromApp={true} key="fzcxd9wpzpbpfp8pad78xj75pr" oauthApp={ Object { "callback_urls": Array [ "https://test2.com/callback", "https://test2.com/callback2", ], "client_secret": "decxd9wpzpbpfp8pad78xj75pr", "create_at": 1501365459984, "creator_id": "88oybd2dwfdoxpkpw1h5kpbyco", "description": "testing2", "homepage": "https://test2.com", "icon_url": "https://test2.com/icon", "id": "fzcxd9wpzpbpfp8pad78xj75pr", "is_trusted": true, "name": "secondApp", "update_at": 1501365479988, } } onDelete={[Function]} onRegenerateSecret={[MockFunction]} team={ Object { "name": "test", } } /> </div> `;
2,448
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/installed_outgoing_webhooks/installed_outgoing_webhooks.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import type {ComponentProps} from 'react'; import type {OutgoingWebhook} from '@mattermost/types/integrations'; import InstalledOutgoingWebhooks from 'components/integrations/installed_outgoing_webhooks/installed_outgoing_webhooks'; import {TestHelper} from 'utils/test_helper'; describe('components/integrations/InstalledOutgoingWebhooks', () => { const teamId = 'testteamid'; const team = TestHelper.getTeamMock({ id: teamId, name: 'test', }); const user = TestHelper.getUserMock({ first_name: 'sudheer', id: 'zaktnt8bpbgu8mb6ez9k64r7sa', roles: 'system_admin system_user', username: 'sudheerdev', }); const channel = TestHelper.getChannelMock({ id: 'mdpzfpfcxi85zkkqkzkch4b85h', name: 'town-square', display_name: 'town-square', }); const outgoingWebhooks = [ { callback_urls: ['http://adsfdasd.com'], channel_id: 'mdpzfpfcxi85zkkqkzkch4b85h', content_type: 'application/x-www-form-urlencoded', create_at: 1508327769020, creator_id: 'zaktnt8bpbgu8mb6ez9k64r7sa', delete_at: 0, description: 'build status', display_name: '', id: '7h88x419ubbyuxzs7dfwtgkfgr', team_id: 'eatxocwc3bg9ffo9xyybnj4omr', token: 'xoxz1z7c3tgi9xhrfudn638q9r', trigger_when: 0, trigger_words: ['build'], 0: 'asdf', update_at: 1508329149618, } as unknown as OutgoingWebhook, { callback_urls: ['http://adsfdasd.com'], channel_id: 'mdpzfpfcxi85zkkqkzkch4b85h', content_type: 'application/x-www-form-urlencoded', create_at: 1508327769020, creator_id: 'zaktnt8bpbgu8mb6ez9k64r7sa', delete_at: 0, description: 'test', display_name: '', id: '7h88x419ubbyuxzs7dfwtgkffr', team_id: 'eatxocwc3bg9ffo9xyybnj4omr', token: 'xoxz1z7c3tgi9xhrfudn638q9r', trigger_when: 0, trigger_words: ['test'], 0: 'asdf', update_at: 1508329149618, } as unknown as OutgoingWebhook, ]; const defaultProps: ComponentProps<typeof InstalledOutgoingWebhooks> = { outgoingWebhooks, teamId, team, user, users: {zaktnt8bpbgu8mb6ez9k64r7sa: user}, channels: {mdpzfpfcxi85zkkqkzkch4b85h: channel}, actions: { removeOutgoingHook: jest.fn(), loadOutgoingHooksAndProfilesForTeam: jest.fn().mockReturnValue(Promise.resolve()), regenOutgoingHookToken: jest.fn(), }, enableOutgoingWebhooks: true, canManageOthersWebhooks: true, }; test('should match snapshot', () => { const wrapper = shallow<InstalledOutgoingWebhooks>( <InstalledOutgoingWebhooks {...defaultProps} />, ); expect(shallow(<div>{wrapper.instance().outgoingWebhooks('town')}</div>)).toMatchSnapshot(); expect(shallow(<div>{wrapper.instance().outgoingWebhooks('ZZZ')}</div>)).toMatchSnapshot(); expect(wrapper).toMatchSnapshot(); }); test('should call regenOutgoingHookToken function', () => { const wrapper = shallow<InstalledOutgoingWebhooks>( <InstalledOutgoingWebhooks {...defaultProps} />, ); wrapper.instance().regenOutgoingWebhookToken(outgoingWebhooks[0]); expect(defaultProps.actions.regenOutgoingHookToken).toHaveBeenCalledTimes(1); expect(defaultProps.actions.regenOutgoingHookToken).toHaveBeenCalledWith(outgoingWebhooks[0].id); }); test('should call removeOutgoingHook function', () => { const wrapper = shallow<InstalledOutgoingWebhooks>( <InstalledOutgoingWebhooks {...defaultProps} />, ); wrapper.instance().removeOutgoingHook(outgoingWebhooks[1]); expect(defaultProps.actions.removeOutgoingHook).toHaveBeenCalledTimes(1); expect(defaultProps.actions.removeOutgoingHook).toHaveBeenCalledWith(outgoingWebhooks[1].id); expect(defaultProps.actions.removeOutgoingHook).toHaveBeenCalled(); }); });
2,450
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/installed_outgoing_webhooks
petrpan-code/mattermost/mattermost/webapp/channels/src/components/integrations/installed_outgoing_webhooks/__snapshots__/installed_outgoing_webhooks.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/integrations/InstalledOutgoingWebhooks should match snapshot 1`] = ` <div> <InstalledOutgoingWebhook canChange={true} channel={ Object { "create_at": 0, "creator_id": "id", "delete_at": 0, "display_name": "town-square", "group_constrained": false, "header": "header", "id": "mdpzfpfcxi85zkkqkzkch4b85h", "last_post_at": 0, "last_root_post_at": 0, "name": "town-square", "purpose": "purpose", "scheme_id": "id", "team_id": "team_id", "type": "O", "update_at": 0, } } creator={ Object { "auth_service": "", "bot_description": "", "create_at": 0, "delete_at": 0, "email": "", "first_name": "sudheer", "id": "zaktnt8bpbgu8mb6ez9k64r7sa", "is_bot": false, "last_activity_at": 0, "last_name": "", "last_password_update": 0, "last_picture_update": 0, "locale": "", "mfa_active": false, "nickname": "", "notify_props": Object { "calls_desktop_sound": "true", "channel": "false", "comments": "never", "desktop": "default", "desktop_sound": "false", "email": "false", "first_name": "false", "highlight_keys": "", "mark_unread": "mention", "mention_keys": "", "push": "none", "push_status": "offline", }, "password": "", "position": "", "props": Object {}, "roles": "system_admin system_user", "terms_of_service_create_at": 0, "terms_of_service_id": "", "update_at": 0, "username": "sudheerdev", } } key="7h88x419ubbyuxzs7dfwtgkfgr" onDelete={[Function]} onRegenToken={[Function]} outgoingWebhook={ Object { "0": "asdf", "callback_urls": Array [ "http://adsfdasd.com", ], "channel_id": "mdpzfpfcxi85zkkqkzkch4b85h", "content_type": "application/x-www-form-urlencoded", "create_at": 1508327769020, "creator_id": "zaktnt8bpbgu8mb6ez9k64r7sa", "delete_at": 0, "description": "build status", "display_name": "", "id": "7h88x419ubbyuxzs7dfwtgkfgr", "team_id": "eatxocwc3bg9ffo9xyybnj4omr", "token": "xoxz1z7c3tgi9xhrfudn638q9r", "trigger_when": 0, "trigger_words": Array [ "build", ], "update_at": 1508329149618, } } team={ Object { "allow_open_invite": false, "allowed_domains": "", "company_name": "", "create_at": 0, "delete_at": 0, "description": "", "display_name": "name", "email": "", "group_constrained": false, "id": "testteamid", "invite_id": "", "name": "test", "scheme_id": "id", "type": "O", "update_at": 0, } } /> <InstalledOutgoingWebhook canChange={true} channel={ Object { "create_at": 0, "creator_id": "id", "delete_at": 0, "display_name": "town-square", "group_constrained": false, "header": "header", "id": "mdpzfpfcxi85zkkqkzkch4b85h", "last_post_at": 0, "last_root_post_at": 0, "name": "town-square", "purpose": "purpose", "scheme_id": "id", "team_id": "team_id", "type": "O", "update_at": 0, } } creator={ Object { "auth_service": "", "bot_description": "", "create_at": 0, "delete_at": 0, "email": "", "first_name": "sudheer", "id": "zaktnt8bpbgu8mb6ez9k64r7sa", "is_bot": false, "last_activity_at": 0, "last_name": "", "last_password_update": 0, "last_picture_update": 0, "locale": "", "mfa_active": false, "nickname": "", "notify_props": Object { "calls_desktop_sound": "true", "channel": "false", "comments": "never", "desktop": "default", "desktop_sound": "false", "email": "false", "first_name": "false", "highlight_keys": "", "mark_unread": "mention", "mention_keys": "", "push": "none", "push_status": "offline", }, "password": "", "position": "", "props": Object {}, "roles": "system_admin system_user", "terms_of_service_create_at": 0, "terms_of_service_id": "", "update_at": 0, "username": "sudheerdev", } } key="7h88x419ubbyuxzs7dfwtgkffr" onDelete={[Function]} onRegenToken={[Function]} outgoingWebhook={ Object { "0": "asdf", "callback_urls": Array [ "http://adsfdasd.com", ], "channel_id": "mdpzfpfcxi85zkkqkzkch4b85h", "content_type": "application/x-www-form-urlencoded", "create_at": 1508327769020, "creator_id": "zaktnt8bpbgu8mb6ez9k64r7sa", "delete_at": 0, "description": "test", "display_name": "", "id": "7h88x419ubbyuxzs7dfwtgkffr", "team_id": "eatxocwc3bg9ffo9xyybnj4omr", "token": "xoxz1z7c3tgi9xhrfudn638q9r", "trigger_when": 0, "trigger_words": Array [ "test", ], "update_at": 1508329149618, } } team={ Object { "allow_open_invite": false, "allowed_domains": "", "company_name": "", "create_at": 0, "delete_at": 0, "description": "", "display_name": "name", "email": "", "group_constrained": false, "id": "testteamid", "invite_id": "", "name": "test", "scheme_id": "id", "type": "O", "update_at": 0, } } /> </div> `; exports[`components/integrations/InstalledOutgoingWebhooks should match snapshot 2`] = `<div />`; exports[`components/integrations/InstalledOutgoingWebhooks should match snapshot 3`] = ` <BackstageList addButtonId="addOutgoingWebhook" addLink="/test/integrations/outgoing_webhooks/add" addText={ <Memo(MemoizedFormattedMessage) defaultMessage="Add Outgoing Webhook" id="installed_outgoing_webhooks.add" /> } emptyText={ <Memo(MemoizedFormattedMessage) defaultMessage="No outgoing webhooks found" id="installed_outgoing_webhooks.empty" /> } emptyTextSearch={ <FormattedMarkdownMessage defaultMessage="No outgoing webhooks match {searchTerm}" id="installed_outgoing_webhooks.emptySearch" /> } header={ <Memo(MemoizedFormattedMessage) defaultMessage="Installed Outgoing Webhooks" id="installed_outgoing_webhooks.header" /> } helpText={ <Memo(MemoizedFormattedMessage) defaultMessage="Use outgoing webhooks to connect external tools to Mattermost. {buildYourOwn} or visit the {appDirectory} to find self-hosted, third-party apps and integrations." id="installed_outgoing_webhooks.help" values={ Object { "appDirectory": <ExternalLink href="https://mattermost.com/marketplace" location="installed_outgoing_webhooks" > <Memo(MemoizedFormattedMessage) defaultMessage="App Directory" id="installed_outgoing_webhooks.help.appDirectory" /> </ExternalLink>, "buildYourOwn": <ExternalLink href="https://mattermost.com/pl/setup-outgoing-webhooks" location="installed_outgoing_webhooks" > <Memo(MemoizedFormattedMessage) defaultMessage="Build your own" id="installed_outgoing_webhooks.help.buildYourOwn" /> </ExternalLink>, } } /> } loading={true} searchPlaceholder="Search Outgoing Webhooks" > <Component /> </BackstageList> `;
2,451
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components
petrpan-code/mattermost/mattermost/webapp/channels/src/components/interactive_dialog/dialog_introduction_text.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {mount} from 'enzyme'; import React from 'react'; import EmojiMap from 'utils/emoji_map'; import DialogIntroductionText from './dialog_introduction_text'; describe('components/DialogIntroductionText', () => { const emojiMap = new EmojiMap(new Map()); test('should render message with supported values', () => { const descriptor = { id: 'testsupported', value: '**bold** *italic* [link](https://mattermost.com/) <br/> [link target blank](!https://mattermost.com/)', emojiMap, }; const wrapper = mount(<DialogIntroductionText {...descriptor}/>); expect(wrapper).toMatchSnapshot(); }); test('should not fail on empty value', () => { const descriptor = { id: 'testblankvalue', value: '', emojiMap, }; const wrapper = mount(<DialogIntroductionText {...descriptor}/>); expect(wrapper).toMatchSnapshot(); }); });
2,454
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components
petrpan-code/mattermost/mattermost/webapp/channels/src/components/interactive_dialog/interactive_dialog.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import {Modal} from 'react-bootstrap'; import {Provider} from 'react-redux'; import type {DialogElement as TDialogElement} from '@mattermost/types/integrations'; import {mountWithIntl} from 'tests/helpers/intl-test-helper'; import mockStore from 'tests/test_store'; import EmojiMap from 'utils/emoji_map'; import type {Props} from './interactive_dialog'; import InteractiveDialog from './interactive_dialog'; const submitEvent = { preventDefault: jest.fn(), } as unknown as React.FormEvent<HTMLFormElement>; describe('components/interactive_dialog/InteractiveDialog', () => { const baseProps: Props = { url: 'http://example.com', callbackId: 'abc', elements: [], title: 'test title', iconUrl: 'http://example.com/icon.png', submitLabel: 'Yes', notifyOnCancel: true, state: 'some state', onExited: jest.fn(), actions: { submitInteractiveDialog: jest.fn(), }, emojiMap: new EmojiMap(new Map()), }; describe('generic error message', () => { test('should appear when submit returns an error', async () => { const props = { ...baseProps, actions: { submitInteractiveDialog: jest.fn().mockResolvedValue({data: {error: 'This is an error.'}}), }, }; const wrapper = shallow<InteractiveDialog>(<InteractiveDialog {...props}/>); await wrapper.instance().handleSubmit(submitEvent); const expected = ( <div className='error-text'> {'This is an error.'} </div> ); expect(wrapper.find(Modal.Footer).containsMatchingElement(expected)).toBe(true); }); test('should not appear when submit does not return an error', async () => { const wrapper = shallow<InteractiveDialog>(<InteractiveDialog {...baseProps}/>); await wrapper.instance().handleSubmit(submitEvent); expect(wrapper.find(Modal.Footer).exists('.error-text')).toBe(false); }); }); describe('default select element in Interactive Dialog', () => { test('should be enabled by default', () => { const selectElement: TDialogElement = { data_source: '', default: 'opt3', display_name: 'Option Selector', name: 'someoptionselector', optional: false, options: [ {text: 'Option1', value: 'opt1'}, {text: 'Option2', value: 'opt2'}, {text: 'Option3', value: 'opt3'}, ], type: 'select', subtype: '', placeholder: '', help_text: '', min_length: 0, max_length: 0, }; const {elements, ...rest} = baseProps; elements?.push(selectElement); const props = { ...rest, elements, }; const store = mockStore({}); const wrapper = mountWithIntl( <Provider store={store}> <InteractiveDialog {...props}/> </Provider>, ); expect(wrapper.find(Modal.Body).find('input').find({defaultValue: 'Option3'}).exists()).toBe(true); }); }); describe('bool element in Interactive Dialog', () => { const element: TDialogElement = { data_source: '', display_name: 'Boolean Selector', name: 'somebool', optional: false, type: 'bool', placeholder: 'Subscribe?', subtype: '', default: '', help_text: '', min_length: 0, max_length: 0, options: [], }; const {elements, ...rest} = baseProps; const props = { ...rest, elements: [ ...elements || [], element, ], }; const testCases = [ {description: 'no default', expectedChecked: false}, {description: 'unknown default', default: 'unknown', expectedChecked: false}, {description: 'default of "false"', default: 'false', expectedChecked: false}, {description: 'default of true', default: true, expectedChecked: true}, {description: 'default of "true"', default: 'True', expectedChecked: true}, {description: 'default of "True"', default: 'True', expectedChecked: true}, {description: 'default of "TRUE"', default: 'TRUE', expectedChecked: true}, ]; testCases.forEach((testCase) => test(`should interpret ${testCase.description}`, () => { if (testCase.default === undefined) { delete (element as any).default; } else { (element as any).default = testCase.default; } const store = mockStore({}); const wrapper = mountWithIntl( <Provider store={store}> <InteractiveDialog {...props}/> </Provider>, ); expect(wrapper.find(Modal.Body).find('input').find({checked: testCase.expectedChecked}).exists()).toBe(true); })); }); });
2,456
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/interactive_dialog
petrpan-code/mattermost/mattermost/webapp/channels/src/components/interactive_dialog/__snapshots__/dialog_introduction_text.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/DialogIntroductionText should not fail on empty value 1`] = ` <DialogIntroductionText emojiMap={ EmojiMap { "customEmojis": Map {}, "customEmojisArray": Array [], } } id="testblankvalue" value="" > <span dangerouslySetInnerHTML={ Object { "__html": "", } } id="testblankvalue" /> </DialogIntroductionText> `; exports[`components/DialogIntroductionText should render message with supported values 1`] = ` <DialogIntroductionText emojiMap={ EmojiMap { "customEmojis": Map {}, "customEmojisArray": Array [], } } id="testsupported" value="**bold** *italic* [link](https://mattermost.com/) <br/> [link target blank](!https://mattermost.com/)" > <span dangerouslySetInnerHTML={ Object { "__html": "<p><strong>bold</strong> <em>italic</em> <a class=\\"theme markdown__link\\" href=\\"https://mattermost.com/\\" rel=\\"noreferrer\\" target=\\"_blank\\">link</a> &lt;br/&gt; <a class=\\"theme markdown__link\\" href=\\"!https://mattermost.com/\\" rel=\\"noreferrer\\" target=\\"_blank\\">link target blank</a></p>", } } id="testsupported" /> </DialogIntroductionText> `;
2,457
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/interactive_dialog
petrpan-code/mattermost/mattermost/webapp/channels/src/components/interactive_dialog/dialog_element/dialog_element.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import RadioSetting from 'components/widgets/settings/radio_setting'; import TextSetting from 'components/widgets/settings/text_setting'; import DialogElement from './dialog_element'; describe('components/interactive_dialog/DialogElement', () => { const baseDialogProps = { displayName: 'Testing', name: 'testing', type: 'text', maxLength: 100, actions: { autocompleteChannels: jest.fn(), autocompleteUsers: jest.fn(), }, onChange: jest.fn(), }; it('type textarea', () => { const wrapper = shallow( <DialogElement {...baseDialogProps} type='textarea' />, ); expect(wrapper.find(TextSetting).dive().find('textarea').exists()).toBe(true); }); it('subtype blank', () => { const wrapper = shallow( <DialogElement {...baseDialogProps} subtype='' />, ); expect(wrapper.find(TextSetting).props().type).toEqual('text'); }); describe('subtype number', () => { test('value is 0', () => { const wrapper = shallow( <DialogElement {...baseDialogProps} type='text' subtype='number' value={0} />, ); expect(wrapper.find(TextSetting).props().value).toEqual(0); }); test('value is 123', () => { const wrapper = shallow( <DialogElement {...baseDialogProps} type='text' subtype='number' value={123} />, ); expect(wrapper.find(TextSetting).props().value).toEqual(123); }); }); it('subtype email', () => { const wrapper = shallow( <DialogElement {...baseDialogProps} subtype='email' />, ); expect(wrapper.find(TextSetting).props().type).toEqual('email'); }); it('subtype password', () => { const wrapper = shallow( <DialogElement {...baseDialogProps} subtype='password' />, ); expect(wrapper.find(TextSetting).props().type).toEqual('password'); }); describe('radioSetting', () => { const radioOptions = [ {value: 'foo', text: 'foo-text'}, {value: 'bar', text: 'bar-text'}, ]; test('RadioSetting is rendered when type is radio', () => { const wrapper = shallow( <DialogElement {...baseDialogProps} type='radio' options={radioOptions} />, ); expect(wrapper.find(RadioSetting).exists()).toBe(true); }); test('RadioSetting is rendered when options are null', () => { const wrapper = shallow( <DialogElement {...baseDialogProps} type='radio' options={undefined} />, ); expect(wrapper.find(RadioSetting).exists()).toBe(true); }); test('RadioSetting is rendered when options are null and value is null', () => { const wrapper = shallow( <DialogElement {...baseDialogProps} type='radio' options={undefined} value={undefined} />, ); expect(wrapper.find(RadioSetting).exists()).toBe(true); }); test('RadioSetting is rendered when options are null and value is not null', () => { const wrapper = shallow( <DialogElement {...baseDialogProps} type='radio' options={undefined} value={'a'} />, ); expect(wrapper.find(RadioSetting).exists()).toBe(true); }); test('RadioSetting is rendered when value is not one of the options', () => { const wrapper = shallow( <DialogElement {...baseDialogProps} type='radio' options={radioOptions} value={'a'} />, ); expect(wrapper.find(RadioSetting).exists()).toBe(true); }); test('No default value is selected from the radio button list', () => { const wrapper = shallow( <DialogElement {...baseDialogProps} type='radio' options={radioOptions} />, ); const instance = wrapper.instance() as DialogElement; expect(instance.props.value).toBeUndefined(); }); test('The default value can be specified from the list', () => { const wrapper = shallow( <DialogElement {...baseDialogProps} type='radio' options={radioOptions} value={radioOptions[1].value} />, ); expect(wrapper.find({options: radioOptions, value: radioOptions[1].value}).exists()).toBe(true); }); }); });
2,461
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components
petrpan-code/mattermost/mattermost/webapp/channels/src/components/intl_provider/intl_provider.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {mount, shallow} from 'enzyme'; import React from 'react'; import {FormattedMessage} from 'react-intl'; import IntlProvider from 'components/intl_provider/intl_provider'; import {getLanguageInfo} from 'i18n/i18n'; describe('components/IntlProvider', () => { const baseProps = { locale: 'en', translations: { 'test.hello_world': 'Hello, World!', }, actions: { loadTranslations: () => {}, // eslint-disable-line }, children: ( <FormattedMessage id='test.hello_world' defaultMessage='Hello, World!' /> ), }; test('should render children when passed translation strings', () => { const wrapper = mount(<IntlProvider {...baseProps}/>); expect(wrapper.find(FormattedMessage).childAt(0)).toMatchSnapshot(); }); test('should render children when passed translation strings for a non-default locale', () => { const props = { ...baseProps, locale: 'fr', translations: { 'test.hello_world': 'Bonjour tout le monde!', }, }; const wrapper = mount(<IntlProvider {...props}/>); expect(wrapper.find(FormattedMessage).childAt(0)).toMatchSnapshot(); }); test('should render null when missing translation strings', () => { const props = { ...baseProps, translations: undefined, }; const wrapper = mount(<IntlProvider {...props}/>); expect(wrapper.find(FormattedMessage).exists()).toBe(false); }); test('on mount, should attempt to load missing translations', () => { const props = { ...baseProps, locale: 'fr', translations: undefined, actions: { loadTranslations: jest.fn(), }, }; shallow(<IntlProvider {...props}/>); expect(props.actions.loadTranslations).toBeCalledWith('fr', getLanguageInfo('fr').url); }); test('on mount, should not attempt to load when given translations', () => { const props = { ...baseProps, locale: 'fr', translations: {}, actions: { loadTranslations: jest.fn(), }, }; shallow(<IntlProvider {...props}/>); expect(props.actions.loadTranslations).not.toBeCalled(); }); test('on locale change, should attempt to load missing translations', () => { const props = { ...baseProps, actions: { loadTranslations: jest.fn(), }, }; const wrapper = shallow(<IntlProvider {...props}/>); expect(props.actions.loadTranslations).not.toBeCalled(); wrapper.setProps({ locale: 'fr', translations: null, }); expect(props.actions.loadTranslations).toBeCalledWith('fr', getLanguageInfo('fr').url); }); test('on locale change, should not attempt to load when given translations', () => { const props = { ...baseProps, actions: { loadTranslations: jest.fn(), }, }; const wrapper = shallow(<IntlProvider {...props}/>); expect(props.actions.loadTranslations).not.toBeCalled(); wrapper.setProps({ locale: 'fr', translations: {}, }); expect(props.actions.loadTranslations).not.toBeCalled(); }); });
2,463
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/intl_provider
petrpan-code/mattermost/mattermost/webapp/channels/src/components/intl_provider/__snapshots__/intl_provider.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/IntlProvider should render children when passed translation strings 1`] = ` <span> Hello, World! </span> `; exports[`components/IntlProvider should render children when passed translation strings for a non-default locale 1`] = ` <span> Bonjour tout le monde! </span> `;
2,465
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components
petrpan-code/mattermost/mattermost/webapp/channels/src/components/invitation_modal/add_to_channels.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import React from 'react'; import type {Channel} from '@mattermost/types/channels'; import deepFreeze from 'mattermost-redux/utils/deep_freeze'; import CloseCircleIcon from 'components/widgets/icons/close_circle_icon'; import {mountWithIntl} from 'tests/helpers/intl-test-helper'; import {renderWithContext, screen} from 'tests/react_testing_utils'; import AddToChannels from './add_to_channels'; import type {Props} from './add_to_channels'; const baseProps: Props = deepFreeze({ customMessage: { message: '', open: false, }, toggleCustomMessage: jest.fn(), setCustomMessage: jest.fn(), inviteChannels: { channels: [], search: '', }, onChannelsChange: jest.fn(), onChannelsInputChange: jest.fn(), channelsLoader: jest.fn(), currentChannel: { display_name: '', }, townSquareDisplayName: 'Town Square', }); describe('AddToChannels', () => { describe('placeholder selection', () => { it('should use townSquareDisplayName when not in a channel', () => { const props = {...baseProps, currentChannel: undefined}; renderWithContext(<AddToChannels {...props}/>); expect(screen.getByText(props.townSquareDisplayName, {exact: false})).toBeInTheDocument(); }); it('should use townSqureDisplayName when not in a public or private channel', () => { const props = {...baseProps, currentChannel: {type: 'D', display_name: ''} as Channel}; renderWithContext(<AddToChannels {...props}/>); expect(screen.getByText(props.townSquareDisplayName, {exact: false})).toBeInTheDocument(); }); it('should use the currentChannel display_name when in a channel', () => { const props = {...baseProps, currentChannel: {type: 'O', display_name: 'My Awesome Channel'} as Channel}; renderWithContext(<AddToChannels {...props}/>); expect(screen.getByText('My Awesome Channel', {exact: false})).toBeInTheDocument(); }); }); describe('custom message', () => { it('UI to toggle custom message opens it when closed', () => { const props = baseProps; const wrapper = mountWithIntl(<AddToChannels {...props}/>); expect(props.toggleCustomMessage).not.toHaveBeenCalled(); wrapper.find('a').at(0).simulate('click'); expect(props.toggleCustomMessage).toHaveBeenCalled(); }); it('UI to toggle custom message closes it when opened', () => { const props = { ...baseProps, customMessage: { ...baseProps.customMessage, open: true, }, }; const wrapper = mountWithIntl(<AddToChannels {...props}/>); expect(props.toggleCustomMessage).not.toHaveBeenCalled(); wrapper.find(CloseCircleIcon).at(0).simulate('click'); expect(props.toggleCustomMessage).toHaveBeenCalled(); }); it('UI to write custom message calls the on change handler with its input', () => { const props = { ...baseProps, customMessage: { ...baseProps.customMessage, open: true, }, }; const wrapper = mountWithIntl(<AddToChannels {...props}/>); expect(props.setCustomMessage).not.toHaveBeenCalled(); const expectedMessage = 'welcome to the team!'; wrapper.find('textarea').at(0).simulate('change', { target: { value: expectedMessage, }, }); expect(props.setCustomMessage).toHaveBeenCalledWith(expectedMessage); }); }); });
2,467
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components
petrpan-code/mattermost/mattermost/webapp/channels/src/components/invitation_modal/index.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import type {Channel} from '@mattermost/types/channels'; import {Permissions} from 'mattermost-redux/constants'; import type {GlobalState} from 'types/store'; import {mapStateToProps} from './index'; describe('mapStateToProps', () => { const currentTeamId = 'team-id'; const currentUserId = 'user-id'; const currentChannelId = 'channel-id'; const initialState = { entities: { general: { config: { EnableGuestAccounts: 'true', BuildEnterpriseReady: 'true', }, license: { IsLicensed: 'true', }, }, teams: { currentTeamId, teams: { [currentTeamId]: { display_name: 'team1', }, }, myMembers: {}, }, preferences: { myPreferences: {}, }, channels: { channels: { [currentChannelId]: { display_name: 'team1', }, }, currentChannelId, channelsInTeam: { [currentTeamId]: new Set(), }, }, users: { currentUserId, profiles: { [currentUserId]: { id: currentUserId, roles: 'test_user_role', }, }, }, roles: { roles: { test_user_role: {permissions: [Permissions.INVITE_GUEST]}, }, }, cloud: {}, }, views: { modals: { modalState: {}, }, }, errors: [], websocket: {}, requests: {}, } as unknown as GlobalState; test('canInviteGuests is false when group_constrained is true', () => { const testState = { ...initialState, entities: { ...initialState.entities, teams: { ...initialState.entities.teams, teams: { [currentTeamId]: { id: currentTeamId, group_constrained: true, }, }, }, }, } as unknown as GlobalState; const props = mapStateToProps(testState, {}); expect(props.canInviteGuests).toBe(false); }); test('canInviteGuests is false when BuildEnterpriseReady is false', () => { const testState = { ...initialState, entities: { ...initialState.entities, general: { config: { EnableGuestAccounts: 'true', BuildEnterpriseReady: 'false', }, license: { IsLicensed: 'true', }, }, teams: { ...initialState.entities.teams, teams: { [currentTeamId]: { id: currentTeamId, group_constrained: true, }, }, }, }, } as unknown as GlobalState; const props = mapStateToProps(testState, {}); expect(props.canInviteGuests).toBe(false); }); test('canInviteGuests is true when group_constrained is false', () => { const testState = { ...initialState, entities: { ...initialState.entities, teams: { ...initialState.entities.teams, myMembers: { ...initialState.entities.teams.myMembers, }, teams: { [currentTeamId]: { id: currentTeamId, group_constrained: false, }, }, }, }, } as unknown as GlobalState; const props = mapStateToProps(testState, {}); expect(props.canInviteGuests).toBe(true); }); test('grabs the team info based on the ownProps channelToInvite value', () => { const testState = { ...initialState, entities: { ...initialState.entities, teams: { ...initialState.entities.teams, myMembers: { ...initialState.entities.teams.myMembers, }, teams: { [currentTeamId]: { id: currentTeamId, group_constrained: false, }, currentTeamId: '', }, }, }, } as unknown as GlobalState; const testChannel = { display_name: 'team1', channel_id: currentChannelId, team_id: currentTeamId, } as unknown as Channel; const props = mapStateToProps(testState, {channelToInvite: testChannel}); expect(props.currentTeam.id).toBe(testChannel.team_id); }); });
2,470
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components
petrpan-code/mattermost/mattermost/webapp/channels/src/components/invitation_modal/invitation_modal.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import React from 'react'; import type {IntlShape} from 'react-intl'; import {Provider} from 'react-redux'; import type {Team} from '@mattermost/types/teams'; import deepFreeze from 'mattermost-redux/utils/deep_freeze'; import store from 'stores/redux_store'; import {mountWithThemedIntl} from 'tests/helpers/themed-intl-test-helper'; import {SelfHostedProducts} from 'utils/constants'; import {TestHelper} from 'utils/test_helper'; import {generateId} from 'utils/utils'; import InvitationModal, {View, InvitationModal as BaseInvitationModal} from './invitation_modal'; import type {Props} from './invitation_modal'; import InviteView from './invite_view'; import NoPermissionsView from './no_permissions_view'; import ResultView from './result_view'; const defaultProps: Props = deepFreeze({ actions: { searchChannels: jest.fn(), regenerateTeamInviteId: jest.fn(), searchProfiles: jest.fn(), sendGuestsInvites: jest.fn(), sendMembersInvites: jest.fn(), sendMembersInvitesToChannels: jest.fn(), }, currentTeam: { display_name: '', } as Team, currentChannel: { display_name: '', }, invitableChannels: [], emailInvitationsEnabled: true, isAdmin: false, isCloud: false, canAddUsers: true, canInviteGuests: true, intl: {} as IntlShape, townSquareDisplayName: '', onExited: jest.fn(), }); let props = defaultProps; describe('InvitationModal', () => { const state = { entities: { admin: { prevTrialLicense: { IsLicensed: 'true', }, }, general: { config: { BuildEnterpriseReady: 'true', }, license: { IsLicensed: 'true', Cloud: 'true', Id: generateId(), }, }, cloud: { subscription: { is_free_trial: 'false', trial_end_at: 0, }, }, users: { currentUserId: 'current_user_id', profiles: { current_user_id: {roles: 'system_user'}, }, }, roles: { roles: { system_user: { permissions: [], }, }, }, preferences: { myPreferences: {}, }, hostedCustomer: { products: { productsLoaded: true, products: { prod_professional: TestHelper.getProductMock({ id: 'prod_professional', name: 'Professional', sku: SelfHostedProducts.PROFESSIONAL, price_per_seat: 7.5, }), }, }, }, }, }; store.getState = () => (state); beforeEach(() => { props = defaultProps; }); it('shows invite view when view state is invite', () => { const wrapper = mountWithThemedIntl( <Provider store={store}> <InvitationModal {...props}/> </Provider>, ); expect(wrapper.find(InviteView).length).toBe(1); }); it('shows result view when view state is result', () => { const wrapper = mountWithThemedIntl( <Provider store={store}> <InvitationModal {...props}/> </Provider>, ); wrapper.find(BaseInvitationModal).at(0).setState({view: View.RESULT}); wrapper.update(); expect(wrapper.find(ResultView).length).toBe(1); }); it('shows no permissions view when user can neither invite users nor guests', () => { props = { ...props, canAddUsers: false, canInviteGuests: false, }; const wrapper = mountWithThemedIntl( <Provider store={store}> <InvitationModal {...props}/> </Provider>, ); expect(wrapper.find(NoPermissionsView).length).toBe(1); }); });
2,473
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components
petrpan-code/mattermost/mattermost/webapp/channels/src/components/invitation_modal/invite_as.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import {Provider} from 'react-redux'; import RadioGroup from 'components/common/radio_group'; import {mountWithIntl} from 'tests/helpers/intl-test-helper'; import mockStore from 'tests/test_store'; import {CloudProducts} from 'utils/constants'; import InviteAs, {InviteType} from './invite_as'; jest.mock('mattermost-redux/selectors/entities/users', () => ({ ...jest.requireActual('mattermost-redux/selectors/entities/users') as typeof import('mattermost-redux/selectors/entities/users'), isCurrentUserSystemAdmin: () => true, })); describe('components/cloud_start_trial_btn/cloud_start_trial_btn', () => { const THIRTY_DAYS = (60 * 60 * 24 * 30 * 1000); // in milliseconds const subscriptionCreateAt = Date.now(); const subscriptionEndAt = subscriptionCreateAt + THIRTY_DAYS; const props = { setInviteAs: jest.fn(), inviteType: InviteType.MEMBER, titleClass: 'title', }; const state = { entities: { admin: { prevTrialLicense: { IsLicensed: 'true', }, }, general: { config: { BuildEnterpriseReady: 'true', }, license: { IsLicensed: 'true', Cloud: 'true', }, }, cloud: { subscription: { is_free_trial: 'false', trial_end_at: 0, }, }, users: { currentUserId: 'uid', profiles: { uid: {}, }, }, }, }; const store = mockStore(state); test('should match snapshot', () => { const wrapper = shallow( <Provider store={store}> <InviteAs {...props}/> </Provider>, ); expect(wrapper).toMatchSnapshot(); }); test('shows the radio buttons', () => { const wrapper = mountWithIntl( <Provider store={store}> <InviteAs {...props}/> </Provider>, ); expect(wrapper.find(RadioGroup).length).toBe(1); }); test('guest radio-button is disabled and shows the badge guest restricted feature to invite guest when is NOT free trial for cloud', () => { const state = { entities: { admin: { prevTrialLicense: { IsLicensed: 'false', }, }, general: { config: { BuildEnterpriseReady: 'true', }, license: { IsLicensed: 'true', Cloud: 'true', SkuShortName: CloudProducts.STARTER, }, }, cloud: { subscription: { is_free_trial: 'false', trial_end_at: 0, sku: CloudProducts.STARTER, product_id: 'cloud-starter-id', }, products: { 'cloud-starter-id': { sku: CloudProducts.STARTER, }, }, }, users: { currentUserId: 'uid', profiles: { current_user_id: {roles: 'system_admin'}, }, }, }, }; const store = mockStore(state); const wrapper = mountWithIntl( <Provider store={store}> <InviteAs {...props}/> </Provider>, ); const guestRadioButton = wrapper.find('input[value="GUEST"]'); expect(guestRadioButton.props().disabled).toBe(true); const badgeText = wrapper.find('.Tag span.tag-text').text(); expect(badgeText).toBe('Professional feature- try it out free'); }); test('restricted badge shows "Upgrade" for cloud post trial', () => { const state = { entities: { admin: { prevTrialLicense: { IsLicensed: 'false', }, }, general: { config: { BuildEnterpriseReady: 'true', }, license: { IsLicensed: 'true', Cloud: 'true', SkuShortName: CloudProducts.STARTER, }, }, cloud: { subscription: { is_free_trial: 'false', trial_end_at: 100000, sku: CloudProducts.STARTER, product_id: 'cloud-starter-id', }, products: { 'cloud-starter-id': { sku: CloudProducts.STARTER, }, }, }, users: { currentUserId: 'uid', profiles: { current_user_id: {roles: 'system_admin'}, }, }, }, }; const store = mockStore(state); const wrapper = mountWithIntl( <Provider store={store}> <InviteAs {...props}/> </Provider>, ); const guestRadioButton = wrapper.find('input[value="GUEST"]'); expect(guestRadioButton.props().disabled).toBe(true); const badgeText = wrapper.find('.Tag span.tag-text').text(); expect(badgeText).toBe('Upgrade'); }); test('guest radio-button is disabled and shows the badge guest restricted feature to invite guest when is NOT free trial for self hosted starter', () => { const state = { entities: { admin: { prevTrialLicense: { IsLicensed: 'false', }, }, general: { config: { BuildEnterpriseReady: 'true', }, license: { IsLicensed: 'false', }, }, cloud: {}, users: { currentUserId: 'uid', profiles: { current_user_id: {roles: 'system_admin'}, }, }, }, }; const store = mockStore(state); const wrapper = mountWithIntl( <Provider store={store}> <InviteAs {...props}/> </Provider>, ); const guestRadioButton = wrapper.find('input[value="GUEST"]'); expect(guestRadioButton.props().disabled).toBe(true); const badgeText = wrapper.find('.Tag span.tag-text').text(); expect(badgeText).toBe('Professional feature- try it out free'); }); test('restricted badge shows "Upgrade" for self hosted starter post trial', () => { const state = { entities: { admin: { prevTrialLicense: { IsLicensed: 'true', }, }, general: { config: { BuildEnterpriseReady: 'true', }, license: { IsLicensed: 'false', }, }, cloud: {}, users: { currentUserId: 'uid', profiles: { current_user_id: {roles: 'system_admin'}, }, }, }, }; const store = mockStore(state); const wrapper = mountWithIntl( <Provider store={store}> <InviteAs {...props}/> </Provider>, ); const guestRadioButton = wrapper.find('input[value="GUEST"]'); expect(guestRadioButton.props().disabled).toBe(true); const badgeText = wrapper.find('.Tag span.tag-text').text(); expect(badgeText).toBe('Upgrade'); }); test('shows the badge guest highligh feature to invite guest when IS FREE trial for cloud', () => { const state = { entities: { admin: { prevTrialLicense: { IsLicensed: 'false', }, }, general: { config: { BuildEnterpriseReady: 'true', }, license: { IsLicensed: 'true', Cloud: 'true', SkuShortName: CloudProducts.STARTER, }, }, cloud: { subscription: { is_free_trial: 'true', trial_end_at: subscriptionEndAt, }, }, users: { currentUserId: 'uid', profiles: { current_user_id: {roles: 'system_admin'}, }, }, }, }; const store = mockStore(state); const wrapper = mountWithIntl( <Provider store={store}> <InviteAs {...props}/> </Provider>, ); const guestRadioButton = wrapper.find('input[value="GUEST"]'); expect(guestRadioButton.props().disabled).toBe(false); const badgeText = wrapper.find('.Tag span.tag-text').text(); expect(badgeText).toBe('Professional feature'); }); test('shows the badge guest highligh feature to invite guest when IS FREE trial for self hosted starter', () => { const state = { entities: { admin: { prevTrialLicense: { IsLicensed: 'false', }, }, general: { config: { BuildEnterpriseReady: 'true', }, license: { IsLicensed: 'true', IsTrial: 'true', }, }, cloud: {}, users: { currentUserId: 'uid', profiles: { current_user_id: {roles: 'system_admin'}, }, }, }, }; const store = mockStore(state); const wrapper = mountWithIntl( <Provider store={store}> <InviteAs {...props}/> </Provider>, ); const guestRadioButton = wrapper.find('input[value="GUEST"]'); expect(guestRadioButton.props().disabled).toBe(false); const badgeText = wrapper.find('.Tag span.tag-text').text(); expect(badgeText).toBe('Professional feature'); }); });
2,476
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components
petrpan-code/mattermost/mattermost/webapp/channels/src/components/invitation_modal/invite_view.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import React from 'react'; import {act} from 'react-dom/test-utils'; import {Provider} from 'react-redux'; import type {Team} from '@mattermost/types/teams'; import deepFreeze from 'mattermost-redux/utils/deep_freeze'; import store from 'stores/redux_store'; import {mountWithThemedIntl} from 'tests/helpers/themed-intl-test-helper'; import {SelfHostedProducts} from 'utils/constants'; import {TestHelper as TH} from 'utils/test_helper'; import {generateId} from 'utils/utils'; import InviteAs, {InviteType} from './invite_as'; import InviteView from './invite_view'; import type {Props} from './invite_view'; const defaultProps: Props = deepFreeze({ setInviteAs: jest.fn(), inviteType: InviteType.MEMBER, titleClass: 'title', invite: jest.fn(), onChannelsChange: jest.fn(), onChannelsInputChange: jest.fn(), onClose: jest.fn(), currentTeam: {} as Team, currentChannel: { display_name: 'some_channel', }, setCustomMessage: jest.fn(), toggleCustomMessage: jest.fn(), channelsLoader: jest.fn(), regenerateTeamInviteId: jest.fn(), isAdmin: false, usersLoader: jest.fn(), onChangeUsersEmails: jest.fn(), isCloud: false, emailInvitationsEnabled: true, onUsersInputChange: jest.fn(), headerClass: '', footerClass: '', canInviteGuests: true, canAddUsers: true, customMessage: { message: '', open: false, }, sending: false, inviteChannels: { channels: [], search: '', }, usersEmails: [], usersEmailsSearch: '', townSquareDisplayName: '', }); let props = defaultProps; describe('InviteView', () => { const state = { entities: { admin: { prevTrialLicense: { IsLicensed: 'true', }, }, general: { config: { BuildEnterpriseReady: 'true', }, license: { IsLicensed: 'true', Cloud: 'true', Id: generateId(), }, }, cloud: { subscription: { is_free_trial: 'false', trial_end_at: 0, }, }, users: { currentUserId: 'current_user_id', profiles: { current_user_id: {roles: 'system_user'}, }, }, roles: { roles: { system_user: { permissions: [], }, }, }, preferences: { myPreferences: {}, }, hostedCustomer: { products: { productsLoaded: true, products: { prod_professional: TH.getProductMock({ id: 'prod_professional', name: 'Professional', sku: SelfHostedProducts.PROFESSIONAL, price_per_seat: 7.5, }), }, }, }, }, }; store.getState = () => (state); beforeEach(() => { props = defaultProps; }); it('shows InviteAs component when user can choose to invite guests or users', async () => { await act(async () => { const wrapper = mountWithThemedIntl( <Provider store={store}> <InviteView {...props}/> </Provider>, ); expect(wrapper.find(InviteAs).length).toBe(1); }); }); it('hides InviteAs component when user can not choose members option', async () => { props = { ...defaultProps, canAddUsers: false, }; await act(async () => { const wrapper = mountWithThemedIntl( <Provider store={store}> <InviteView {...props}/> </Provider>, ); expect(wrapper.find(InviteAs).length).toBe(0); }); }); it('hides InviteAs component when user can not choose guests option', async () => { props = { ...defaultProps, canInviteGuests: false, }; await act(async () => { const wrapper = mountWithThemedIntl( <Provider store={store}> <InviteView {...props}/> </Provider>, ); expect(wrapper.find(InviteAs).length).toBe(0); }); }); });
2,481
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components
petrpan-code/mattermost/mattermost/webapp/channels/src/components/invitation_modal/result_table.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import deepFreeze from 'mattermost-redux/utils/deep_freeze'; import AlertIcon from 'components/widgets/icons/alert_icon'; import EmailIcon from 'components/widgets/icons/mail_icon'; import BotTag from 'components/widgets/tag/bot_tag'; import GuestTag from 'components/widgets/tag/guest_tag'; import Avatar from 'components/widgets/users/avatar'; import {mountWithIntl} from 'tests/helpers/intl-test-helper'; import ResultTable from './result_table'; import type {Props} from './result_table'; let props: Props = { sent: true, rows: [], }; const defaultUser = deepFreeze({ id: 'userid', create_at: 1, update_at: 1, delete_at: 1, username: 'username', password: 'password', auth_service: 'auth_service', email: '[email protected]', email_verified: true, nickname: 'nickname', first_name: 'first_name', last_name: 'last_name', position: 'position', roles: 'user', props: {}, notify_props: { desktop: 'default', desktop_sound: 'true', email: 'true', mark_unread: 'all', push: 'default', push_status: 'ooo', comments: 'never', first_name: 'true', channel: 'true', mention_keys: '', }, last_password_update: 1, last_picture_update: 1, locale: 'en', mfa_active: false, last_activity_at: 1, is_bot: false, bot_description: '', terms_of_service_id: '', terms_of_service_create_at: 1, }, ); describe('ResultTable', () => { beforeEach(() => { props = { sent: true, rows: [], }; }); test('emails render as email', () => { props.rows = [{ email: '[email protected]', reason: 'some reason', }]; const wrapper = shallow(<ResultTable {...props}/>); expect(wrapper.find(EmailIcon).length).toBe(1); }); test('unsent invites render as unsent invites', () => { props.rows = [{ text: '@incomplete_userna', reason: 'This was not a complete user', }]; const wrapper = shallow(<ResultTable {...props}/>); expect(wrapper.find(AlertIcon).length).toBe(1); }); test('user invites render as users', () => { props.rows = [{ user: defaultUser, reason: 'added successfuly', }]; const wrapper = shallow(<ResultTable {...props}/>); expect(wrapper.find(Avatar).length).toBe(1); expect(wrapper.find(BotTag).length).toBe(0); expect(wrapper.find(GuestTag).length).toBe(0); }); test('bots render as bots', () => { props.rows = [{ user: { ...defaultUser, is_bot: true, }, reason: 'added successfuly', }]; const wrapper = shallow(<ResultTable {...props}/>); expect(wrapper.find(Avatar).length).toBe(1); expect(wrapper.find(BotTag).length).toBe(1); expect(wrapper.find(GuestTag).length).toBe(0); }); test('guests render as guests', () => { props.rows = [{ user: { ...defaultUser, roles: 'system_guest', }, reason: 'added successfuly', }]; const wrapper = shallow(<ResultTable {...props}/>); expect(wrapper.find(Avatar).length).toBe(1); expect(wrapper.find(BotTag).length).toBe(0); expect(wrapper.find(GuestTag).length).toBe(1); }); test('renders success banner when invites were sent', () => { props.sent = true; const wrapper = mountWithIntl(<ResultTable {...props}/>); expect(wrapper.find('h2').at(0).text()).toContain('Successful Invites'); }); test('renders not sent banner when invites were not sent', () => { props.sent = false; const wrapper = mountWithIntl(<ResultTable {...props}/>); expect(wrapper.find('h2').at(0).text()).toContain('Invitations Not Sent'); }); });
2,485
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/invitation_modal
petrpan-code/mattermost/mattermost/webapp/channels/src/components/invitation_modal/__snapshots__/invite_as.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/cloud_start_trial_btn/cloud_start_trial_btn should match snapshot 1`] = ` <ContextProvider value={ Object { "store": Object { "clearActions": [Function], "dispatch": [Function], "getActions": [Function], "getState": [Function], "replaceReducer": [Function], "subscribe": [Function], }, "subscription": Subscription { "handleChangeWrapper": [Function], "listeners": Object { "notify": [Function], }, "onStateChange": [Function], "parentSub": undefined, "store": Object { "clearActions": [Function], "dispatch": [Function], "getActions": [Function], "getState": [Function], "replaceReducer": [Function], "subscribe": [Function], }, "unsubscribe": null, }, } } > <InviteAs inviteType="MEMBER" setInviteAs={[MockFunction]} titleClass="title" /> </ContextProvider> `;
2,488
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/invitation_modal
petrpan-code/mattermost/mattermost/webapp/channels/src/components/invitation_modal/overage_users_banner_notice/overage_users_banner_notice.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import React from 'react'; import type {DeepPartial} from '@mattermost/types/utilities'; import {savePreferences} from 'mattermost-redux/actions/preferences'; import {General} from 'mattermost-redux/constants'; import {trackEvent} from 'actions/telemetry_actions'; import { fireEvent, renderWithContext, screen, } from 'tests/react_testing_utils'; import {LicenseLinks, OverActiveUserLimits, Preferences, SelfHostedProducts, StatTypes} from 'utils/constants'; import {TestHelper} from 'utils/test_helper'; import {generateId} from 'utils/utils'; import type {GlobalState} from 'types/store'; import OverageUsersBannerNotice from './index'; jest.mock('react-redux', () => ({ ...jest.requireActual('react-redux'), useDispatch: jest.fn().mockReturnValue(() => {}), })); jest.mock('mattermost-redux/actions/preferences', () => ({ savePreferences: jest.fn(), })); jest.mock('actions/telemetry_actions', () => ({ trackEvent: jest.fn(), // Disable any additional query parameteres from being added in the event of a link-out isTelemetryEnabled: jest.fn().mockReturnValue(false), })); const seatsPurchased = 40; const seatsMinimumFor5PercentageState = (Math.ceil(seatsPurchased * OverActiveUserLimits.MIN)) + seatsPurchased; const seatsMinimumFor10PercentageState = (Math.ceil(seatsPurchased * OverActiveUserLimits.MAX)) + seatsPurchased; const text5PercentageState = `Your workspace user count has exceeded your paid license seat count by ${seatsMinimumFor5PercentageState - seatsPurchased} seats`; const text10PercentageState = `Your workspace user count has exceeded your paid license seat count by ${seatsMinimumFor10PercentageState - seatsPurchased} seats`; const notifyText = 'Notify your Customer Success Manager on your next true-up check'; const contactSalesTextLink = 'Contact Sales'; const expandSeatsTextLink = 'Purchase additional seats'; const licenseId = generateId(); describe('components/invitation_modal/overage_users_banner_notice', () => { const initialState: DeepPartial<GlobalState> = { entities: { users: { currentUserId: 'current_user', profiles: { current_user: { roles: General.SYSTEM_ADMIN_ROLE, id: 'currentUser', }, }, }, admin: { analytics: { [StatTypes.TOTAL_USERS]: 1, }, }, general: { config: { CWSURL: 'http://testing', }, license: { IsLicensed: 'true', IssuedAt: '1517714643650', StartsAt: '1517714643650', ExpiresAt: '1620335443650', SkuShortName: 'Enterprise', Name: 'LicenseName', Company: 'Mattermost Inc.', Users: String(seatsPurchased), Id: licenseId, }, }, preferences: { myPreferences: {}, }, cloud: { subscriptionStats: { is_expandable: false, getRequestState: 'IDLE', }, }, hostedCustomer: { products: { productsLoaded: true, products: { prod_professional: TestHelper.getProductMock({ id: 'prod_professional', name: 'Professional', sku: SelfHostedProducts.PROFESSIONAL, price_per_seat: 7.5, }), }, }, }, }, }; let windowSpy: jest.SpyInstance; beforeAll(() => { windowSpy = jest.spyOn(window, 'open'); windowSpy.mockImplementation(() => {}); }); afterAll(() => { windowSpy.mockRestore(); }); it('should not render the banner because we are not on overage state', () => { renderWithContext(<OverageUsersBannerNotice/>); expect(screen.queryByText(notifyText, {exact: false})).not.toBeInTheDocument(); }); it('should not render the banner because we are not admins', () => { const store: GlobalState = JSON.parse(JSON.stringify(initialState)); store.entities.users = { ...store.entities.users, profiles: { ...store.entities.users.profiles, current_user: { ...store.entities.users.profiles.current_user, roles: General.SYSTEM_USER_ROLE, }, }, }; renderWithContext( <OverageUsersBannerNotice/>, store, ); expect(screen.queryByText(notifyText, {exact: false})).not.toBeInTheDocument(); }); it('should not render the banner because it\'s cloud licenese', () => { const store: GlobalState = JSON.parse(JSON.stringify(initialState)); store.entities.general.license = { ...store.entities.general.license, Cloud: 'true', }; renderWithContext( <OverageUsersBannerNotice/>, store, ); expect(screen.queryByText(notifyText, {exact: false})).not.toBeInTheDocument(); }); it('should not render the 5% banner because we have dissmised it', () => { const store: GlobalState = JSON.parse(JSON.stringify(initialState)); store.entities.preferences.myPreferences = TestHelper.getPreferencesMock( [ { category: Preferences.OVERAGE_USERS_BANNER, value: 'Overage users banner watched', name: `warn_overage_seats_${licenseId.substring(0, 8)}`, }, ], ); store.entities.admin = { ...store.entities.admin, analytics: { [StatTypes.TOTAL_USERS]: seatsMinimumFor5PercentageState, }, }; renderWithContext( <OverageUsersBannerNotice/>, store, ); expect(screen.queryByText(text5PercentageState)).not.toBeInTheDocument(); }); it('should render the banner because we are over 5% and we don\'t have any preferences', () => { const store: GlobalState = JSON.parse(JSON.stringify(initialState)); store.entities.admin = { ...store.entities.admin, analytics: { [StatTypes.TOTAL_USERS]: seatsMinimumFor5PercentageState, }, }; renderWithContext( <OverageUsersBannerNotice/>, store, ); expect(screen.getByText(text5PercentageState)).toBeInTheDocument(); expect(screen.getByText(notifyText, {exact: false})).toBeInTheDocument(); }); it('should track if the admin click Contact Sales CTA in a 5% overage state', () => { const store: GlobalState = JSON.parse(JSON.stringify(initialState)); store.entities.admin = { ...store.entities.admin, analytics: { [StatTypes.TOTAL_USERS]: seatsMinimumFor5PercentageState, }, }; store.entities.cloud = { ...store.entities.cloud, subscriptionStats: { is_expandable: false, getRequestState: 'OK', }, }; renderWithContext( <OverageUsersBannerNotice/>, store, ); fireEvent.click(screen.getByText(contactSalesTextLink)); expect(screen.getByRole('link')).toHaveAttribute( 'href', LicenseLinks.CONTACT_SALES + '?utm_source=mattermost&utm_medium=in-product&utm_content=&uid=current_user&sid=', ); expect(trackEvent).toBeCalledTimes(2); expect(trackEvent).toBeCalledWith('insights', 'click_true_up_warning', { cta: 'Contact Sales', banner: 'invite modal', }); }); it('should render the banner because we are over 5% and we have preferences from one old banner', () => { const store: GlobalState = JSON.parse(JSON.stringify(initialState)); store.entities.preferences.myPreferences = TestHelper.getPreferencesMock( [ { category: Preferences.OVERAGE_USERS_BANNER, value: 'Overage users banner watched', name: `warn_overage_seats_${generateId().substring(0, 8)}`, }, ], ); store.entities.admin = { ...store.entities.admin, analytics: { [StatTypes.TOTAL_USERS]: seatsMinimumFor5PercentageState, }, }; renderWithContext( <OverageUsersBannerNotice/>, store, ); expect(screen.getByText(text5PercentageState)).toBeInTheDocument(); expect(screen.getByText(notifyText, {exact: false})).toBeInTheDocument(); }); it('should save the preferences for 5% banner if admin click on close', () => { const store: GlobalState = JSON.parse(JSON.stringify(initialState)); store.entities.admin = { ...store.entities.admin, analytics: { [StatTypes.TOTAL_USERS]: seatsMinimumFor5PercentageState, }, }; renderWithContext( <OverageUsersBannerNotice/>, store, ); fireEvent.click(screen.getByRole('button')); expect(savePreferences).toBeCalledTimes(1); expect(savePreferences).toBeCalledWith(store.entities.users.profiles.current_user.id, [{ category: Preferences.OVERAGE_USERS_BANNER, name: `warn_overage_seats_${licenseId.substring(0, 8)}`, user_id: store.entities.users.profiles.current_user.id, value: 'Overage users banner watched', }]); }); it('should render the banner because we are over 10% and we don\'t have preferences', () => { const store: GlobalState = JSON.parse(JSON.stringify(initialState)); store.entities.admin = { ...store.entities.admin, analytics: { [StatTypes.TOTAL_USERS]: seatsMinimumFor10PercentageState, }, }; renderWithContext( <OverageUsersBannerNotice/>, store, ); expect(screen.getByText(text10PercentageState)).toBeInTheDocument(); expect(screen.getByText(notifyText, {exact: false})).toBeInTheDocument(); }); it('should track if the admin click Contact Sales CTA in a 10% overage state', () => { const store: GlobalState = JSON.parse(JSON.stringify(initialState)); store.entities.admin = { ...store.entities.admin, analytics: { [StatTypes.TOTAL_USERS]: seatsMinimumFor10PercentageState, }, }; store.entities.cloud = { ...store.entities.cloud, subscriptionStats: { is_expandable: false, getRequestState: 'OK', }, }; renderWithContext( <OverageUsersBannerNotice/>, store, ); fireEvent.click(screen.getByText(contactSalesTextLink)); expect(screen.getByRole('link')).toHaveAttribute( 'href', LicenseLinks.CONTACT_SALES + '?utm_source=mattermost&utm_medium=in-product&utm_content=&uid=current_user&sid=', ); expect(trackEvent).toBeCalledTimes(2); expect(trackEvent).toBeCalledWith('insights', 'click_true_up_error', { cta: 'Contact Sales', banner: 'invite modal', }); }); it('should render the banner because we are over 10%, and we have preference only for the warning state', () => { const store: GlobalState = JSON.parse(JSON.stringify(initialState)); store.entities.preferences.myPreferences = TestHelper.getPreferencesMock( [ { category: Preferences.OVERAGE_USERS_BANNER, value: 'Overage users banner watched', name: `warn_overage_seats_${licenseId.substring(0, 8)}`, }, ], ); store.entities.admin = { ...store.entities.admin, analytics: { [StatTypes.TOTAL_USERS]: seatsMinimumFor10PercentageState, }, }; renderWithContext( <OverageUsersBannerNotice/>, store, ); expect(screen.getByText(text10PercentageState)).toBeInTheDocument(); expect(screen.getByText(notifyText, {exact: false})).toBeInTheDocument(); }); it('should not render the banner because we are over 10% and we have preferences', () => { const store: GlobalState = JSON.parse(JSON.stringify(initialState)); store.entities.preferences.myPreferences = TestHelper.getPreferencesMock( [ { category: Preferences.OVERAGE_USERS_BANNER, value: 'Overage users banner watched', name: `error_overage_seats_${licenseId.substring(0, 8)}`, }, ], ); store.entities.admin = { ...store.entities.admin, analytics: { [StatTypes.TOTAL_USERS]: seatsMinimumFor10PercentageState, }, }; renderWithContext( <OverageUsersBannerNotice/>, store, ); expect(screen.queryByText(text10PercentageState)).not.toBeInTheDocument(); expect(screen.queryByText(notifyText, {exact: false})).not.toBeInTheDocument(); }); it('should save preferences for the banner because we are over 10% and we don\'t have preferences', () => { const store: GlobalState = JSON.parse(JSON.stringify(initialState)); store.entities.admin = { ...store.entities.admin, analytics: { [StatTypes.TOTAL_USERS]: seatsMinimumFor10PercentageState, }, }; renderWithContext( <OverageUsersBannerNotice/>, store, ); fireEvent.click(screen.getByRole('button')); expect(savePreferences).toBeCalledTimes(1); expect(savePreferences).toBeCalledWith(store.entities.users.profiles.current_user.id, [{ category: Preferences.OVERAGE_USERS_BANNER, name: `error_overage_seats_${licenseId.substring(0, 8)}`, user_id: store.entities.users.profiles.current_user.id, value: 'Overage users banner watched', }]); }); it('should track if the admin click expansion seats CTA in a 5% overage state', () => { const store: GlobalState = JSON.parse(JSON.stringify(initialState)); store.entities.admin = { ...store.entities.admin, analytics: { [StatTypes.TOTAL_USERS]: seatsMinimumFor5PercentageState, }, }; store.entities.cloud = { ...store.entities.cloud, subscriptionStats: { is_expandable: true, getRequestState: 'OK', }, }; renderWithContext( <OverageUsersBannerNotice/>, store, ); fireEvent.click(screen.getByText(expandSeatsTextLink)); expect(screen.getByRole('link')).toHaveAttribute('href', `http://testing/subscribe/expand?licenseId=${licenseId}`); expect(trackEvent).toBeCalledTimes(2); expect(trackEvent).toBeCalledWith('insights', 'click_true_up_warning', { cta: 'Self Serve', banner: 'invite modal', }); }); it('should track if the admin click expansion seats CTA in a 10% overage state', () => { const store: GlobalState = JSON.parse(JSON.stringify(initialState)); store.entities.admin = { ...store.entities.admin, analytics: { [StatTypes.TOTAL_USERS]: seatsMinimumFor10PercentageState, }, }; store.entities.cloud = { ...store.entities.cloud, subscriptionStats: { is_expandable: true, getRequestState: 'OK', }, }; renderWithContext( <OverageUsersBannerNotice/>, store, ); fireEvent.click(screen.getByText(expandSeatsTextLink)); expect(screen.getByRole('link')).toHaveAttribute('href', `http://testing/subscribe/expand?licenseId=${licenseId}`); expect(trackEvent).toBeCalledTimes(2); expect(trackEvent).toBeCalledWith('insights', 'click_true_up_error', { cta: 'Self Serve', banner: 'invite modal', }); }); it('gov sku sees overage notice but not a call to do true up', async () => { const store: GlobalState = JSON.parse(JSON.stringify(initialState)); store.entities.admin = { ...store.entities.admin, analytics: { [StatTypes.TOTAL_USERS]: seatsMinimumFor10PercentageState, }, }; store.entities.cloud = { ...store.entities.cloud, subscriptionStats: { is_expandable: false, getRequestState: 'OK', }, }; store.entities.general.license.IsGovSku = 'true'; renderWithContext( <OverageUsersBannerNotice/>, store, ); screen.getByText(text10PercentageState); expect(screen.queryByText(notifyText)).not.toBeInTheDocument(); }); });
2,490
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/keyboard_shortcuts
petrpan-code/mattermost/mattermost/webapp/channels/src/components/keyboard_shortcuts/keyboard_shortcuts_modal/keyboard_shortcuts_modal.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import * as redux from 'react-redux'; import KeyboardShortcutsModal from 'components/keyboard_shortcuts/keyboard_shortcuts_modal/keyboard_shortcuts_modal'; import mockStore from 'tests/test_store'; import {suitePluginIds} from 'utils/constants'; describe('components/KeyboardShortcutsModal', () => { const initialState = { plugins: { plugins: {}, }, }; test('should match snapshot modal', async () => { const store = await mockStore(initialState); jest.spyOn(redux, 'useSelector').mockImplementation((cb) => cb(store.getState())); const wrapper = shallow( <KeyboardShortcutsModal onExited={jest.fn()}/>, ); expect(wrapper).toMatchSnapshot(); }); test('should match snapshot modal with Calls enabled', async () => { const store = await mockStore({ ...initialState, plugins: { ...initialState.plugins, plugins: { ...initialState.plugins.plugins, [suitePluginIds.calls]: { id: suitePluginIds.calls, version: '0.15.0', }, }, }, }); jest.spyOn(redux, 'useSelector').mockImplementation((cb) => cb(store.getState())); const wrapper = shallow( <KeyboardShortcutsModal onExited={jest.fn()}/>, ); expect(wrapper).toMatchSnapshot(); }); });
2,492
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/keyboard_shortcuts/keyboard_shortcuts_modal
petrpan-code/mattermost/mattermost/webapp/channels/src/components/keyboard_shortcuts/keyboard_shortcuts_modal/__snapshots__/keyboard_shortcuts_modal.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/KeyboardShortcutsModal should match snapshot modal 1`] = ` <Modal animation={true} aria-labelledby="shortcutsModalLabel" autoFocus={true} backdrop={true} bsClass="modal" dialogClassName="a11y__modal shortcuts-modal" dialogComponentClass={[Function]} enforceFocus={true} keyboard={true} manager={ ModalManager { "add": [Function], "containers": Array [], "data": Array [], "handleContainerOverflow": true, "hideSiblingNodes": true, "isTopModal": [Function], "modals": Array [], "remove": [Function], } } onExited={[MockFunction]} onHide={[Function]} renderBackdrop={[Function]} restoreFocus={true} role="dialog" show={true} > <div className="shortcuts-content" > <ModalHeader bsClass="modal-header" closeButton={true} closeLabel="Close" > <ModalTitle bsClass="modal-title" componentClass="h1" id="shortcutsModalLabel" > <strong> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Keyboard shortcuts Ctrl|/", "id": "shortcuts.header", }, "mac": Object { "defaultMessage": "Keyboard shortcuts ⌘|/", "id": "shortcuts.header.mac", }, } } /> </strong> </ModalTitle> </ModalHeader> <ModalBody bsClass="modal-body" componentClass="div" > <div className="row" > <div className="col-sm-4" > <div className="section" > <div> <h3 className="section-title" > <strong> Navigation </strong> </h3> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Previous channel: Alt|Up", "id": "shortcuts.nav.prev", }, "mac": Object { "defaultMessage": "Previous channel: ⌥|Up", "id": "shortcuts.nav.prev.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Next channel: Alt|Down", "id": "shortcuts.nav.next", }, "mac": Object { "defaultMessage": "Next channel: ⌥|Down", "id": "shortcuts.nav.next.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Previous unread channel: Alt|Shift|Up", "id": "shortcuts.nav.unread_prev", }, "mac": Object { "defaultMessage": "Previous unread channel: ⌥|Shift|Up", "id": "shortcuts.nav.unread_prev.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Next unread channel: Alt|Shift|Down", "id": "shortcuts.nav.unread_next", }, "mac": Object { "defaultMessage": "Next unread channel: ⌥|Shift|Down", "id": "shortcuts.nav.unread_next.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Previous team: Ctrl|Alt|Up", "id": "shortcuts.team_nav.prev", }, "mac": Object { "defaultMessage": "Previous team: ⌘|⌥|Up", "id": "shortcuts.team_nav.prev.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Next team: Ctrl|Alt|Down", "id": "shortcuts.team_nav.next", }, "mac": Object { "defaultMessage": "Next team: ⌘|⌥|Down", "id": "shortcuts.team_nav.next.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Navigate to a specific team: Ctrl|Alt|[1-9]", "id": "shortcuts.team_nav.switcher", }, "mac": Object { "defaultMessage": "Navigate to a specific team: ⌘|⌥|[1-9]", "id": "shortcuts.team_nav.switcher.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Quick channel navigation: Ctrl|K", "id": "shortcuts.nav.switcher", }, "mac": Object { "defaultMessage": "Quick channel navigation: ⌘|K", "id": "shortcuts.nav.switcher.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Direct messages menu: Ctrl|Shift|K", "id": "shortcuts.nav.direct_messages_menu", }, "mac": Object { "defaultMessage": "Direct messages menu: ⌘|Shift|K", "id": "shortcuts.nav.direct_messages_menu.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Settings: Ctrl|Shift|A", "id": "shortcuts.nav.settings", }, "mac": Object { "defaultMessage": "Settings: ⌘|Shift|A", "id": "shortcuts.nav.settings.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Recent mentions: Ctrl|Shift|M", "id": "shortcuts.nav.recent_mentions", }, "mac": Object { "defaultMessage": "Recent mentions: ⌘|Shift|M", "id": "shortcuts.nav.recent_mentions.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Set focus to input field: Ctrl|Shift|L", "id": "shortcuts.nav.focus_center", }, "mac": Object { "defaultMessage": "Set focus to input field: ⌘|Shift|L", "id": "shortcuts.nav.focus_center.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Open or close the right sidebar: Ctrl|.", "id": "shortcuts.nav.open_close_sidebar", }, "mac": Object { "defaultMessage": "Open or close the right sidebar: ⌘|.", "id": "shortcuts.nav.open_close_sidebar.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Expand the right sidebar: Ctrl|Shift|.", "id": "shortcuts.nav.expand_sidebar", }, "mac": Object { "defaultMessage": "Expand the right sidebar: ⌘|Shift|.", "id": "shortcuts.nav.expand_sidebar.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "View channel info: Ctrl|Alt|I", "id": "shortcuts.nav.open_channel_info", }, "mac": Object { "defaultMessage": "View channel info: ⌘|Shift|I", "id": "shortcuts.nav.open_channel_info.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Toggle unread/all channels: Ctrl|Shift|U", "id": "shortcuts.nav.toggle_unreads", }, "mac": Object { "defaultMessage": "Toggle unread/all channels: ⌘|Shift|U", "id": "shortcuts.nav.toggle_unreads.mac", }, } } /> </div> </div> </div> <div className="col-sm-4" > <div className="section" > <div> <h3 className="section-title" > <strong> Messages </strong> </h3> <span> <strong> Works inside an empty input field </strong> </span> <div className="subsection" > <Memo(KeyboardShortcutSequence) shortcut={ Object { "defaultMessage": "Edit last message in channel: Up", "id": "shortcuts.msgs.edit", } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "defaultMessage": "Reply to last message in channel: Shift|Up", "id": "shortcuts.msgs.reply", } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "React to last message: Ctrl|Shift|⧵", "id": "shortcuts.msgs.comp.last_reaction", }, "mac": Object { "defaultMessage": "React to last message: ⌘|Shift|⧵", "id": "shortcuts.msgs.comp.last_reaction.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Reprint previous message: Ctrl|Up", "id": "shortcuts.msgs.reprint_prev", }, "mac": Object { "defaultMessage": "Reprint previous message: ⌘|Up", "id": "shortcuts.msgs.reprint_prev.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Reprint next message: Ctrl|Down", "id": "shortcuts.msgs.reprint_next", }, "mac": Object { "defaultMessage": "Reprint next message: ⌘|Down", "id": "shortcuts.msgs.reprint_next.mac", }, } } /> </div> <span> <strong> Autocomplete </strong> </span> <div className="subsection" > <Memo(KeyboardShortcutSequence) shortcut={ Object { "defaultMessage": "Username: @|[a-z]|Tab", "id": "shortcuts.msgs.comp.username", } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "defaultMessage": "Channel: ~|[a-z]|Tab", "id": "shortcuts.msgs.comp.channel", } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "defaultMessage": "Emoji: :|[a-z]|Tab", "id": "shortcuts.msgs.comp.emoji", } } /> </div> <span> <strong> Formatting </strong> </span> <div className="subsection" > <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Bold: Ctrl|B", "id": "shortcuts.msgs.markdown.bold", }, "mac": Object { "defaultMessage": "Bold: ⌘|B", "id": "shortcuts.msgs.markdown.bold.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Italic: Ctrl|I", "id": "shortcuts.msgs.markdown.italic", }, "mac": Object { "defaultMessage": "Italic: ⌘|I", "id": "shortcuts.msgs.markdown.italic.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Link: Ctrl|Alt|K", "id": "shortcuts.msgs.markdown.link", }, "mac": Object { "defaultMessage": "Link: ⌘|⌥|K", "id": "shortcuts.msgs.markdown.link.mac", }, } } /> </div> <span> <strong> Searching </strong> </span> <div className="subsection" > <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "In channel: Ctrl|F", "id": "shortcuts.msgs.search_channel", }, "mac": Object { "defaultMessage": "In channel: ⌘|F", "id": "shortcuts.msgs.search_channel.mac", }, } } /> </div> </div> </div> </div> <div className="col-sm-4" > <div className="section" > <div> <h3 className="section-title" > <strong> Files </strong> </h3> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Upload files: Ctrl|U", "id": "shortcuts.files.upload", }, "mac": Object { "defaultMessage": "Upload files: ⌘|U", "id": "shortcuts.files.upload.mac", }, } } /> </div> <div className="section--lower" > <h3 className="section-title" > <strong> Built-in Browser Commands </strong> </h3> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Back in history: Alt|Left", "id": "shortcuts.browser.channel_prev", }, "mac": Object { "defaultMessage": "Back in history: ⌘|[", "id": "shortcuts.browser.channel_prev.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Forward in history: Alt|Right", "id": "shortcuts.browser.channel_next", }, "mac": Object { "defaultMessage": "Forward in history: ⌘|]", "id": "shortcuts.browser.channel_next.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Zoom in: Ctrl|+", "id": "shortcuts.browser.font_increase", }, "mac": Object { "defaultMessage": "Zoom in: ⌘|+", "id": "shortcuts.browser.font_increase.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Zoom out: Ctrl|-", "id": "shortcuts.browser.font_decrease", }, "mac": Object { "defaultMessage": "Zoom out: ⌘|-", "id": "shortcuts.browser.font_decrease.mac", }, } } /> <span> <strong> Works inside an input field </strong> </span> <div className="subsection" > <Memo(KeyboardShortcutSequence) shortcut={ Object { "defaultMessage": "Highlight text to the previous line: Shift|Up", "id": "shortcuts.browser.highlight_prev", } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "defaultMessage": "Highlight text to the next line: Shift|Down", "id": "shortcuts.browser.highlight_next", } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "defaultMessage": "Create a new line: Shift|Enter", "id": "shortcuts.browser.newline", } } /> </div> </div> </div> </div> </div> <div className="info__label" > Begin a message with / for a list of all the available slash commands. </div> </ModalBody> </div> </Modal> `; exports[`components/KeyboardShortcutsModal should match snapshot modal with Calls enabled 1`] = ` <Modal animation={true} aria-labelledby="shortcutsModalLabel" autoFocus={true} backdrop={true} bsClass="modal" dialogClassName="a11y__modal shortcuts-modal" dialogComponentClass={[Function]} enforceFocus={true} keyboard={true} manager={ ModalManager { "add": [Function], "containers": Array [], "data": Array [], "handleContainerOverflow": true, "hideSiblingNodes": true, "isTopModal": [Function], "modals": Array [], "remove": [Function], } } onExited={[MockFunction]} onHide={[Function]} renderBackdrop={[Function]} restoreFocus={true} role="dialog" show={true} > <div className="shortcuts-content" > <ModalHeader bsClass="modal-header" closeButton={true} closeLabel="Close" > <ModalTitle bsClass="modal-title" componentClass="h1" id="shortcutsModalLabel" > <strong> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Keyboard shortcuts Ctrl|/", "id": "shortcuts.header", }, "mac": Object { "defaultMessage": "Keyboard shortcuts ⌘|/", "id": "shortcuts.header.mac", }, } } /> </strong> </ModalTitle> </ModalHeader> <ModalBody bsClass="modal-body" componentClass="div" > <div className="row" > <div className="col-sm-4" > <div className="section" > <div> <h3 className="section-title" > <strong> Navigation </strong> </h3> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Previous channel: Alt|Up", "id": "shortcuts.nav.prev", }, "mac": Object { "defaultMessage": "Previous channel: ⌥|Up", "id": "shortcuts.nav.prev.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Next channel: Alt|Down", "id": "shortcuts.nav.next", }, "mac": Object { "defaultMessage": "Next channel: ⌥|Down", "id": "shortcuts.nav.next.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Previous unread channel: Alt|Shift|Up", "id": "shortcuts.nav.unread_prev", }, "mac": Object { "defaultMessage": "Previous unread channel: ⌥|Shift|Up", "id": "shortcuts.nav.unread_prev.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Next unread channel: Alt|Shift|Down", "id": "shortcuts.nav.unread_next", }, "mac": Object { "defaultMessage": "Next unread channel: ⌥|Shift|Down", "id": "shortcuts.nav.unread_next.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Previous team: Ctrl|Alt|Up", "id": "shortcuts.team_nav.prev", }, "mac": Object { "defaultMessage": "Previous team: ⌘|⌥|Up", "id": "shortcuts.team_nav.prev.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Next team: Ctrl|Alt|Down", "id": "shortcuts.team_nav.next", }, "mac": Object { "defaultMessage": "Next team: ⌘|⌥|Down", "id": "shortcuts.team_nav.next.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Navigate to a specific team: Ctrl|Alt|[1-9]", "id": "shortcuts.team_nav.switcher", }, "mac": Object { "defaultMessage": "Navigate to a specific team: ⌘|⌥|[1-9]", "id": "shortcuts.team_nav.switcher.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Quick channel navigation: Ctrl|K", "id": "shortcuts.nav.switcher", }, "mac": Object { "defaultMessage": "Quick channel navigation: ⌘|K", "id": "shortcuts.nav.switcher.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Direct messages menu: Ctrl|Shift|K", "id": "shortcuts.nav.direct_messages_menu", }, "mac": Object { "defaultMessage": "Direct messages menu: ⌘|Shift|K", "id": "shortcuts.nav.direct_messages_menu.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Settings: Ctrl|Shift|A", "id": "shortcuts.nav.settings", }, "mac": Object { "defaultMessage": "Settings: ⌘|Shift|A", "id": "shortcuts.nav.settings.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Recent mentions: Ctrl|Shift|M", "id": "shortcuts.nav.recent_mentions", }, "mac": Object { "defaultMessage": "Recent mentions: ⌘|Shift|M", "id": "shortcuts.nav.recent_mentions.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Set focus to input field: Ctrl|Shift|L", "id": "shortcuts.nav.focus_center", }, "mac": Object { "defaultMessage": "Set focus to input field: ⌘|Shift|L", "id": "shortcuts.nav.focus_center.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Open or close the right sidebar: Ctrl|.", "id": "shortcuts.nav.open_close_sidebar", }, "mac": Object { "defaultMessage": "Open or close the right sidebar: ⌘|.", "id": "shortcuts.nav.open_close_sidebar.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Expand the right sidebar: Ctrl|Shift|.", "id": "shortcuts.nav.expand_sidebar", }, "mac": Object { "defaultMessage": "Expand the right sidebar: ⌘|Shift|.", "id": "shortcuts.nav.expand_sidebar.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "View channel info: Ctrl|Alt|I", "id": "shortcuts.nav.open_channel_info", }, "mac": Object { "defaultMessage": "View channel info: ⌘|Shift|I", "id": "shortcuts.nav.open_channel_info.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Toggle unread/all channels: Ctrl|Shift|U", "id": "shortcuts.nav.toggle_unreads", }, "mac": Object { "defaultMessage": "Toggle unread/all channels: ⌘|Shift|U", "id": "shortcuts.nav.toggle_unreads.mac", }, } } /> </div> </div> </div> <div className="col-sm-4" > <div className="section" > <div> <h3 className="section-title" > <strong> Messages </strong> </h3> <span> <strong> Works inside an empty input field </strong> </span> <div className="subsection" > <Memo(KeyboardShortcutSequence) shortcut={ Object { "defaultMessage": "Edit last message in channel: Up", "id": "shortcuts.msgs.edit", } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "defaultMessage": "Reply to last message in channel: Shift|Up", "id": "shortcuts.msgs.reply", } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "React to last message: Ctrl|Shift|⧵", "id": "shortcuts.msgs.comp.last_reaction", }, "mac": Object { "defaultMessage": "React to last message: ⌘|Shift|⧵", "id": "shortcuts.msgs.comp.last_reaction.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Reprint previous message: Ctrl|Up", "id": "shortcuts.msgs.reprint_prev", }, "mac": Object { "defaultMessage": "Reprint previous message: ⌘|Up", "id": "shortcuts.msgs.reprint_prev.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Reprint next message: Ctrl|Down", "id": "shortcuts.msgs.reprint_next", }, "mac": Object { "defaultMessage": "Reprint next message: ⌘|Down", "id": "shortcuts.msgs.reprint_next.mac", }, } } /> </div> <span> <strong> Autocomplete </strong> </span> <div className="subsection" > <Memo(KeyboardShortcutSequence) shortcut={ Object { "defaultMessage": "Username: @|[a-z]|Tab", "id": "shortcuts.msgs.comp.username", } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "defaultMessage": "Channel: ~|[a-z]|Tab", "id": "shortcuts.msgs.comp.channel", } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "defaultMessage": "Emoji: :|[a-z]|Tab", "id": "shortcuts.msgs.comp.emoji", } } /> </div> <span> <strong> Formatting </strong> </span> <div className="subsection" > <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Bold: Ctrl|B", "id": "shortcuts.msgs.markdown.bold", }, "mac": Object { "defaultMessage": "Bold: ⌘|B", "id": "shortcuts.msgs.markdown.bold.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Italic: Ctrl|I", "id": "shortcuts.msgs.markdown.italic", }, "mac": Object { "defaultMessage": "Italic: ⌘|I", "id": "shortcuts.msgs.markdown.italic.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Link: Ctrl|Alt|K", "id": "shortcuts.msgs.markdown.link", }, "mac": Object { "defaultMessage": "Link: ⌘|⌥|K", "id": "shortcuts.msgs.markdown.link.mac", }, } } /> </div> <span> <strong> Searching </strong> </span> <div className="subsection" > <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "In channel: Ctrl|F", "id": "shortcuts.msgs.search_channel", }, "mac": Object { "defaultMessage": "In channel: ⌘|F", "id": "shortcuts.msgs.search_channel.mac", }, } } /> </div> </div> </div> </div> <div className="col-sm-4" > <div className="section" > <div> <h3 className="section-title" > <strong> Files </strong> </h3> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Upload files: Ctrl|U", "id": "shortcuts.files.upload", }, "mac": Object { "defaultMessage": "Upload files: ⌘|U", "id": "shortcuts.files.upload.mac", }, } } /> </div> <div className="section--lower" > <h3 className="section-title" > <strong> Built-in Browser Commands </strong> </h3> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Back in history: Alt|Left", "id": "shortcuts.browser.channel_prev", }, "mac": Object { "defaultMessage": "Back in history: ⌘|[", "id": "shortcuts.browser.channel_prev.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Forward in history: Alt|Right", "id": "shortcuts.browser.channel_next", }, "mac": Object { "defaultMessage": "Forward in history: ⌘|]", "id": "shortcuts.browser.channel_next.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Zoom in: Ctrl|+", "id": "shortcuts.browser.font_increase", }, "mac": Object { "defaultMessage": "Zoom in: ⌘|+", "id": "shortcuts.browser.font_increase.mac", }, } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "default": Object { "defaultMessage": "Zoom out: Ctrl|-", "id": "shortcuts.browser.font_decrease", }, "mac": Object { "defaultMessage": "Zoom out: ⌘|-", "id": "shortcuts.browser.font_decrease.mac", }, } } /> <span> <strong> Works inside an input field </strong> </span> <div className="subsection" > <Memo(KeyboardShortcutSequence) shortcut={ Object { "defaultMessage": "Highlight text to the previous line: Shift|Up", "id": "shortcuts.browser.highlight_prev", } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "defaultMessage": "Highlight text to the next line: Shift|Down", "id": "shortcuts.browser.highlight_next", } } /> <Memo(KeyboardShortcutSequence) shortcut={ Object { "defaultMessage": "Create a new line: Shift|Enter", "id": "shortcuts.browser.newline", } } /> </div> </div> </div> </div> </div> <div className="row" > <div className="col-sm-4" > <div className="section" > <div> <h3 className="section-title" > <strong> Calls </strong> </h3> <span> <strong> Global </strong> </span> <div className="subsection" > <Memo(KeyboardShortcutSequence) key="callsJoinCall" shortcut={ Object { "default": Object { "defaultMessage": "Join call in current channel: Ctrl|Alt|S", "id": "shortcuts.calls.join_call", }, "mac": Object { "defaultMessage": "Join call in current channel: ⌘|⌥|S", "id": "shortcuts.calls.join_call.mac", }, } } /> </div> <span> <strong> Call widget </strong> </span> <div className="subsection" > <Memo(KeyboardShortcutSequence) key="callsMuteToggle" shortcut={ Object { "default": Object { "defaultMessage": "Mute or unmute: Ctrl|Shift|Space", "id": "shortcuts.calls.mute_toggle", }, "mac": Object { "defaultMessage": "Mute or unmute: ⌘|Shift|Space", "id": "shortcuts.calls.mute_toggle.mac", }, } } /> <Memo(KeyboardShortcutSequence) key="callsRaiseHandToggle" shortcut={ Object { "default": Object { "defaultMessage": "Raise or lower hand: Ctrl|Shift|Y", "id": "shortcuts.calls.raise_hand_toggle", }, "mac": Object { "defaultMessage": "Raise or lower hand: ⌘|Shift|Y", "id": "shortcuts.calls.raise_hand_toggle.mac", }, } } /> <Memo(KeyboardShortcutSequence) key="callsShareScreenToggle" shortcut={ Object { "default": Object { "defaultMessage": "Share or unshare the screen: Ctrl|Shift|E", "id": "shortcuts.calls.share_screen_toggle", }, "mac": Object { "defaultMessage": "Share or unshare the screen: ⌘|Shift|E", "id": "shortcuts.calls.share_screen_toggle.mac", }, } } /> <Memo(KeyboardShortcutSequence) key="callsParticipantsListToggle" shortcut={ Object { "default": Object { "defaultMessage": "Show or hide participants list: Alt|P Ctrl|Shift|P", "id": "shortcuts.calls.participants_list_toggle", }, "mac": Object { "defaultMessage": "Show or hide participants list: ⌥|P ⌘|Shift|P", "id": "shortcuts.calls.participants_list_toggle.mac", }, } } /> <Memo(KeyboardShortcutSequence) key="callsLeaveCall" shortcut={ Object { "default": Object { "defaultMessage": "Leave current call: Ctrl|Shift|L", "id": "shortcuts.calls.leave_call", }, "mac": Object { "defaultMessage": "Leave current call: ⌘|Shift|L", "id": "shortcuts.calls.leave_call.mac", }, } } /> </div> <span> <strong> Expanded view (pop-out window) </strong> </span> <div className="subsection" > <Memo(KeyboardShortcutSequence) key="callsPushToTalk" shortcut={ Object { "default": Object { "defaultMessage": "Hold to unmute (push to talk): Space", "id": "shortcuts.calls.push_to_talk", }, } } /> </div> </div> </div> </div> </div> <div className="info__label" > Begin a message with / for a list of all the available slash commands. </div> </ModalBody> </div> </Modal> `;
2,496
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/keyboard_shortcuts
petrpan-code/mattermost/mattermost/webapp/channels/src/components/keyboard_shortcuts/keyboard_shortcuts_sequence/keyboard_shortcuts_sequence.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import React from 'react'; import {mountWithIntl} from 'tests/helpers/intl-test-helper'; import KeyboardShortcutsSequence from './keyboard_shortcuts_sequence'; import KeyboardShortcutSequence, {KEYBOARD_SHORTCUTS} from './index'; describe('components/shortcuts/KeyboardShortcutsSequence', () => { test('should match snapshot when used for modal with description', () => { const wrapper = mountWithIntl( <KeyboardShortcutsSequence shortcut={{ id: 'test', defaultMessage: 'Keyboard shortcuts\t⌘|/', }} />, ); const tag = <span>{'Keyboard shortcuts'}</span>; expect(wrapper.contains(tag)).toEqual(true); expect(wrapper).toMatchSnapshot(); expect(wrapper.find('.shortcut-key--tooltip')).toHaveLength(0); expect(wrapper.find('.shortcut-key--shortcut-modal')).toHaveLength(2); }); test('should render sequence without description', () => { const wrapper = mountWithIntl( <KeyboardShortcutsSequence shortcut={{ id: 'test', defaultMessage: 'Keyboard shortcuts\t⌘|/', }} hideDescription={true} />, ); const tag = <span>{'Keyboard shortcuts'}</span>; expect(wrapper.contains(tag)).toEqual(false); expect(wrapper).toMatchSnapshot(); }); test('should match snapshot with alternative shortcut', () => { const wrapper = mountWithIntl( <KeyboardShortcutsSequence shortcut={{ id: 'test', defaultMessage: 'Keyboard shortcuts\t⌘||P\tCtrl|P', }} />, ); const tag = <span>{'Keyboard shortcuts'}</span>; expect(wrapper.contains(tag)).toEqual(true); expect(wrapper).toMatchSnapshot(); expect(wrapper.find('.shortcut-key--tooltip')).toHaveLength(0); expect(wrapper.find('.shortcut-key--shortcut-modal')).toHaveLength(5); }); test('should render sequence without description', () => { const wrapper = mountWithIntl( <KeyboardShortcutsSequence shortcut={{ id: 'test', defaultMessage: 'Keyboard shortcuts\t⌘|/', }} isInsideTooltip={true} />, ); const tag = <span>{'Keyboard shortcuts'}</span>; expect(wrapper.contains(tag)).toEqual(true); expect(wrapper).toMatchSnapshot(); expect(wrapper.find('.shortcut-key--tooltip')).toHaveLength(2); expect(wrapper.find('.shortcut-key--shortcut-modal')).toHaveLength(0); }); test('should render sequence hoisting description', () => { const wrapper = mountWithIntl( <KeyboardShortcutsSequence shortcut={{ id: 'test', defaultMessage: 'Keyboard shortcuts\t⌘|/', }} isInsideTooltip={true} hoistDescription={true} />, ); const tag = <span>{'Keyboard shortcuts'}</span>; expect(wrapper.contains(tag)).toEqual(false); expect(wrapper).toMatchSnapshot(); expect(wrapper.find('.shortcut-key--tooltip')).toHaveLength(2); expect(wrapper.find('.shortcut-key--shortcut-modal')).toHaveLength(0); }); test('should create sequence with order', () => { const order = 3; const wrapper = mountWithIntl( <KeyboardShortcutSequence shortcut={KEYBOARD_SHORTCUTS.teamNavigation} values={{order}} hideDescription={true} isInsideTooltip={true} />, ); expect(wrapper).toMatchSnapshot(); const tag = <span>{'Keyboard shortcuts'}</span>; expect(wrapper.contains(tag)).toEqual(false); expect(wrapper.find('.shortcut-key--tooltip')).toHaveLength(3); expect(wrapper.find('.shortcut-key--shortcut-modal')).toHaveLength(0); }); });
2,498
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/keyboard_shortcuts/keyboard_shortcuts_sequence
petrpan-code/mattermost/mattermost/webapp/channels/src/components/keyboard_shortcuts/keyboard_shortcuts_sequence/__snapshots__/keyboard_shortcuts_sequence.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/shortcuts/KeyboardShortcutsSequence should create sequence with order 1`] = ` <Memo(KeyboardShortcutSequence) hideDescription={true} isInsideTooltip={true} shortcut={ Object { "default": Object { "defaultMessage": "Ctrl|Alt|{order}", "id": "team.button.tooltip", }, "mac": Object { "defaultMessage": "⌘|⌥|{order}", "id": "team.button.tooltip.mac", }, } } values={ Object { "order": 3, } } > <div className="shortcut-line" > <ShortcutKey key="Ctrl" variant="tooltip" > <mark className="shortcut-key shortcut-key--tooltip" > Ctrl </mark> </ShortcutKey> <ShortcutKey key="Alt" variant="tooltip" > <mark className="shortcut-key shortcut-key--tooltip" > Alt </mark> </ShortcutKey> <ShortcutKey key="3" variant="tooltip" > <mark className="shortcut-key shortcut-key--tooltip" > 3 </mark> </ShortcutKey> </div> </Memo(KeyboardShortcutSequence)> `; exports[`components/shortcuts/KeyboardShortcutsSequence should match snapshot when used for modal with description 1`] = ` <Memo(KeyboardShortcutSequence) shortcut={ Object { "defaultMessage": "Keyboard shortcuts ⌘|/", "id": "test", } } > <div className="shortcut-line" > <span> Keyboard shortcuts </span> <ShortcutKey key="⌘" variant="shortcut" > <mark className="shortcut-key shortcut-key--shortcut-modal" > ⌘ </mark> </ShortcutKey> <ShortcutKey key="/" variant="shortcut" > <mark className="shortcut-key shortcut-key--shortcut-modal" > / </mark> </ShortcutKey> </div> </Memo(KeyboardShortcutSequence)> `; exports[`components/shortcuts/KeyboardShortcutsSequence should match snapshot with alternative shortcut 1`] = ` <Memo(KeyboardShortcutSequence) shortcut={ Object { "defaultMessage": "Keyboard shortcuts ⌘||P Ctrl|P", "id": "test", } } > <div className="shortcut-line" > <span> Keyboard shortcuts </span> <ShortcutKey key="⌘" variant="shortcut" > <mark className="shortcut-key shortcut-key--shortcut-modal" > ⌘ </mark> </ShortcutKey> <ShortcutKey key="" variant="shortcut" > <mark className="shortcut-key shortcut-key--shortcut-modal" /> </ShortcutKey> <ShortcutKey key="P" variant="shortcut" > <mark className="shortcut-key shortcut-key--shortcut-modal" > P </mark> </ShortcutKey> <span> | </span> <ShortcutKey key="Ctrl" variant="shortcut" > <mark className="shortcut-key shortcut-key--shortcut-modal" > Ctrl </mark> </ShortcutKey> <ShortcutKey key="P" variant="shortcut" > <mark className="shortcut-key shortcut-key--shortcut-modal" > P </mark> </ShortcutKey> </div> </Memo(KeyboardShortcutSequence)> `; exports[`components/shortcuts/KeyboardShortcutsSequence should render sequence hoisting description 1`] = ` <Memo(KeyboardShortcutSequence) hoistDescription={true} isInsideTooltip={true} shortcut={ Object { "defaultMessage": "Keyboard shortcuts ⌘|/", "id": "test", } } > Keyboard shortcuts <div className="shortcut-line" > <ShortcutKey key="⌘" variant="tooltip" > <mark className="shortcut-key shortcut-key--tooltip" > ⌘ </mark> </ShortcutKey> <ShortcutKey key="/" variant="tooltip" > <mark className="shortcut-key shortcut-key--tooltip" > / </mark> </ShortcutKey> </div> </Memo(KeyboardShortcutSequence)> `; exports[`components/shortcuts/KeyboardShortcutsSequence should render sequence without description 1`] = ` <Memo(KeyboardShortcutSequence) hideDescription={true} shortcut={ Object { "defaultMessage": "Keyboard shortcuts ⌘|/", "id": "test", } } > <div className="shortcut-line" > <ShortcutKey key="⌘" variant="shortcut" > <mark className="shortcut-key shortcut-key--shortcut-modal" > ⌘ </mark> </ShortcutKey> <ShortcutKey key="/" variant="shortcut" > <mark className="shortcut-key shortcut-key--shortcut-modal" > / </mark> </ShortcutKey> </div> </Memo(KeyboardShortcutSequence)> `; exports[`components/shortcuts/KeyboardShortcutsSequence should render sequence without description 2`] = ` <Memo(KeyboardShortcutSequence) isInsideTooltip={true} shortcut={ Object { "defaultMessage": "Keyboard shortcuts ⌘|/", "id": "test", } } > <div className="shortcut-line" > <span> Keyboard shortcuts </span> <ShortcutKey key="⌘" variant="tooltip" > <mark className="shortcut-key shortcut-key--tooltip" > ⌘ </mark> </ShortcutKey> <ShortcutKey key="/" variant="tooltip" > <mark className="shortcut-key shortcut-key--tooltip" > / </mark> </ShortcutKey> </div> </Memo(KeyboardShortcutSequence)> `;
2,500
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components
petrpan-code/mattermost/mattermost/webapp/channels/src/components/latex_block/latex_block.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import LatexBlock from 'components/latex_block/latex_block'; describe('components/LatexBlock', () => { const defaultProps = { content: '```latex e^{i\\pi} + 1 = 0```', enableLatex: true, }; test('should match snapshot', async () => { const wrapper = shallow(<LatexBlock {...defaultProps}/>); await import('katex'); //manually import katex expect(wrapper).toMatchSnapshot(); }); test('latex is disabled', async () => { const props = { ...defaultProps, enableLatex: false, }; const wrapper = shallow(<LatexBlock {...props}/>); await import('katex'); //manually import katex expect(wrapper).toMatchSnapshot(); }); test('error in katex', async () => { const props = { content: '```latex e^{i\\pi + 1 = 0```', enableLatex: true, }; const wrapper = shallow(<LatexBlock {...props}/>); await import('katex'); //manually import katex expect(wrapper).toMatchSnapshot(); }); });
2,502
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/latex_block
petrpan-code/mattermost/mattermost/webapp/channels/src/components/latex_block/__snapshots__/latex_block.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/LatexBlock error in katex 1`] = ` <div className="post-body--code tex" dangerouslySetInnerHTML={ Object { "__html": "<span class=\\"katex-error\\" title=\\"ParseError: KaTeX parse error: Expected &#x27;}&#x27;, got &#x27;EOF&#x27; at end of input: …i\\\\pi + 1 = 0\`\`\`\\" style=\\"color:#cc0000\\">\`\`\`latex e^{i\\\\pi + 1 = 0\`\`\`</span>", } } /> `; exports[`components/LatexBlock latex is disabled 1`] = ` <div className="post-body--code tex" > \`\`\`latex e^{i\\pi} + 1 = 0\`\`\` </div> `; exports[`components/LatexBlock should match snapshot 1`] = ` <div className="post-body--code tex" dangerouslySetInnerHTML={ Object { "__html": "<span class=\\"katex-display fleqn\\"><span class=\\"katex\\"><span class=\\"katex-mathml\\"><math xmlns=\\"http://www.w3.org/1998/Math/MathML\\" display=\\"block\\"><semantics><mrow><mi mathvariant=\\"normal\\">‘</mi><mi mathvariant=\\"normal\\">‘</mi><mi mathvariant=\\"normal\\">‘</mi><mi>l</mi><mi>a</mi><mi>t</mi><mi>e</mi><mi>x</mi><msup><mi>e</mi><mrow><mi>i</mi><mi>π</mi></mrow></msup><mo>+</mo><mn>1</mn><mo>=</mo><mn>0</mn><mi mathvariant=\\"normal\\">‘</mi><mi mathvariant=\\"normal\\">‘</mi><mi mathvariant=\\"normal\\">‘</mi></mrow><annotation encoding=\\"application/x-tex\\">\`\`\`latex e^{i\\\\pi} + 1 = 0\`\`\`</annotation></semantics></math></span><span class=\\"katex-html\\" aria-hidden=\\"true\\"><span class=\\"base\\"><span class=\\"strut\\" style=\\"height:0.958em;vertical-align:-0.0833em;\\"></span><span class=\\"mord\\">‘‘‘</span><span class=\\"mord mathnormal\\" style=\\"margin-right:0.01968em;\\">l</span><span class=\\"mord mathnormal\\">a</span><span class=\\"mord mathnormal\\">t</span><span class=\\"mord mathnormal\\">e</span><span class=\\"mord mathnormal\\">x</span><span class=\\"mord\\"><span class=\\"mord mathnormal\\">e</span><span class=\\"msupsub\\"><span class=\\"vlist-t\\"><span class=\\"vlist-r\\"><span class=\\"vlist\\" style=\\"height:0.8747em;\\"><span style=\\"top:-3.113em;margin-right:0.05em;\\"><span class=\\"pstrut\\" style=\\"height:2.7em;\\"></span><span class=\\"sizing reset-size6 size3 mtight\\"><span class=\\"mord mtight\\"><span class=\\"mord mathnormal mtight\\" style=\\"margin-right:0.03588em;\\">iπ</span></span></span></span></span></span></span></span></span><span class=\\"mspace\\" style=\\"margin-right:0.2222em;\\"></span><span class=\\"mbin\\">+</span><span class=\\"mspace\\" style=\\"margin-right:0.2222em;\\"></span></span><span class=\\"base\\"><span class=\\"strut\\" style=\\"height:0.6444em;\\"></span><span class=\\"mord\\">1</span><span class=\\"mspace\\" style=\\"margin-right:0.2778em;\\"></span><span class=\\"mrel\\">=</span><span class=\\"mspace\\" style=\\"margin-right:0.2778em;\\"></span></span><span class=\\"base\\"><span class=\\"strut\\" style=\\"height:0.6944em;\\"></span><span class=\\"mord\\">0‘‘‘</span></span></span></span></span>", } } /> `;
2,504
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components
petrpan-code/mattermost/mattermost/webapp/channels/src/components/latex_inline/latex_inline.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import LatexInline from 'components/latex_inline/latex_inline'; describe('components/LatexBlock', () => { const defaultProps = { content: 'e^{i\\pi} + 1 = 0', enableInlineLatex: true, }; test('should match snapshot', async () => { const wrapper = shallow(<LatexInline {...defaultProps}/>); await import('katex'); //manually import katex expect(wrapper).toMatchSnapshot(); }); test('latex is disabled', async () => { const props = { ...defaultProps, enableInlineLatex: false, }; const wrapper = shallow(<LatexInline {...props}/>); await import('katex'); //manually import katex expect(wrapper).toMatchSnapshot(); }); test('error in katex', async () => { const props = { content: 'e^{i\\pi + 1 = 0', enableInlineLatex: true, }; const wrapper = shallow(<LatexInline {...props}/>); await import('katex'); //manually import katex expect(wrapper).toMatchSnapshot(); }); });
2,506
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/latex_inline
petrpan-code/mattermost/mattermost/webapp/channels/src/components/latex_inline/__snapshots__/latex_inline.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/LatexBlock error in katex 1`] = ` <span className="post-body--code inline-tex" dangerouslySetInnerHTML={ Object { "__html": "<span class=\\"katex-error\\" title=\\"ParseError: KaTeX parse error: Expected &#x27;}&#x27;, got &#x27;EOF&#x27; at end of input: e^{i\\\\pi + 1 = 0\\" style=\\"color:#cc0000\\">e^{i\\\\pi + 1 = 0</span>", } } /> `; exports[`components/LatexBlock latex is disabled 1`] = ` <span className="post-body--code inline-tex" > $e^{i\\pi} + 1 = 0$ </span> `; exports[`components/LatexBlock should match snapshot 1`] = ` <span className="post-body--code inline-tex" dangerouslySetInnerHTML={ Object { "__html": "<span class=\\"katex\\"><span class=\\"katex-mathml\\"><math xmlns=\\"http://www.w3.org/1998/Math/MathML\\"><semantics><mrow><msup><mi>e</mi><mrow><mi>i</mi><mi>π</mi></mrow></msup><mo>+</mo><mn>1</mn><mo>=</mo><mn>0</mn></mrow><annotation encoding=\\"application/x-tex\\">e^{i\\\\pi} + 1 = 0</annotation></semantics></math></span><span class=\\"katex-html\\" aria-hidden=\\"true\\"><span class=\\"base\\"><span class=\\"strut\\" style=\\"height:0.908em;vertical-align:-0.0833em;\\"></span><span class=\\"mord\\"><span class=\\"mord mathnormal\\">e</span><span class=\\"msupsub\\"><span class=\\"vlist-t\\"><span class=\\"vlist-r\\"><span class=\\"vlist\\" style=\\"height:0.8247em;\\"><span style=\\"top:-3.063em;margin-right:0.05em;\\"><span class=\\"pstrut\\" style=\\"height:2.7em;\\"></span><span class=\\"sizing reset-size6 size3 mtight\\"><span class=\\"mord mtight\\"><span class=\\"mord mathnormal mtight\\" style=\\"margin-right:0.03588em;\\">iπ</span></span></span></span></span></span></span></span></span><span class=\\"mspace\\" style=\\"margin-right:0.2222em;\\"></span><span class=\\"mbin\\">+</span><span class=\\"mspace\\" style=\\"margin-right:0.2222em;\\"></span></span><span class=\\"base\\"><span class=\\"strut\\" style=\\"height:0.6444em;\\"></span><span class=\\"mord\\">1</span><span class=\\"mspace\\" style=\\"margin-right:0.2778em;\\"></span><span class=\\"mrel\\">=</span><span class=\\"mspace\\" style=\\"margin-right:0.2778em;\\"></span></span><span class=\\"base\\"><span class=\\"strut\\" style=\\"height:0.6444em;\\"></span><span class=\\"mord\\">0</span></span></span></span>", } } /> `;
2,508
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components
petrpan-code/mattermost/mattermost/webapp/channels/src/components/learn_more_trial_modal/learn_more_trial_modal.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import {Provider} from 'react-redux'; import {GenericModal} from '@mattermost/components'; import Carousel from 'components/common/carousel/carousel'; import LearnMoreTrialModal from 'components/learn_more_trial_modal/learn_more_trial_modal'; import {mountWithIntl} from 'tests/helpers/intl-test-helper'; import mockStore from 'tests/test_store'; jest.mock('actions/telemetry_actions.jsx', () => { const original = jest.requireActual('actions/telemetry_actions.jsx'); return { ...original, trackEvent: jest.fn(), }; }); const CloudStartTrialButton = () => { return (<button>{'Start Cloud Trial'}</button>); }; jest.mock('components/cloud_start_trial/cloud_start_trial_btn', () => CloudStartTrialButton); describe('components/learn_more_trial_modal/learn_more_trial_modal', () => { // required state to mount using the provider const state = { entities: { users: { currentUserId: 'current_user_id', profiles: { current_user_id: { id: 'current_user_id', roles: '', }, }, }, admin: { analytics: { TOTAL_USERS: 9, }, prevTrialLicense: { IsLicensed: 'false', }, }, general: { license: { IsLicensed: 'false', Cloud: 'true', }, config: { DiagnosticsEnabled: 'false', }, }, cloud: { subscription: {id: 'subscription'}, }, }, views: { modals: { modalState: { learn_more_trial_modal: { open: 'true', }, }, }, }, }; const props = { onExited: jest.fn(), }; const store = mockStore(state); test('should match snapshot', () => { const wrapper = shallow( <Provider store={store}> <LearnMoreTrialModal {...props}/> </Provider>, ); expect(wrapper).toMatchSnapshot(); }); test('should show the learn more about trial modal carousel slides', () => { const wrapper = mountWithIntl( <Provider store={store}> <LearnMoreTrialModal {...props}/> </Provider>, ); expect(wrapper.find('LearnMoreTrialModal').find('Carousel')).toHaveLength(1); }); test('should call on close', () => { const mockOnClose = jest.fn(); const wrapper = mountWithIntl( <Provider store={store}> <LearnMoreTrialModal {...props} onClose={mockOnClose} /> </Provider>, ); wrapper.find(GenericModal).props().onExited(); expect(mockOnClose).toHaveBeenCalled(); }); test('should call on exited', () => { const mockOnExited = jest.fn(); const wrapper = mountWithIntl( <Provider store={store}> <LearnMoreTrialModal {...props} onExited={mockOnExited} /> </Provider>, ); wrapper.find(GenericModal).props().onExited(); expect(mockOnExited).toHaveBeenCalled(); }); test('should move the slides when clicking carousel next and prev buttons', () => { const wrapper = mountWithIntl( <Provider store={store}> <LearnMoreTrialModal {...props} /> </Provider>, ); // validate the value of the first slide let activeSlide = wrapper.find(Carousel).find('.slide.active-anim'); let activeSlideId = activeSlide.find('LearnMoreTrialModalStep').props().id; expect(activeSlideId).toBe('useSso'); const nextButton = wrapper.find(Carousel).find('CarouselButton div.chevron-right'); const prevButton = wrapper.find(Carousel).find('CarouselButton div.chevron-left'); // move to the second slide nextButton.simulate('click'); activeSlide = wrapper.find(Carousel).find('.slide.active-anim'); activeSlideId = activeSlide.find('LearnMoreTrialModalStep').props().id; expect(activeSlideId).toBe('ldap'); // move to the third slide nextButton.simulate('click'); activeSlide = wrapper.find(Carousel).find('.slide.active-anim'); activeSlideId = activeSlide.find('LearnMoreTrialModalStep').props().id; expect(activeSlideId).toBe('systemConsole'); // move back to the second slide prevButton.simulate('click'); activeSlide = wrapper.find(Carousel).find('.slide.active-anim'); activeSlideId = activeSlide.find('LearnMoreTrialModalStep').props().id; expect(activeSlideId).toBe('ldap'); }); test('should have the start cloud trial button when is cloud workspace and cloud free is enabled', () => { const wrapper = mountWithIntl( <Provider store={store}> <LearnMoreTrialModal {...props} /> </Provider>, ); const trialButton = wrapper.find('CloudStartTrialButton'); expect(trialButton).toHaveLength(1); }); test('should have the self hosted request trial button cloud free is disabled', () => { const nonCloudState = { ...state, entities: { ...state.entities, general: { ...state.entities.general, license: { ...state.entities.general.license, Cloud: 'false', }, }, }, }; const nonCloudStore = mockStore(nonCloudState); const wrapper = mountWithIntl( <Provider store={nonCloudStore}> <LearnMoreTrialModal {...props} /> </Provider>, ); // validate the cloud start trial button is not present const trialButton = wrapper.find('CloudStartTrialButton'); expect(trialButton).toHaveLength(0); // validate the cloud start trial button is not present const selfHostedRequestTrialButton = wrapper.find('StartTrialBtn'); expect(selfHostedRequestTrialButton).toHaveLength(1); }); });
2,511
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components
petrpan-code/mattermost/mattermost/webapp/channels/src/components/learn_more_trial_modal/learn_more_trial_modal_step.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import {Provider} from 'react-redux'; import LearnMoreTrialModalStep from 'components/learn_more_trial_modal/learn_more_trial_modal_step'; import mockStore from 'tests/test_store'; describe('components/learn_more_trial_modal/learn_more_trial_modal_step', () => { const props = { id: 'stepId', title: 'Step title', description: 'Step description', svgWrapperClassName: 'stepClassname', svgElement: <svg/>, buttonLabel: 'button', }; const state = { entities: { admin: { prevTrialLicense: { IsLicensed: 'false', }, }, general: { license: { IsLicensed: 'false', }, }, }, views: { modals: { modalState: { learn_more_trial_modal: { open: 'true', }, }, }, }, }; const store = mockStore(state); test('should match snapshot', () => { const wrapper = shallow( <Provider store={store}> <LearnMoreTrialModalStep {...props}/> </Provider>, ); expect(wrapper).toMatchSnapshot(); }); test('should match snapshot with optional params', () => { const wrapper = shallow( <Provider store={store}> <LearnMoreTrialModalStep {...props} bottomLeftMessage='Step bottom message' /> </Provider>, ); expect(wrapper).toMatchSnapshot(); }); test('should match snapshot when loaded in cloud workspace', () => { const cloudProps = {...props, isCloud: true}; const wrapper = shallow( <Provider store={store}> <LearnMoreTrialModalStep {...cloudProps} bottomLeftMessage='Step bottom message' /> </Provider>, ); expect(wrapper).toMatchSnapshot(); }); });
2,514
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components
petrpan-code/mattermost/mattermost/webapp/channels/src/components/learn_more_trial_modal/start_trial_btn.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import type {ReactWrapper} from 'enzyme'; import {shallow} from 'enzyme'; import React from 'react'; import {act} from 'react-dom/test-utils'; import {Provider} from 'react-redux'; import StartTrialBtn from 'components/learn_more_trial_modal/start_trial_btn'; import {mountWithIntl} from 'tests/helpers/intl-test-helper'; import mockStore from 'tests/test_store'; jest.mock('actions/telemetry_actions.jsx', () => { const original = jest.requireActual('actions/telemetry_actions.jsx'); return { ...original, trackEvent: jest.fn(), }; }); jest.mock('mattermost-redux/actions/general', () => ({ ...jest.requireActual('mattermost-redux/actions/general'), getLicenseConfig: () => ({type: 'adsf'}), })); jest.mock('actions/admin_actions', () => ({ ...jest.requireActual('actions/admin_actions'), requestTrialLicense: (requestedUsers: number) => { if (requestedUsers === 9001) { return {type: 'asdf', data: null, error: {status: 400, message: 'some error'}}; } else if (requestedUsers === 451) { return {type: 'asdf', data: {status: 451}, error: {message: 'some error'}}; } return {type: 'asdf', data: 'ok'}; }, })); describe('components/learn_more_trial_modal/start_trial_btn', () => { const state = { entities: { users: { currentUserId: 'current_user_id', }, admin: { analytics: { TOTAL_USERS: 9, }, prevTrialLicense: { IsLicensed: 'false', }, }, general: { license: { IsLicensed: 'false', }, config: { TelemetryId: 'test_telemetry_id', }, }, }, views: { modals: { modalState: { learn_more_trial_modal: { open: 'true', }, }, }, }, }; const store = mockStore(state); const props = { onClick: jest.fn(), message: 'Start trial', telemetryId: 'test_telemetry_id', }; test('should match snapshot', () => { const wrapper = shallow( <Provider store={store}> <StartTrialBtn {...props}/> </Provider>, ); expect(wrapper).toMatchSnapshot(); }); test('should handle on click', async () => { const mockOnClick = jest.fn(); let wrapper: ReactWrapper<any>; // Mount the component await act(async () => { wrapper = mountWithIntl( <Provider store={store}> <StartTrialBtn {...props} onClick={mockOnClick} /> </Provider>, ); }); await act(async () => { wrapper.find('.start-trial-btn').simulate('click'); }); expect(mockOnClick).toHaveBeenCalled(); }); test('should handle on click when rendered as button', async () => { const mockOnClick = jest.fn(); let wrapper: ReactWrapper<any>; // Mount the component await act(async () => { wrapper = mountWithIntl( <Provider store={store}> <StartTrialBtn {...props} renderAsButton={true} onClick={mockOnClick} /> </Provider>, ); }); await act(async () => { wrapper.find('button').simulate('click'); }); expect(mockOnClick).toHaveBeenCalled(); }); // test('does not show success for embargoed countries', async () => { // const mockOnClick = jest.fn(); // let wrapper: ReactWrapper<any>; // const clonedState = JSON.parse(JSON.stringify(state)); // clonedState.entities.admin.analytics.TOTAL_USERS = 451; // // Mount the component // await act(async () => { // wrapper = mountWithIntl( // <Provider store={mockStore(clonedState)}> // <StartTrialBtn // {...props} // onClick={mockOnClick} // /> // </Provider>, // ); // }); // await act(async () => { // wrapper.find('.start-trial-btn').simulate('click'); // }); // expect(mockOnClick).not.toHaveBeenCalled(); // }); });
2,516
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/learn_more_trial_modal
petrpan-code/mattermost/mattermost/webapp/channels/src/components/learn_more_trial_modal/__snapshots__/learn_more_trial_modal.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/learn_more_trial_modal/learn_more_trial_modal should match snapshot 1`] = ` <ContextProvider value={ Object { "store": Object { "clearActions": [Function], "dispatch": [Function], "getActions": [Function], "getState": [Function], "replaceReducer": [Function], "subscribe": [Function], }, "subscription": Subscription { "handleChangeWrapper": [Function], "listeners": Object { "notify": [Function], }, "onStateChange": [Function], "parentSub": undefined, "store": Object { "clearActions": [Function], "dispatch": [Function], "getActions": [Function], "getState": [Function], "replaceReducer": [Function], "subscribe": [Function], }, "unsubscribe": null, }, } } > <LearnMoreTrialModal onExited={[MockFunction]} /> </ContextProvider> `;
2,517
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/learn_more_trial_modal
petrpan-code/mattermost/mattermost/webapp/channels/src/components/learn_more_trial_modal/__snapshots__/learn_more_trial_modal_step.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/learn_more_trial_modal/learn_more_trial_modal_step should match snapshot 1`] = ` <ContextProvider value={ Object { "store": Object { "clearActions": [Function], "dispatch": [Function], "getActions": [Function], "getState": [Function], "replaceReducer": [Function], "subscribe": [Function], }, "subscription": Subscription { "handleChangeWrapper": [Function], "listeners": Object { "notify": [Function], }, "onStateChange": [Function], "parentSub": undefined, "store": Object { "clearActions": [Function], "dispatch": [Function], "getActions": [Function], "getState": [Function], "replaceReducer": [Function], "subscribe": [Function], }, "unsubscribe": null, }, } } > <LearnMoreTrialModalStep buttonLabel="button" description="Step description" id="stepId" svgElement={<svg />} svgWrapperClassName="stepClassname" title="Step title" /> </ContextProvider> `; exports[`components/learn_more_trial_modal/learn_more_trial_modal_step should match snapshot when loaded in cloud workspace 1`] = ` <ContextProvider value={ Object { "store": Object { "clearActions": [Function], "dispatch": [Function], "getActions": [Function], "getState": [Function], "replaceReducer": [Function], "subscribe": [Function], }, "subscription": Subscription { "handleChangeWrapper": [Function], "listeners": Object { "notify": [Function], }, "onStateChange": [Function], "parentSub": undefined, "store": Object { "clearActions": [Function], "dispatch": [Function], "getActions": [Function], "getState": [Function], "replaceReducer": [Function], "subscribe": [Function], }, "unsubscribe": null, }, } } > <LearnMoreTrialModalStep bottomLeftMessage="Step bottom message" buttonLabel="button" description="Step description" id="stepId" isCloud={true} svgElement={<svg />} svgWrapperClassName="stepClassname" title="Step title" /> </ContextProvider> `; exports[`components/learn_more_trial_modal/learn_more_trial_modal_step should match snapshot with optional params 1`] = ` <ContextProvider value={ Object { "store": Object { "clearActions": [Function], "dispatch": [Function], "getActions": [Function], "getState": [Function], "replaceReducer": [Function], "subscribe": [Function], }, "subscription": Subscription { "handleChangeWrapper": [Function], "listeners": Object { "notify": [Function], }, "onStateChange": [Function], "parentSub": undefined, "store": Object { "clearActions": [Function], "dispatch": [Function], "getActions": [Function], "getState": [Function], "replaceReducer": [Function], "subscribe": [Function], }, "unsubscribe": null, }, } } > <LearnMoreTrialModalStep bottomLeftMessage="Step bottom message" buttonLabel="button" description="Step description" id="stepId" svgElement={<svg />} svgWrapperClassName="stepClassname" title="Step title" /> </ContextProvider> `;
2,518
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/learn_more_trial_modal
petrpan-code/mattermost/mattermost/webapp/channels/src/components/learn_more_trial_modal/__snapshots__/start_trial_btn.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/learn_more_trial_modal/start_trial_btn should match snapshot 1`] = ` <ContextProvider value={ Object { "store": Object { "clearActions": [Function], "dispatch": [Function], "getActions": [Function], "getState": [Function], "replaceReducer": [Function], "subscribe": [Function], }, "subscription": Subscription { "handleChangeWrapper": [Function], "listeners": Object { "notify": [Function], }, "onStateChange": [Function], "parentSub": undefined, "store": Object { "clearActions": [Function], "dispatch": [Function], "getActions": [Function], "getState": [Function], "replaceReducer": [Function], "subscribe": [Function], }, "unsubscribe": null, }, } } > <StartTrialBtn message="Start trial" onClick={[MockFunction]} telemetryId="test_telemetry_id" /> </ContextProvider> `;
2,520
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components
petrpan-code/mattermost/mattermost/webapp/channels/src/components/leave_channel_modal/leave_channel_modal.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import type {ChannelType} from '@mattermost/types/channels'; import ConfirmModal from 'components/confirm_modal'; import LeaveChannelModal from 'components/leave_channel_modal/leave_channel_modal'; describe('components/LeaveChannelModal', () => { const channels = { 'channel-1': { id: 'channel-1', name: 'test-channel-1', display_name: 'Test Channel 1', type: ('P' as ChannelType), team_id: 'team-1', header: '', purpose: '', creator_id: '', scheme_id: '', group_constrained: false, create_at: 0, update_at: 0, delete_at: 0, last_post_at: 0, last_root_post_at: 0, }, 'channel-2': { id: 'channel-2', name: 'test-channel-2', display_name: 'Test Channel 2', team_id: 'team-1', type: ('P' as ChannelType), header: '', purpose: '', creator_id: '', scheme_id: '', group_constrained: false, create_at: 0, update_at: 0, delete_at: 0, last_post_at: 0, last_root_post_at: 0, }, 'town-square': { id: 'town-square-id', name: 'town-square', display_name: 'Town Square', type: ('O' as ChannelType), team_id: 'team-1', header: '', purpose: '', creator_id: '', scheme_id: '', group_constrained: false, create_at: 0, update_at: 0, delete_at: 0, last_post_at: 0, last_root_post_at: 0, }, }; test('should match snapshot, init', () => { const props = { channel: channels['town-square'], onExited: jest.fn(), actions: { leaveChannel: jest.fn(), }, }; const wrapper = shallow( <LeaveChannelModal {...props}/>, ); expect(wrapper).toMatchSnapshot(); }); test('should fail to leave channel', () => { const props = { channel: channels['channel-1'], actions: { leaveChannel: jest.fn().mockImplementation(() => { const error = { message: 'error leaving channel', }; return Promise.resolve({error}); }), }, onExited: jest.fn(), callback: jest.fn(), }; const wrapper = shallow<typeof LeaveChannelModal>( <LeaveChannelModal {...props} />, ); wrapper.find(ConfirmModal).props().onConfirm?.(true); expect(props.actions.leaveChannel).toHaveBeenCalledTimes(1); expect(props.callback).toHaveBeenCalledTimes(0); }); });
2,522
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/leave_channel_modal
petrpan-code/mattermost/mattermost/webapp/channels/src/components/leave_channel_modal/__snapshots__/leave_channel_modal.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/LeaveChannelModal should match snapshot, init 1`] = ` <ConfirmModal confirmButtonClass="btn btn-danger" confirmButtonText={ <Memo(MemoizedFormattedMessage) defaultMessage="Yes, leave channel" id="leave_private_channel_modal.leave" /> } message={ <Memo(MemoizedFormattedMessage) defaultMessage="Are you sure you wish to leave the channel {channel}? You can re-join this channel in the future if you change your mind." id="leave_public_channel_modal.message" values={ Object { "channel": <b> Town Square </b>, } } /> } modalClass="" onCancel={[Function]} onConfirm={[Function]} onExited={[MockFunction]} show={true} title={ <Memo(MemoizedFormattedMessage) defaultMessage="Leave Channel {channel}" id="leave_public_channel_modal.title" values={ Object { "channel": <b> Town Square </b>, } } /> } /> `;
2,524
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components
petrpan-code/mattermost/mattermost/webapp/channels/src/components/leave_team_modal/leave_team_modal.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import {TestHelper} from 'utils/test_helper'; import LeaveTeamModal from './leave_team_modal'; describe('components/LeaveTeamModal', () => { const requiredProps = { currentUser: TestHelper.getUserMock({ id: 'test', }), currentUserId: 'user_id', currentTeamId: 'team_id', numOfPrivateChannels: 0, numOfPublicChannels: 0, onExited: jest.fn(), actions: { leaveTeam: jest.fn(), toggleSideBarRightMenu: jest.fn(), }, }; it('should render the leave team model', () => { const wrapper = shallow(<LeaveTeamModal {...requiredProps}/>); expect(wrapper).toMatchSnapshot(); }); it('should hide when cancel is clicked', () => { const wrapper = shallow(<LeaveTeamModal {...requiredProps}/>); const cancel = wrapper.find('.btn-tertiary').first(); cancel.simulate('click'); expect(wrapper.state('show')).toBe(false); }); it('should call leaveTeam and toggleSideBarRightMenu when ok is clicked', () => { const wrapper = shallow(<LeaveTeamModal {...requiredProps}/>); const ok = wrapper.find('.btn-danger').first(); ok.simulate('click'); expect(requiredProps.actions.leaveTeam).toHaveBeenCalledTimes(1); expect(requiredProps.actions.toggleSideBarRightMenu).toHaveBeenCalledTimes(1); expect(requiredProps.actions.leaveTeam). toHaveBeenCalledWith(requiredProps.currentTeamId, requiredProps.currentUserId); expect(wrapper.state('show')).toBe(false); }); it('should call attach and remove event listeners', () => { document.addEventListener = jest.fn(); document.removeEventListener = jest.fn(); const wrapper = shallow(<LeaveTeamModal {...{...requiredProps, show: true}}/>); const instance = wrapper.instance() as LeaveTeamModal; expect(document.addEventListener).toHaveBeenCalledTimes(1); expect(document.removeEventListener).not.toBeCalled(); instance.componentWillUnmount(); expect(document.removeEventListener).toHaveBeenCalledTimes(1); }); });
2,526
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/leave_team_modal
petrpan-code/mattermost/mattermost/webapp/channels/src/components/leave_team_modal/__snapshots__/leave_team_modal.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/LeaveTeamModal should render the leave team model 1`] = ` <Modal animation={true} aria-labelledby="leaveTeamModalLabel" autoFocus={true} backdrop={true} bsClass="modal" className="modal-confirm" dialogClassName="a11y__modal" dialogComponentClass={[Function]} enforceFocus={true} id="leaveTeamModal" keyboard={true} manager={ ModalManager { "add": [Function], "containers": Array [], "data": Array [], "handleContainerOverflow": true, "hideSiblingNodes": true, "isTopModal": [Function], "modals": Array [], "remove": [Function], } } onExited={[MockFunction]} onHide={[Function]} renderBackdrop={[Function]} restoreFocus={true} role="dialog" show={true} > <ModalHeader bsClass="modal-header" closeButton={false} closeLabel="Close" > <ModalTitle bsClass="modal-title" componentClass="h1" id="leaveTeamModalLabel" > <MemoizedFormattedMessage defaultMessage="Leave the team?" id="leave_team_modal.title" /> </ModalTitle> </ModalHeader> <ModalBody bsClass="modal-body" componentClass="div" > <FormattedMarkdownMessage defaultMessage="**You will be removed from {num_of_private_channels} private {num_of_private_channels,one {channel} other {channels}} on this team.** If the team is private you won't be able to rejoin it without an invitation from another team member. Are you sure?" id="leave_team_modal_private.desc" values={ Object { "num_of_private_channels": 0, "num_of_public_channels": 0, } } /> </ModalBody> <ModalFooter bsClass="modal-footer" componentClass="div" > <button className="btn btn-tertiary" id="leaveTeamNo" onClick={[Function]} type="button" > <MemoizedFormattedMessage defaultMessage="No" id="leave_team_modal.no" /> </button> <button className="btn btn-danger" id="leaveTeamYes" onClick={[Function]} type="button" > <MemoizedFormattedMessage defaultMessage="Yes" id="leave_team_modal.yes" /> </button> </ModalFooter> </Modal> `;
2,528
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components
petrpan-code/mattermost/mattermost/webapp/channels/src/components/link_tooltip/link_tooltip.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import type {ReactPortal} from 'react'; import ReactDOM from 'react-dom'; import LinkTooltip from 'components/link_tooltip/link_tooltip'; describe('components/link_tooltip/link_tooltip', () => { test('should match snapshot', () => { ReactDOM.createPortal = (node) => node as ReactPortal; const wrapper = shallow<LinkTooltip>( <LinkTooltip href={'www.test.com'} attributes={{ class: 'mention-highlight', 'data-hashtag': '#somehashtag', 'data-link': 'somelink', 'data-channel-mention': 'somechannel', }} > {'test title'} </LinkTooltip>, ); expect(wrapper).toMatchSnapshot(); expect(wrapper.find('span').text()).toBe('test title'); }); test('should match snapshot with uncommon link structure', () => { ReactDOM.createPortal = (node) => node as ReactPortal; const wrapper = shallow<LinkTooltip>( <LinkTooltip href={'https://www.google.com'} attributes={{}} > <span className='codespan__pre-wrap'> <code>{'foo'}</code> </span> {' and '} <span className='codespan__pre-wrap'> <code>{'bar'}</code> </span> </LinkTooltip>, ); expect(wrapper).toMatchSnapshot(); expect(wrapper.find('span').at(0).text()).toBe('foo and bar'); }); });
2,530
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components/link_tooltip
petrpan-code/mattermost/mattermost/webapp/channels/src/components/link_tooltip/__snapshots__/link_tooltip.test.tsx.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`components/link_tooltip/link_tooltip should match snapshot 1`] = ` <Fragment> <div className="tooltip-container" style={ Object { "alignItems": "center", "display": "flex", "flexDirection": "column", "left": -1000, "position": "absolute", "top": -1000, "zIndex": 1070, } } > <Connect(Pluggable) href="www.test.com" pluggableName="LinkTooltip" show={false} /> </div> <span data-channel-mention="somechannel" data-hashtag="#somehashtag" data-link="somelink" onMouseLeave={[Function]} onMouseOver={[Function]} > test title </span> </Fragment> `; exports[`components/link_tooltip/link_tooltip should match snapshot with uncommon link structure 1`] = ` <Fragment> <div className="tooltip-container" style={ Object { "alignItems": "center", "display": "flex", "flexDirection": "column", "left": -1000, "position": "absolute", "top": -1000, "zIndex": 1070, } } > <Connect(Pluggable) href="https://www.google.com" pluggableName="LinkTooltip" show={false} /> </div> <span onMouseLeave={[Function]} onMouseOver={[Function]} > <span className="codespan__pre-wrap" > <code> foo </code> </span> and <span className="codespan__pre-wrap" > <code> bar </code> </span> </span> </Fragment> `;
2,534
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components
petrpan-code/mattermost/mattermost/webapp/channels/src/components/logged_in/logged_in.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import type {UserProfile} from '@mattermost/types/users'; import * as GlobalActions from 'actions/global_actions'; import BrowserStore from 'stores/browser_store'; import LoggedIn from 'components/logged_in/logged_in'; import type {Props} from 'components/logged_in/logged_in'; jest.mock('actions/websocket_actions.jsx', () => ({ initialize: jest.fn(), })); BrowserStore.signalLogin = jest.fn(); describe('components/logged_in/LoggedIn', () => { const children = <span>{'Test'}</span>; const baseProps: Props = { currentUser: {} as UserProfile, mfaRequired: false, actions: { autoUpdateTimezone: jest.fn(), getChannelURLAction: jest.fn(), markChannelAsViewedOnServer: jest.fn(), updateApproximateViewTime: jest.fn(), }, isCurrentChannelManuallyUnread: false, showTermsOfService: false, location: { pathname: '/', search: '', }, }; it('should render loading state without user', () => { const props = { ...baseProps, currentUser: undefined, }; const wrapper = shallow(<LoggedIn {...props}>{children}</LoggedIn>); expect(wrapper).toMatchInlineSnapshot('<LoadingScreen />'); }); it('should redirect to mfa when required and not on /mfa/setup', () => { const props = { ...baseProps, mfaRequired: true, }; const wrapper = shallow(<LoggedIn {...props}>{children}</LoggedIn>); expect(wrapper).toMatchInlineSnapshot(` <Redirect to="/mfa/setup" /> `); }); it('should render children when mfa required and already on /mfa/setup', () => { const props = { ...baseProps, mfaRequired: true, location: { pathname: '/mfa/setup', search: '', }, }; const wrapper = shallow(<LoggedIn {...props}>{children}</LoggedIn>); expect(wrapper).toMatchInlineSnapshot(` <span> Test </span> `); }); it('should render children when mfa is not required and on /mfa/confirm', () => { const props = { ...baseProps, mfaRequired: false, location: { pathname: '/mfa/confirm', search: '', }, }; const wrapper = shallow(<LoggedIn {...props}>{children}</LoggedIn>); expect(wrapper).toMatchInlineSnapshot(` <span> Test </span> `); }); it('should redirect to terms of service when mfa not required and terms of service required but not on /terms_of_service', () => { const props = { ...baseProps, mfaRequired: false, showTermsOfService: true, }; const wrapper = shallow(<LoggedIn {...props}>{children}</LoggedIn>); expect(wrapper).toMatchInlineSnapshot(` <Redirect to="/terms_of_service?redirect_to=%2F" /> `); }); it('should render children when mfa is not required and terms of service required and on /terms_of_service', () => { const props = { ...baseProps, mfaRequired: false, showTermsOfService: true, location: { pathname: '/terms_of_service', search: '', }, }; const wrapper = shallow(<LoggedIn {...props}>{children}</LoggedIn>); expect(wrapper).toMatchInlineSnapshot(` <span> Test </span> `); }); it('should render children when neither mfa nor terms of service required', () => { const props = { ...baseProps, mfaRequired: false, showTermsOfService: false, }; const wrapper = shallow(<LoggedIn {...props}>{children}</LoggedIn>); expect(wrapper).toMatchInlineSnapshot(` <span> Test </span> `); }); it('should signal to other tabs when login is successful', () => { const props = { ...baseProps, mfaRequired: false, showTermsOfService: true, }; shallow(<LoggedIn {...props}>{children}</LoggedIn>); expect(BrowserStore.signalLogin).toBeCalledTimes(1); }); it('should set state to unfocused if it starts in the background', () => { document.hasFocus = jest.fn(() => false); const obj = Object.assign(GlobalActions); obj.emitBrowserFocus = jest.fn(); const props = { ...baseProps, mfaRequired: false, showTermsOfService: true, }; shallow(<LoggedIn {...props}>{children}</LoggedIn>); expect(obj.emitBrowserFocus).toBeCalledTimes(1); }); });
2,537
0
petrpan-code/mattermost/mattermost/webapp/channels/src/components
petrpan-code/mattermost/mattermost/webapp/channels/src/components/login/login.test.tsx
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {shallow} from 'enzyme'; import React from 'react'; import {IntlProvider} from 'react-intl'; import {MemoryRouter} from 'react-router-dom'; import type {ClientConfig} from '@mattermost/types/config'; import {RequestStatus} from 'mattermost-redux/constants'; import type {ActionFunc} from 'mattermost-redux/types/actions'; import LocalStorageStore from 'stores/local_storage_store'; import AlertBanner from 'components/alert_banner'; import ExternalLoginButton from 'components/external_login_button/external_login_button'; import Login from 'components/login/login'; import SaveButton from 'components/save_button'; import Input from 'components/widgets/inputs/input/input'; import PasswordInput from 'components/widgets/inputs/password_input/password_input'; import {mountWithIntl} from 'tests/helpers/intl-test-helper'; import Constants, {WindowSizes} from 'utils/constants'; import type {GlobalState} from 'types/store'; let mockState: GlobalState; let mockLocation = {pathname: '', search: '', hash: ''}; const mockHistoryReplace = jest.fn(); const mockHistoryPush = jest.fn(); const mockLicense = {IsLicensed: 'false'}; let mockConfig: Partial<ClientConfig>; jest.mock('react-redux', () => ({ ...jest.requireActual('react-redux') as typeof import('react-redux'), useSelector: (selector: (state: typeof mockState) => unknown) => selector(mockState), useDispatch: jest.fn(() => (action: ActionFunc) => action), })); jest.mock('react-router-dom', () => ({ ...jest.requireActual('react-router-dom') as typeof import('react-router-dom'), useLocation: () => mockLocation, useHistory: () => ({ replace: mockHistoryReplace, push: mockHistoryPush, }), })); jest.mock('mattermost-redux/selectors/entities/general', () => ({ ...jest.requireActual('mattermost-redux/selectors/entities/general') as typeof import('mattermost-redux/selectors/entities/general'), getLicense: () => mockLicense, getConfig: () => mockConfig, })); describe('components/login/Login', () => { beforeEach(() => { mockLocation = {pathname: '', search: '', hash: ''}; LocalStorageStore.setWasLoggedIn(false); mockState = { entities: { general: { config: {}, license: {}, }, users: { currentUserId: '', profiles: { user1: { id: 'user1', roles: '', }, }, }, teams: { currentTeamId: 'team1', teams: { team1: { id: 'team1', name: 'team-1', displayName: 'Team 1', }, }, myMembers: { team1: {roles: 'team_role'}, }, }, }, requests: { users: { logout: { status: RequestStatus.NOT_STARTED, }, }, }, storage: { initialized: true, }, views: { browser: { windowSize: WindowSizes.DESKTOP_VIEW, }, }, } as unknown as GlobalState; mockConfig = { EnableLdap: 'false', EnableSaml: 'false', EnableSignInWithEmail: 'false', EnableSignInWithUsername: 'false', EnableSignUpWithEmail: 'false', EnableSignUpWithGitLab: 'false', EnableSignUpWithOffice365: 'false', EnableSignUpWithGoogle: 'false', EnableSignUpWithOpenId: 'false', EnableOpenServer: 'false', LdapLoginFieldName: '', GitLabButtonText: '', GitLabButtonColor: '', OpenIdButtonText: '', OpenIdButtonColor: '', SamlLoginButtonText: '', EnableCustomBrand: 'false', CustomBrandText: '', CustomDescriptionText: '', SiteName: 'Mattermost', ExperimentalPrimaryTeam: '', PasswordEnableForgotLink: 'true', }; }); it('should match snapshot', () => { const wrapper = shallow( <Login/>, ); expect(wrapper).toMatchSnapshot(); }); it('should match snapshot with base login', () => { mockConfig.EnableSignInWithEmail = 'true'; const wrapper = shallow( <Login/>, ); expect(wrapper).toMatchSnapshot(); }); it('should handle session expired', () => { LocalStorageStore.setWasLoggedIn(true); mockConfig.EnableSignInWithEmail = 'true'; const wrapper = mountWithIntl( <MemoryRouter><Login/></MemoryRouter>, ); const alertBanner = wrapper.find(AlertBanner).first(); expect(alertBanner.props().mode).toEqual('warning'); expect(alertBanner.props().title).toEqual('Your session has expired. Please log in again.'); alertBanner.find('button').first().simulate('click'); expect(wrapper.find(AlertBanner)).toEqual({}); }); it('should handle initializing when logout status success', () => { mockState.requests.users.logout.status = RequestStatus.SUCCESS; const intlProviderProps = { defaultLocale: 'en', locale: 'en', messages: {}, }; const wrapper = mountWithIntl( <IntlProvider {...intlProviderProps}> <MemoryRouter> <Login/> </MemoryRouter> </IntlProvider>, ); // eslint-disable-next-line react/jsx-key, react/jsx-no-literals expect(wrapper.contains([<p>Loading</p>])).toEqual(true); }); it('should handle initializing when storage not initalized', () => { mockState.storage.initialized = false; const intlProviderProps = { defaultLocale: 'en', locale: 'en', messages: {}, }; const wrapper = mountWithIntl( <IntlProvider {...intlProviderProps}> <Login/> </IntlProvider>, ); // eslint-disable-next-line react/jsx-no-literals, react/jsx-key expect(wrapper.contains([<p>Loading</p>])).toEqual(true); }); it('should handle suppress session expired notification on sign in change', () => { mockLocation.search = '?extra=' + Constants.SIGNIN_CHANGE; LocalStorageStore.setWasLoggedIn(true); mockConfig.EnableSignInWithEmail = 'true'; const wrapper = mountWithIntl( <MemoryRouter> <Login/> </MemoryRouter>, ); expect(LocalStorageStore.getWasLoggedIn()).toEqual(false); const alertBanner = wrapper.find(AlertBanner).first(); expect(alertBanner.props().mode).toEqual('success'); expect(alertBanner.props().title).toEqual('Sign-in method changed successfully'); alertBanner.find('button').first().simulate('click'); expect(wrapper.find(AlertBanner)).toEqual({}); }); it('should handle discard session expiry notification on failed sign in', () => { LocalStorageStore.setWasLoggedIn(true); mockConfig.EnableSignInWithEmail = 'true'; const wrapper = mountWithIntl( <MemoryRouter> <Login/> </MemoryRouter>, ); let alertBanner = wrapper.find(AlertBanner).first(); expect(alertBanner.props().mode).toEqual('warning'); expect(alertBanner.props().title).toEqual('Your session has expired. Please log in again.'); const input = wrapper.find(Input).first().find('input').first(); input.simulate('change', {target: {value: 'user1'}}); const passwordInput = wrapper.find(PasswordInput).first().find('input').first(); passwordInput.simulate('change', {target: {value: 'passw'}}); const saveButton = wrapper.find(SaveButton).first(); expect(saveButton.props().disabled).toEqual(false); saveButton.find('button').first().simulate('click'); setTimeout(() => { alertBanner = wrapper.find(AlertBanner).first(); expect(alertBanner.props().mode).toEqual('danger'); expect(alertBanner.props().title).toEqual('The email/username or password is invalid.'); }); }); it('should handle gitlab text and color props', () => { mockConfig.EnableSignInWithEmail = 'true'; mockConfig.EnableSignUpWithGitLab = 'true'; mockConfig.GitLabButtonText = 'GitLab 2'; mockConfig.GitLabButtonColor = '#00ff00'; const wrapper = shallow( <Login/>, ); const externalLoginButton = wrapper.find(ExternalLoginButton).first(); expect(externalLoginButton.props().url).toEqual('/oauth/gitlab/login'); expect(externalLoginButton.props().label).toEqual('GitLab 2'); expect(externalLoginButton.props().style).toEqual({color: '#00ff00', borderColor: '#00ff00'}); }); it('should handle openid text and color props', () => { mockConfig.EnableSignInWithEmail = 'true'; mockConfig.EnableSignUpWithOpenId = 'true'; mockConfig.OpenIdButtonText = 'OpenID 2'; mockConfig.OpenIdButtonColor = '#00ff00'; const wrapper = shallow( <Login/>, ); const externalLoginButton = wrapper.find(ExternalLoginButton).first(); expect(externalLoginButton.props().url).toEqual('/oauth/openid/login'); expect(externalLoginButton.props().label).toEqual('OpenID 2'); expect(externalLoginButton.props().style).toEqual({color: '#00ff00', borderColor: '#00ff00'}); }); it('should redirect on login', () => { mockState.entities.users.currentUserId = 'user1'; LocalStorageStore.setWasLoggedIn(true); mockConfig.EnableSignInWithEmail = 'true'; const redirectPath = '/boards/team/teamID/boardID'; mockLocation.search = '?redirect_to=' + redirectPath; mountWithIntl( <MemoryRouter> <Login/> </MemoryRouter>, ); expect(mockHistoryPush).toHaveBeenCalledWith(redirectPath); }); });