Re-export all React Testing Library functions (#23522)

Этот коммит содержится в:
Harrison Healey
2023-06-05 12:49:31 -04:00
коммит произвёл GitHub
родитель f4f420dd93
Коммит 9c656c25d9
96 изменённых файлов: 282 добавлений и 322 удалений

Просмотреть файл

@@ -2,21 +2,16 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React from 'react'; import React from 'react';
import {Provider} from 'react-redux';
import mockStore from 'tests/test_store';
import {ClientConfig, ClientLicense} from '@mattermost/types/config'; import {ClientConfig, ClientLicense} from '@mattermost/types/config';
import AboutBuildModal from 'components/about_build_modal/about_build_modal'; import AboutBuildModal from 'components/about_build_modal/about_build_modal';
import {renderWithFullContext, screen, userEvent} from 'tests/react_testing_utils';
import {AboutLinks} from 'utils/constants'; import {AboutLinks} from 'utils/constants';
import AboutBuildModalCloud from './about_build_modal_cloud/about_build_modal_cloud'; import AboutBuildModalCloud from './about_build_modal_cloud/about_build_modal_cloud';
import {screen} from '@testing-library/react';
import {renderWithIntl} from 'tests/react_testing_utils';
import store from 'stores/redux_store';
import userEvent from '@testing-library/user-event';
describe('components/AboutBuildModal', () => { describe('components/AboutBuildModal', () => {
const RealDate: DateConstructor = Date; const RealDate: DateConstructor = Date;
@@ -98,16 +93,14 @@ describe('components/AboutBuildModal', () => {
license.Cloud = 'true'; license.Cloud = 'true';
} }
renderWithIntl( renderWithFullContext(
<Provider store={store}> <AboutBuildModalCloud
<AboutBuildModalCloud config={config}
config={config} license={license}
license={license} show={true}
show={true} onExited={jest.fn()}
onExited={jest.fn()} doHide={jest.fn()}
doHide={jest.fn()} />,
/>
</Provider>,
); );
expect(screen.getByText('Mattermost Cloud')).toBeInTheDocument(); expect(screen.getByText('Mattermost Cloud')).toBeInTheDocument();
@@ -170,7 +163,7 @@ describe('components/AboutBuildModal', () => {
test('should call onExited callback when the modal is hidden', () => { test('should call onExited callback when the modal is hidden', () => {
const onExited = jest.fn(); const onExited = jest.fn();
const store = mockStore({ const state = {
entities: { entities: {
general: { general: {
config: {}, config: {},
@@ -182,16 +175,15 @@ describe('components/AboutBuildModal', () => {
currentUserId: 'currentUserId', currentUserId: 'currentUserId',
}, },
}, },
}); };
renderWithIntl( renderWithFullContext(
<Provider store={store}> <AboutBuildModal
<AboutBuildModal config={config}
config={config} license={license}
license={license} onExited={onExited}
onExited={onExited} />,
/> state,
</Provider>,
); );
userEvent.click(screen.getByText('Close')); userEvent.click(screen.getByText('Close'));
@@ -199,7 +191,7 @@ describe('components/AboutBuildModal', () => {
}); });
test('should show default tos and privacy policy links and not the config links', () => { test('should show default tos and privacy policy links and not the config links', () => {
const store = mockStore({ const state = {
entities: { entities: {
general: { general: {
config: {}, config: {},
@@ -211,15 +203,14 @@ describe('components/AboutBuildModal', () => {
currentUserId: 'currentUserId', currentUserId: 'currentUserId',
}, },
}, },
}); };
renderWithIntl( renderWithFullContext(
<Provider store={store}> <AboutBuildModal
<AboutBuildModal config={config}
config={config} license={license}
license={license} onExited={jest.fn()}
onExited={jest.fn()} />,
/> state,
</Provider>,
); );
expect(screen.getByRole('link', {name: 'Terms of Use'})).toHaveAttribute('href', `${AboutLinks.TERMS_OF_SERVICE}?utm_source=mattermost&utm_medium=in-product&utm_content=about_build_modal&uid=currentUserId&sid=`); expect(screen.getByRole('link', {name: 'Terms of Use'})).toHaveAttribute('href', `${AboutLinks.TERMS_OF_SERVICE}?utm_source=mattermost&utm_medium=in-product&utm_content=about_build_modal&uid=currentUserId&sid=`);
@@ -242,6 +233,6 @@ describe('components/AboutBuildModal', () => {
...props, ...props,
}; };
return renderWithIntl(<Provider store={store}><AboutBuildModal {...allProps}/></Provider>); return renderWithFullContext(<AboutBuildModal {...allProps}/>);
} }
}); });

Просмотреть файл

@@ -2,14 +2,8 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React from 'react'; import React from 'react';
import {Provider} from 'react-redux';
import {BrowserRouter} from 'react-router-dom'; import {renderWithFullContext, screen} from 'tests/react_testing_utils';
import {screen} from '@testing-library/react';
import mockStore from 'tests/test_store';
import {renderWithIntl} from 'tests/react_testing_utils';
import InsightsTitle from './insights_title'; import InsightsTitle from './insights_title';
@@ -31,53 +25,33 @@ describe('components/activity_and_insights/insights/insights_title', () => {
}, },
}, },
}, },
general: {
config: {},
license: {},
},
users: { users: {
currentUserId: 'current_user_id', currentUserId: 'current_user_id',
profiles: { profiles: {
current_user_id: {}, current_user_id: {},
}, },
}, },
preferences: {
myPreferences: {},
},
cloud: {
subscription: {},
},
}, },
}; };
test('should match snapshot with My insights', async () => { test('should match snapshot with My insights', () => {
const store = await mockStore(initialState); renderWithFullContext(
<InsightsTitle
renderWithIntl( {...props}
<Provider store={store}> filterType={'MY'}
<BrowserRouter> />,
<InsightsTitle initialState,
{...props}
filterType={'MY'}
/>
</BrowserRouter>
</Provider>,
); );
expect(screen.getByText('My insights')).toBeInTheDocument(); expect(screen.getByText('My insights')).toBeInTheDocument();
}); });
test('should match snapshot with Team insights', async () => { test('should match snapshot with Team insights', () => {
const store = await mockStore(initialState); renderWithFullContext(
<InsightsTitle
renderWithIntl( {...props}
<Provider store={store}> />,
<BrowserRouter> initialState,
<InsightsTitle
{...props}
/>
</BrowserRouter>
</Provider>,
); );
expect(screen.getByText('Team insights')).toBeInTheDocument(); expect(screen.getByText('Team insights')).toBeInTheDocument();

Просмотреть файл

@@ -5,12 +5,11 @@ import React from 'react';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
import {act} from '@testing-library/react';
import {ReactWrapper} from 'enzyme'; import {ReactWrapper} from 'enzyme';
import {BrowserRouter} from 'react-router-dom'; import {BrowserRouter} from 'react-router-dom';
import {act} from 'tests/react_testing_utils';
import {mountWithIntl} from 'tests/helpers/intl-test-helper'; import {mountWithIntl} from 'tests/helpers/intl-test-helper';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';

Просмотреть файл

@@ -4,8 +4,6 @@
import React from 'react'; import React from 'react';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
import {act} from '@testing-library/react';
import {ReactWrapper} from 'enzyme'; import {ReactWrapper} from 'enzyme';
import {BrowserRouter} from 'react-router-dom'; import {BrowserRouter} from 'react-router-dom';
@@ -13,6 +11,7 @@ import {BrowserRouter} from 'react-router-dom';
import {CardSizes, InsightsWidgetTypes, TimeFrames} from '@mattermost/types/insights'; import {CardSizes, InsightsWidgetTypes, TimeFrames} from '@mattermost/types/insights';
import {mountWithIntl} from 'tests/helpers/intl-test-helper'; import {mountWithIntl} from 'tests/helpers/intl-test-helper';
import {act} from 'tests/react_testing_utils';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';
import LeastActiveChannels from './least_active_channels'; import LeastActiveChannels from './least_active_channels';

Просмотреть файл

@@ -4,14 +4,13 @@
import React from 'react'; import React from 'react';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
import {act} from '@testing-library/react';
import {ReactWrapper} from 'enzyme'; import {ReactWrapper} from 'enzyme';
import {BrowserRouter} from 'react-router-dom'; import {BrowserRouter} from 'react-router-dom';
import {TimeFrames} from '@mattermost/types/insights'; import {TimeFrames} from '@mattermost/types/insights';
import {act} from 'tests/react_testing_utils';
import {mountWithIntl} from 'tests/helpers/intl-test-helper'; import {mountWithIntl} from 'tests/helpers/intl-test-helper';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';

Просмотреть файл

@@ -4,8 +4,6 @@
import React from 'react'; import React from 'react';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
import {act} from '@testing-library/react';
import {ReactWrapper} from 'enzyme'; import {ReactWrapper} from 'enzyme';
import {BrowserRouter} from 'react-router-dom'; import {BrowserRouter} from 'react-router-dom';
@@ -13,6 +11,7 @@ import {BrowserRouter} from 'react-router-dom';
import {CardSizes, InsightsWidgetTypes, TimeFrames} from '@mattermost/types/insights'; import {CardSizes, InsightsWidgetTypes, TimeFrames} from '@mattermost/types/insights';
import {mountWithIntl} from 'tests/helpers/intl-test-helper'; import {mountWithIntl} from 'tests/helpers/intl-test-helper';
import {act} from 'tests/react_testing_utils';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';
import TopBoards from './top_boards'; import TopBoards from './top_boards';

Просмотреть файл

@@ -4,8 +4,6 @@
import React from 'react'; import React from 'react';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
import {act} from '@testing-library/react';
import {ReactWrapper} from 'enzyme'; import {ReactWrapper} from 'enzyme';
import {BrowserRouter} from 'react-router-dom'; import {BrowserRouter} from 'react-router-dom';
@@ -13,6 +11,7 @@ import {BrowserRouter} from 'react-router-dom';
import {TimeFrames} from '@mattermost/types/insights'; import {TimeFrames} from '@mattermost/types/insights';
import {mountWithIntl} from 'tests/helpers/intl-test-helper'; import {mountWithIntl} from 'tests/helpers/intl-test-helper';
import {act} from 'tests/react_testing_utils';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';
import TopBoardsTable from './top_boards_table'; import TopBoardsTable from './top_boards_table';

Просмотреть файл

@@ -4,8 +4,6 @@
import React from 'react'; import React from 'react';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
import {act} from '@testing-library/react';
import {ReactWrapper} from 'enzyme'; import {ReactWrapper} from 'enzyme';
import {BrowserRouter} from 'react-router-dom'; import {BrowserRouter} from 'react-router-dom';
@@ -13,6 +11,7 @@ import {BrowserRouter} from 'react-router-dom';
import {CardSizes, InsightsWidgetTypes, TimeFrames} from '@mattermost/types/insights'; import {CardSizes, InsightsWidgetTypes, TimeFrames} from '@mattermost/types/insights';
import {mountWithIntl} from 'tests/helpers/intl-test-helper'; import {mountWithIntl} from 'tests/helpers/intl-test-helper';
import {act} from 'tests/react_testing_utils';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';
import TopChannels from './top_channels'; import TopChannels from './top_channels';

Просмотреть файл

@@ -4,8 +4,6 @@
import React from 'react'; import React from 'react';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
import {act} from '@testing-library/react';
import {ReactWrapper} from 'enzyme'; import {ReactWrapper} from 'enzyme';
import {BrowserRouter} from 'react-router-dom'; import {BrowserRouter} from 'react-router-dom';
@@ -13,6 +11,7 @@ import {BrowserRouter} from 'react-router-dom';
import {TimeFrames} from '@mattermost/types/insights'; import {TimeFrames} from '@mattermost/types/insights';
import {mountWithIntl} from 'tests/helpers/intl-test-helper'; import {mountWithIntl} from 'tests/helpers/intl-test-helper';
import {act} from 'tests/react_testing_utils';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';
import TopChannelsTable from './top_channels_table'; import TopChannelsTable from './top_channels_table';

Просмотреть файл

@@ -4,8 +4,6 @@
import React from 'react'; import React from 'react';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
import {act} from '@testing-library/react';
import {ReactWrapper} from 'enzyme'; import {ReactWrapper} from 'enzyme';
import {BrowserRouter} from 'react-router-dom'; import {BrowserRouter} from 'react-router-dom';
@@ -13,6 +11,7 @@ import {BrowserRouter} from 'react-router-dom';
import {TimeFrames} from '@mattermost/types/insights'; import {TimeFrames} from '@mattermost/types/insights';
import {mountWithIntl} from 'tests/helpers/intl-test-helper'; import {mountWithIntl} from 'tests/helpers/intl-test-helper';
import {act} from 'tests/react_testing_utils';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';
import NewMembersTable from './new_members_table'; import NewMembersTable from './new_members_table';

Просмотреть файл

@@ -4,8 +4,6 @@
import React from 'react'; import React from 'react';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
import {act} from '@testing-library/react';
import {ReactWrapper} from 'enzyme'; import {ReactWrapper} from 'enzyme';
import {BrowserRouter} from 'react-router-dom'; import {BrowserRouter} from 'react-router-dom';
@@ -13,6 +11,7 @@ import {BrowserRouter} from 'react-router-dom';
import {CardSizes, InsightsWidgetTypes, TimeFrames} from '@mattermost/types/insights'; import {CardSizes, InsightsWidgetTypes, TimeFrames} from '@mattermost/types/insights';
import {mountWithIntl} from 'tests/helpers/intl-test-helper'; import {mountWithIntl} from 'tests/helpers/intl-test-helper';
import {act} from 'tests/react_testing_utils';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';
import TopDMsAndNewMembers from './top_dms_and_new_members'; import TopDMsAndNewMembers from './top_dms_and_new_members';

Просмотреть файл

@@ -4,8 +4,6 @@
import React from 'react'; import React from 'react';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
import {act} from '@testing-library/react';
import {ReactWrapper} from 'enzyme'; import {ReactWrapper} from 'enzyme';
import {BrowserRouter} from 'react-router-dom'; import {BrowserRouter} from 'react-router-dom';
@@ -13,6 +11,7 @@ import {BrowserRouter} from 'react-router-dom';
import {TimeFrames} from '@mattermost/types/insights'; import {TimeFrames} from '@mattermost/types/insights';
import {mountWithIntl} from 'tests/helpers/intl-test-helper'; import {mountWithIntl} from 'tests/helpers/intl-test-helper';
import {act} from 'tests/react_testing_utils';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';
import TopDMsTable from './top_dms_table'; import TopDMsTable from './top_dms_table';

Просмотреть файл

@@ -4,8 +4,6 @@
import React from 'react'; import React from 'react';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
import {act} from '@testing-library/react';
import {ReactWrapper} from 'enzyme'; import {ReactWrapper} from 'enzyme';
import {BrowserRouter} from 'react-router-dom'; import {BrowserRouter} from 'react-router-dom';
@@ -13,6 +11,7 @@ import {BrowserRouter} from 'react-router-dom';
import {CardSizes, InsightsWidgetTypes, TimeFrames} from '@mattermost/types/insights'; import {CardSizes, InsightsWidgetTypes, TimeFrames} from '@mattermost/types/insights';
import {mountWithIntl} from 'tests/helpers/intl-test-helper'; import {mountWithIntl} from 'tests/helpers/intl-test-helper';
import {act} from 'tests/react_testing_utils';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';
import TopPlaybooks from './top_playbooks'; import TopPlaybooks from './top_playbooks';

Просмотреть файл

@@ -4,8 +4,6 @@
import React from 'react'; import React from 'react';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
import {act} from '@testing-library/react';
import {ReactWrapper} from 'enzyme'; import {ReactWrapper} from 'enzyme';
import {BrowserRouter} from 'react-router-dom'; import {BrowserRouter} from 'react-router-dom';
@@ -13,6 +11,7 @@ import {BrowserRouter} from 'react-router-dom';
import {TimeFrames} from '@mattermost/types/insights'; import {TimeFrames} from '@mattermost/types/insights';
import {mountWithIntl} from 'tests/helpers/intl-test-helper'; import {mountWithIntl} from 'tests/helpers/intl-test-helper';
import {act} from 'tests/react_testing_utils';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';
import TopPlaybooksTable from './top_playbooks_table'; import TopPlaybooksTable from './top_playbooks_table';

Просмотреть файл

@@ -4,13 +4,12 @@
import React from 'react'; import React from 'react';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
import {act} from '@testing-library/react';
import {ReactWrapper} from 'enzyme'; import {ReactWrapper} from 'enzyme';
import {CardSizes, InsightsWidgetTypes, TimeFrames} from '@mattermost/types/insights'; import {CardSizes, InsightsWidgetTypes, TimeFrames} from '@mattermost/types/insights';
import {mountWithIntl} from 'tests/helpers/intl-test-helper'; import {mountWithIntl} from 'tests/helpers/intl-test-helper';
import {act} from 'tests/react_testing_utils';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';
import TopReactions from './top_reactions'; import TopReactions from './top_reactions';

Просмотреть файл

@@ -4,13 +4,12 @@
import React from 'react'; import React from 'react';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
import {act} from '@testing-library/react';
import {ReactWrapper} from 'enzyme'; import {ReactWrapper} from 'enzyme';
import {TimeFrames} from '@mattermost/types/insights'; import {TimeFrames} from '@mattermost/types/insights';
import {mountWithIntl} from 'tests/helpers/intl-test-helper'; import {mountWithIntl} from 'tests/helpers/intl-test-helper';
import {act} from 'tests/react_testing_utils';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';
import TopReactionsTable from './top_reactions_table'; import TopReactionsTable from './top_reactions_table';

Просмотреть файл

@@ -4,8 +4,6 @@
import React from 'react'; import React from 'react';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
import {act} from '@testing-library/react';
import {ReactWrapper} from 'enzyme'; import {ReactWrapper} from 'enzyme';
import {BrowserRouter} from 'react-router-dom'; import {BrowserRouter} from 'react-router-dom';
@@ -13,6 +11,7 @@ import {BrowserRouter} from 'react-router-dom';
import {CardSizes, InsightsWidgetTypes, TimeFrames} from '@mattermost/types/insights'; import {CardSizes, InsightsWidgetTypes, TimeFrames} from '@mattermost/types/insights';
import {mountWithIntl} from 'tests/helpers/intl-test-helper'; import {mountWithIntl} from 'tests/helpers/intl-test-helper';
import {act} from 'tests/react_testing_utils';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';
import TopThreads from './top_threads'; import TopThreads from './top_threads';

Просмотреть файл

@@ -4,8 +4,6 @@
import React from 'react'; import React from 'react';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
import {act} from '@testing-library/react';
import {ReactWrapper} from 'enzyme'; import {ReactWrapper} from 'enzyme';
import {BrowserRouter} from 'react-router-dom'; import {BrowserRouter} from 'react-router-dom';
@@ -13,6 +11,7 @@ import {BrowserRouter} from 'react-router-dom';
import {PostType} from '@mattermost/types/posts'; import {PostType} from '@mattermost/types/posts';
import {mountWithIntl} from 'tests/helpers/intl-test-helper'; import {mountWithIntl} from 'tests/helpers/intl-test-helper';
import {act} from 'tests/react_testing_utils';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';
import TopThreadsItem from './top_threads_item'; import TopThreadsItem from './top_threads_item';

Просмотреть файл

@@ -4,8 +4,6 @@
import React from 'react'; import React from 'react';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
import {act} from '@testing-library/react';
import {ReactWrapper} from 'enzyme'; import {ReactWrapper} from 'enzyme';
import {BrowserRouter} from 'react-router-dom'; import {BrowserRouter} from 'react-router-dom';
@@ -13,6 +11,7 @@ import {BrowserRouter} from 'react-router-dom';
import {TimeFrames} from '@mattermost/types/insights'; import {TimeFrames} from '@mattermost/types/insights';
import {mountWithIntl} from 'tests/helpers/intl-test-helper'; import {mountWithIntl} from 'tests/helpers/intl-test-helper';
import {act} from 'tests/react_testing_utils';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';
import TopThreadsTable from './top_threads_table'; import TopThreadsTable from './top_threads_table';

Просмотреть файл

@@ -2,16 +2,15 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React, {ComponentType} from 'react'; import React, {ComponentType} from 'react';
import {screen} from '@testing-library/react';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
import {InsightsScopes} from 'utils/constants';
import {CardSizes, InsightsWidgetTypes, TimeFrames} from '@mattermost/types/insights'; import {CardSizes, InsightsWidgetTypes, TimeFrames} from '@mattermost/types/insights';
import {renderWithIntl} from 'tests/react_testing_utils';
import {renderWithIntl, screen} from 'tests/react_testing_utils';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';
import {InsightsScopes} from 'utils/constants';
import widgetHoc from './widget_hoc'; import widgetHoc from './widget_hoc';
describe('components/activity_and_insights/insights/widget_hoc', () => { describe('components/activity_and_insights/insights/widget_hoc', () => {

Просмотреть файл

@@ -3,25 +3,17 @@
import React from 'react'; import React from 'react';
import {screen} from '@testing-library/react'; import {renderWithFullContext, screen} from 'tests/react_testing_utils';
import {MenuItemBlockableLinkImpl} from './menu_item_blockable_link'; import {MenuItemBlockableLinkImpl} from './menu_item_blockable_link';
import {renderWithIntl} from 'tests/react_testing_utils';
import {Provider} from 'react-redux';
import store from 'stores/redux_store';
import {BrowserRouter} from 'react-router-dom';
describe('components/MenuItemBlockableLink', () => { describe('components/MenuItemBlockableLink', () => {
test('should render my link', () => { test('should render my link', () => {
renderWithIntl( renderWithFullContext(
<BrowserRouter> <MenuItemBlockableLinkImpl
<Provider store={store}> to='/wherever'
<MenuItemBlockableLinkImpl text='Whatever'
to='/wherever' />,
text='Whatever'
/>
</Provider>
</BrowserRouter>,
); );
screen.getByText('Whatever'); screen.getByText('Whatever');

Просмотреть файл

@@ -3,12 +3,11 @@
import React from 'react'; import React from 'react';
import {screen} from '@testing-library/react'; import {renderWithIntl, screen} from 'tests/react_testing_utils';
import {TestHelper} from 'utils/test_helper'; import {TestHelper} from 'utils/test_helper';
import AdminUserCard from 'components/admin_console/admin_user_card/admin_user_card'; import AdminUserCard from './admin_user_card';
import {renderWithIntl} from 'tests/react_testing_utils';
describe('components/admin_console/admin_user_card/admin_user_card', () => { describe('components/admin_console/admin_user_card/admin_user_card', () => {
const user = TestHelper.getUserMock({ const user = TestHelper.getUserMock({

Просмотреть файл

@@ -5,9 +5,7 @@ import React from 'react';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
import {screen} from '@testing-library/react'; import {renderWithIntl, renderWithIntlAndStore, screen} from 'tests/react_testing_utils';
import {renderWithIntl, renderWithIntlAndStore} from 'tests/react_testing_utils';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';
import {CloudLinks, HostedCustomerLinks} from 'utils/constants'; import {CloudLinks, HostedCustomerLinks} from 'utils/constants';

Просмотреть файл

@@ -2,9 +2,9 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React from 'react'; import React from 'react';
import {screen, fireEvent} from '@testing-library/react';
import {Provider} from 'react-redux'; import {GlobalState} from '@mattermost/types/store';
import {UserProfile, UsersState} from '@mattermost/types/users';
import {getPreferenceKey} from 'mattermost-redux/utils/preference_utils'; import {getPreferenceKey} from 'mattermost-redux/utils/preference_utils';
import {Preferences} from 'mattermost-redux/constants'; import {Preferences} from 'mattermost-redux/constants';
@@ -14,14 +14,11 @@ import * as useGetUsageDeltas from 'components/common/hooks/useGetUsageDeltas';
import * as useOpenCloudPurchaseModal from 'components/common/hooks/useOpenCloudPurchaseModal'; import * as useOpenCloudPurchaseModal from 'components/common/hooks/useOpenCloudPurchaseModal';
import * as useOpenPricingModal from 'components/common/hooks/useOpenPricingModal'; import * as useOpenPricingModal from 'components/common/hooks/useOpenPricingModal';
import * as useSaveBool from 'components/common/hooks/useSavePreferences'; import * as useSaveBool from 'components/common/hooks/useSavePreferences';
import {renderWithIntl} from 'tests/react_testing_utils';
import mockStore from 'tests/test_store'; import {fireEvent, renderWithFullContext, screen} from 'tests/react_testing_utils';
import {CloudProducts} from 'utils/constants'; import {CloudProducts} from 'utils/constants';
import {GlobalState} from '@mattermost/types/store';
import {UserProfile, UsersState} from '@mattermost/types/users';
import LimitReachedBanner from './limit_reached_banner'; import LimitReachedBanner from './limit_reached_banner';
const upgradeCloudKey = getPreferenceKey(Preferences.CATEGORY_UPGRADE_CLOUD, Preferences.SYSTEM_CONSOLE_LIMIT_REACHED); const upgradeCloudKey = getPreferenceKey(Preferences.CATEGORY_UPGRADE_CLOUD, Preferences.SYSTEM_CONSOLE_LIMIT_REACHED);
@@ -120,11 +117,11 @@ function makeSpies() {
describe('limits_reached_banner', () => { describe('limits_reached_banner', () => {
test('does not render when product is enterprise', () => { test('does not render when product is enterprise', () => {
const store = mockStore(state);
const spies = makeSpies(); const spies = makeSpies();
spies.useGetUsageDeltas.mockReturnValue(someLimitReached); spies.useGetUsageDeltas.mockReturnValue(someLimitReached);
renderWithIntl(<Provider store={store}><LimitReachedBanner product={enterprise}/></Provider>); renderWithFullContext(<LimitReachedBanner product={enterprise}/>, state);
expect(screen.queryByText(titleFree)).not.toBeInTheDocument(); expect(screen.queryByText(titleFree)).not.toBeInTheDocument();
expect(screen.queryByText(titleProfessional)).not.toBeInTheDocument(); expect(screen.queryByText(titleProfessional)).not.toBeInTheDocument();
}); });
@@ -143,46 +140,55 @@ describe('limits_reached_banner', () => {
}, },
}, },
}; };
const store = mockStore(myState);
const spies = makeSpies(); const spies = makeSpies();
spies.useGetUsageDeltas.mockReturnValue(someLimitReached); spies.useGetUsageDeltas.mockReturnValue(someLimitReached);
renderWithIntl(<Provider store={store}><LimitReachedBanner product={enterprise}/></Provider>);
renderWithFullContext(<LimitReachedBanner product={enterprise}/>, myState);
expect(screen.queryByText(titleFree)).not.toBeInTheDocument(); expect(screen.queryByText(titleFree)).not.toBeInTheDocument();
expect(screen.queryByText(titleProfessional)).not.toBeInTheDocument(); expect(screen.queryByText(titleProfessional)).not.toBeInTheDocument();
}); });
test('does not render when no limit reached', () => { test('does not render when no limit reached', () => {
const store = mockStore(state);
const spies = makeSpies(); const spies = makeSpies();
spies.useGetUsageDeltas.mockReturnValue(noLimitReached); spies.useGetUsageDeltas.mockReturnValue(noLimitReached);
renderWithIntl(<Provider store={store}><LimitReachedBanner product={free}/></Provider>);
renderWithFullContext(<LimitReachedBanner product={free}/>, state);
expect(screen.queryByText(titleFree)).not.toBeInTheDocument(); expect(screen.queryByText(titleFree)).not.toBeInTheDocument();
expect(screen.queryByText(titleProfessional)).not.toBeInTheDocument(); expect(screen.queryByText(titleProfessional)).not.toBeInTheDocument();
}); });
test('renders free banner', () => { test('renders free banner', () => {
const store = mockStore(state);
const spies = makeSpies(); const spies = makeSpies();
const mockOpenPricingModal = jest.fn(); const mockOpenPricingModal = jest.fn();
spies.useOpenPricingModal.mockReturnValue(mockOpenPricingModal); spies.useOpenPricingModal.mockReturnValue(mockOpenPricingModal);
spies.useGetUsageDeltas.mockReturnValue(someLimitReached); spies.useGetUsageDeltas.mockReturnValue(someLimitReached);
renderWithIntl(<Provider store={store}><LimitReachedBanner product={free}/></Provider>);
renderWithFullContext(<LimitReachedBanner product={free}/>, state);
screen.getByText(titleFree); screen.getByText(titleFree);
expect(screen.queryByText(titleProfessional)).not.toBeInTheDocument(); expect(screen.queryByText(titleProfessional)).not.toBeInTheDocument();
fireEvent.click(screen.getByText('View plans')); fireEvent.click(screen.getByText('View plans'));
expect(mockOpenPricingModal).toHaveBeenCalled(); expect(mockOpenPricingModal).toHaveBeenCalled();
}); });
test('clicking Contact Sales opens sales link', () => { test('clicking Contact Sales opens sales link', () => {
const store = mockStore(state);
const spies = makeSpies(); const spies = makeSpies();
const mockOpenSalesLink = jest.fn(); const mockOpenSalesLink = jest.fn();
spies.useOpenSalesLink.mockReturnValue([mockOpenSalesLink, '']); spies.useOpenSalesLink.mockReturnValue([mockOpenSalesLink, '']);
spies.useGetUsageDeltas.mockReturnValue(someLimitReached); spies.useGetUsageDeltas.mockReturnValue(someLimitReached);
renderWithIntl(<Provider store={store}><LimitReachedBanner product={free}/></Provider>);
renderWithFullContext(<LimitReachedBanner product={free}/>, state);
screen.getByText(titleFree); screen.getByText(titleFree);
expect(screen.queryByText(titleProfessional)).not.toBeInTheDocument(); expect(screen.queryByText(titleProfessional)).not.toBeInTheDocument();
fireEvent.click(screen.getByText('Contact sales')); fireEvent.click(screen.getByText('Contact sales'));
expect(mockOpenSalesLink).toHaveBeenCalled(); expect(mockOpenSalesLink).toHaveBeenCalled();
}); });
}); });

Просмотреть файл

@@ -3,12 +3,10 @@
import React from 'react'; import React from 'react';
import {screen} from '@testing-library/react';
import * as redux from 'react-redux'; import * as redux from 'react-redux';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
import {renderWithIntl} from 'tests/react_testing_utils'; import {renderWithIntl, screen} from 'tests/react_testing_utils';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';
import * as cloudActions from 'actions/cloud'; import * as cloudActions from 'actions/cloud';

Просмотреть файл

@@ -2,9 +2,8 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React from 'react'; import React from 'react';
import {screen} from '@testing-library/react';
import {renderWithIntlAndStore} from 'tests/react_testing_utils'; import {renderWithIntlAndStore, screen} from 'tests/react_testing_utils';
import {CloudProducts} from 'utils/constants'; import {CloudProducts} from 'utils/constants';
import {ToPaidNudgeBanner, ToPaidPlanBannerDismissable} from './to_paid_plan_nudge_banner'; import {ToPaidNudgeBanner, ToPaidPlanBannerDismissable} from './to_paid_plan_nudge_banner';

Просмотреть файл

@@ -2,9 +2,8 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React from 'react'; import React from 'react';
import {screen} from '@testing-library/react';
import {renderWithIntlAndStore} from 'tests/react_testing_utils'; import {renderWithIntlAndStore, screen} from 'tests/react_testing_utils';
import {CloudProducts, RecurringIntervals} from 'utils/constants'; import {CloudProducts, RecurringIntervals} from 'utils/constants';
import {ToYearlyNudgeBanner, ToYearlyNudgeBannerDismissable} from './to_yearly_nudge_banner'; import {ToYearlyNudgeBanner, ToYearlyNudgeBannerDismissable} from './to_yearly_nudge_banner';

Просмотреть файл

@@ -3,9 +3,9 @@
import React from 'react'; import React from 'react';
import ColorSetting from 'components/admin_console/color_setting'; import {renderWithIntl, screen} from 'tests/react_testing_utils';
import {renderWithIntl} from 'tests/react_testing_utils';
import {screen} from '@testing-library/react'; import ColorSetting from './color_setting';
describe('components/ColorSetting', () => { describe('components/ColorSetting', () => {
test('should match snapshot, all', () => { test('should match snapshot, all', () => {

Просмотреть файл

@@ -2,17 +2,22 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React from 'react'; import React from 'react';
import {Provider as ReduxProvider} from 'react-redux';
import FeatureDiscovery from 'components/admin_console/feature_discovery/feature_discovery'; import FeatureDiscovery from 'components/admin_console/feature_discovery/feature_discovery';
import store from 'stores/redux_store';
import {
renderWithIntl,
screen,
userEvent,
waitFor,
} from 'tests/react_testing_utils';
import {LicenseSkus} from 'utils/constants'; import {LicenseSkus} from 'utils/constants';
import SamlSVG from './features/images/saml_svg'; import SamlSVG from './features/images/saml_svg';
import {renderWithIntl} from 'tests/react_testing_utils';
import {screen, waitFor} from '@testing-library/react';
import {Provider as ReduxProvider} from 'react-redux';
import store from 'stores/redux_store';
import userEvent from '@testing-library/user-event';
describe('components/feature_discovery', () => { describe('components/feature_discovery', () => {
describe('FeatureDiscovery', () => { describe('FeatureDiscovery', () => {

Просмотреть файл

@@ -2,14 +2,13 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React from 'react'; import React from 'react';
import {screen} from '@testing-library/react';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
import moment from 'moment-timezone'; import moment from 'moment-timezone';
import {mountWithIntl} from 'tests/helpers/intl-test-helper'; import {mountWithIntl} from 'tests/helpers/intl-test-helper';
import {renderWithIntl} from 'tests/react_testing_utils'; import {renderWithIntl, screen} from 'tests/react_testing_utils';
import {OverActiveUserLimits, SelfHostedProducts} from 'utils/constants'; import {OverActiveUserLimits, SelfHostedProducts} from 'utils/constants';
import {TestHelper} from 'utils/test_helper'; import {TestHelper} from 'utils/test_helper';

Просмотреть файл

@@ -3,9 +3,9 @@
import React from 'react'; import React from 'react';
import {renderWithIntl, screen} from 'tests/react_testing_utils';
import AdminTextSetting from './text_setting'; import AdminTextSetting from './text_setting';
import {renderWithIntl} from 'tests/react_testing_utils';
import {screen} from '@testing-library/react';
describe('components/admin_console/TextSetting', () => { describe('components/admin_console/TextSetting', () => {
test('render component with required props', () => { test('render component with required props', () => {

Просмотреть файл

@@ -2,12 +2,11 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React from 'react'; import React from 'react';
import {screen} from '@testing-library/react';
import {GlobalState} from '@mattermost/types/store'; import {GlobalState} from '@mattermost/types/store';
import {DeepPartial} from '@mattermost/types/utilities'; import {DeepPartial} from '@mattermost/types/utilities';
import {renderWithIntlAndStore} from 'tests/react_testing_utils'; import {renderWithIntlAndStore, screen} from 'tests/react_testing_utils';
import * as useCWSAvailabilityCheckAll from 'components/common/hooks/useCWSAvailabilityCheck'; import * as useCWSAvailabilityCheckAll from 'components/common/hooks/useCWSAvailabilityCheck';
import {LicenseSkus} from 'utils/constants'; import {LicenseSkus} from 'utils/constants';

Просмотреть файл

@@ -2,11 +2,15 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React, {ComponentProps} from 'react'; import React, {ComponentProps} from 'react';
import {fireEvent, screen, waitFor} from '@testing-library/react';
import * as reactRedux from 'react-redux'; import * as reactRedux from 'react-redux';
import configureStore from 'store'; import configureStore from 'store';
import {renderWithIntl} from 'tests/react_testing_utils'; import {
fireEvent,
renderWithIntl,
screen,
waitFor,
} from 'tests/react_testing_utils';
import {CloudProducts, Preferences, TELEMETRY_CATEGORIES} from 'utils/constants'; import {CloudProducts, Preferences, TELEMETRY_CATEGORIES} from 'utils/constants';
import {savePreferences} from 'mattermost-redux/actions/preferences'; import {savePreferences} from 'mattermost-redux/actions/preferences';
import {Client4} from 'mattermost-redux/client'; import {Client4} from 'mattermost-redux/client';

Просмотреть файл

@@ -2,13 +2,12 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React from 'react'; import React from 'react';
import {fireEvent, screen} from '@testing-library/react';
import {DeepPartial} from '@mattermost/types/utilities'; import {DeepPartial} from '@mattermost/types/utilities';
import {GlobalState} from 'types/store'; import {GlobalState} from 'types/store';
import {General} from 'mattermost-redux/constants'; import {General} from 'mattermost-redux/constants';
import {OverActiveUserLimits, Preferences, SelfHostedProducts, StatTypes} from 'utils/constants'; import {OverActiveUserLimits, Preferences, SelfHostedProducts, StatTypes} from 'utils/constants';
import {renderWithIntlAndStore} from 'tests/react_testing_utils'; import {fireEvent, renderWithIntlAndStore, screen} from 'tests/react_testing_utils';
import {savePreferences} from 'mattermost-redux/actions/preferences'; import {savePreferences} from 'mattermost-redux/actions/preferences';
import {trackEvent} from 'actions/telemetry_actions'; import {trackEvent} from 'actions/telemetry_actions';
import {getLicenseSelfServeStatus} from 'mattermost-redux/actions/cloud'; import {getLicenseSelfServeStatus} from 'mattermost-redux/actions/cloud';

Просмотреть файл

@@ -2,8 +2,7 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React from 'react'; import React from 'react';
import {screen} from '@testing-library/react'; import {renderWithIntlAndStore, screen} from 'tests/react_testing_utils';
import {renderWithIntlAndStore} from 'tests/react_testing_utils';
import * as cloudActions from 'mattermost-redux/actions/cloud'; import * as cloudActions from 'mattermost-redux/actions/cloud';
import {CloudProducts} from 'utils/constants'; import {CloudProducts} from 'utils/constants';

Просмотреть файл

@@ -3,10 +3,9 @@
import React from 'react'; import React from 'react';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
import {screen} from '@testing-library/react';
import {makeEmptyUsage} from 'utils/limits_test'; import {makeEmptyUsage} from 'utils/limits_test';
import {renderWithIntl} from 'tests/react_testing_utils'; import {renderWithIntl, screen} from 'tests/react_testing_utils';
import testConfigureStore from 'tests/test_store'; import testConfigureStore from 'tests/test_store';
import {adminUsersState, endUsersState} from 'tests/constants/users'; import {adminUsersState, endUsersState} from 'tests/constants/users';
import {emptyLimits} from 'tests/constants/cloud'; import {emptyLimits} from 'tests/constants/cloud';

Просмотреть файл

@@ -2,10 +2,9 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React from 'react'; import React from 'react';
import {screen} from '@testing-library/react';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
import {renderWithIntl} from 'tests/react_testing_utils'; import {renderWithIntl, screen} from 'tests/react_testing_utils';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';
import {Channel} from '@mattermost/types/channels'; import {Channel} from '@mattermost/types/channels';

Просмотреть файл

@@ -2,10 +2,9 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React from 'react'; import React from 'react';
import {screen} from '@testing-library/react';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
import {renderWithIntl} from 'tests/react_testing_utils'; import {renderWithIntl, screen} from 'tests/react_testing_utils';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';
import Constants from 'utils/constants'; import Constants from 'utils/constants';
import {Channel} from '@mattermost/types/channels'; import {Channel} from '@mattermost/types/channels';

Просмотреть файл

@@ -2,10 +2,9 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React from 'react'; import React from 'react';
import {screen} from '@testing-library/react';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
import {renderWithIntl} from 'tests/react_testing_utils'; import {renderWithIntl, screen} from 'tests/react_testing_utils';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';
import {Channel} from '@mattermost/types/channels'; import {Channel} from '@mattermost/types/channels';
import {UserProfile} from '@mattermost/types/users'; import {UserProfile} from '@mattermost/types/users';

Просмотреть файл

@@ -3,9 +3,7 @@
import React from 'react'; import React from 'react';
import {act} from '@testing-library/react'; import {act, renderWithIntl} from 'tests/react_testing_utils';
import {renderWithIntl} from 'tests/react_testing_utils';
import {Channel, ChannelStats} from '@mattermost/types/channels'; import {Channel, ChannelStats} from '@mattermost/types/channels';
import {UserProfile} from '@mattermost/types/users'; import {UserProfile} from '@mattermost/types/users';

Просмотреть файл

@@ -2,9 +2,8 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React from 'react'; import React from 'react';
import {fireEvent, screen} from '@testing-library/react';
import {renderWithIntl} from 'tests/react_testing_utils'; import {fireEvent, renderWithIntl, screen} from 'tests/react_testing_utils';
import EditableArea from './editable_area'; import EditableArea from './editable_area';

Просмотреть файл

@@ -2,10 +2,9 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React from 'react'; import React from 'react';
import {fireEvent, screen} from '@testing-library/react';
import {Channel} from '@mattermost/types/channels'; import {Channel} from '@mattermost/types/channels';
import {renderWithIntl} from 'tests/react_testing_utils'; import {fireEvent, renderWithIntl, screen} from 'tests/react_testing_utils';
import Header from './header'; import Header from './header';

Просмотреть файл

@@ -2,9 +2,13 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React from 'react'; import React from 'react';
import {act, fireEvent, screen} from '@testing-library/react';
import {renderWithIntl} from 'tests/react_testing_utils'; import {
act,
fireEvent,
renderWithIntl,
screen,
} from 'tests/react_testing_utils';
import Constants from 'utils/constants'; import Constants from 'utils/constants';
import {Channel, ChannelStats} from '@mattermost/types/channels'; import {Channel, ChannelStats} from '@mattermost/types/channels';

Просмотреть файл

@@ -2,9 +2,8 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React from 'react'; import React from 'react';
import {fireEvent, screen} from '@testing-library/react';
import {renderWithIntl} from 'tests/react_testing_utils'; import {fireEvent, renderWithIntl, screen} from 'tests/react_testing_utils';
import Constants from 'utils/constants'; import Constants from 'utils/constants';
import TopButtons, {Props} from './top_buttons'; import TopButtons, {Props} from './top_buttons';

Просмотреть файл

@@ -2,9 +2,8 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React from 'react'; import React from 'react';
import {fireEvent, screen} from '@testing-library/react';
import {renderWithIntl} from 'tests/react_testing_utils'; import {fireEvent, renderWithIntl, screen} from 'tests/react_testing_utils';
import Constants from 'utils/constants'; import Constants from 'utils/constants';
import ActionBar, {Props} from './action_bar'; import ActionBar, {Props} from './action_bar';

Просмотреть файл

@@ -3,12 +3,10 @@
import React from 'react'; import React from 'react';
import {screen} from '@testing-library/react';
import * as redux from 'react-redux'; import * as redux from 'react-redux';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
import {renderWithIntl} from 'tests/react_testing_utils'; import {renderWithIntl, screen} from 'tests/react_testing_utils';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';
import {FileSizes} from 'utils/file_utils'; import {FileSizes} from 'utils/file_utils';

Просмотреть файл

@@ -2,10 +2,9 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React, {ReactPortal} from 'react'; import React, {ReactPortal} from 'react';
import {screen} from '@testing-library/react';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
import {renderWithIntl} from 'tests/react_testing_utils'; import {renderWithIntl, screen} from 'tests/react_testing_utils';
import {TestHelper} from 'utils/test_helper'; import {TestHelper} from 'utils/test_helper';
import {Preferences} from 'utils/constants'; import {Preferences} from 'utils/constants';

Просмотреть файл

@@ -2,10 +2,9 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React, {ComponentProps} from 'react'; import React, {ComponentProps} from 'react';
import {fireEvent, screen} from '@testing-library/react';
import * as reactRedux from 'react-redux'; import * as reactRedux from 'react-redux';
import {renderWithIntl} from 'tests/react_testing_utils'; import {fireEvent, renderWithIntl, screen} from 'tests/react_testing_utils';
import {savePreferences} from 'mattermost-redux/actions/preferences'; import {savePreferences} from 'mattermost-redux/actions/preferences';
import {trackEvent} from 'actions/telemetry_actions'; import {trackEvent} from 'actions/telemetry_actions';
import configureStore from 'store'; import configureStore from 'store';

Просмотреть файл

@@ -2,7 +2,6 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React from 'react'; import React from 'react';
import {screen} from '@testing-library/react';
import * as reactRedux from 'react-redux'; import * as reactRedux from 'react-redux';
import {CloudProducts, ModalIdentifiers, Preferences} from 'utils/constants'; import {CloudProducts, ModalIdentifiers, Preferences} from 'utils/constants';
@@ -10,7 +9,7 @@ import * as StorageSelectors from 'selectors/storage';
import configureStore from 'store'; import configureStore from 'store';
import {TestHelper} from 'utils/test_helper'; import {TestHelper} from 'utils/test_helper';
import ModalController from 'components/modal_controller'; import ModalController from 'components/modal_controller';
import {renderWithIntl} from 'tests/react_testing_utils'; import {renderWithIntl, screen} from 'tests/react_testing_utils';
import * as cloudActions from 'mattermost-redux/actions/cloud'; import * as cloudActions from 'mattermost-redux/actions/cloud';
import DelinquencyModalController from './index'; import DelinquencyModalController from './index';

Просмотреть файл

@@ -2,10 +2,9 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React, {ComponentProps} from 'react'; import React, {ComponentProps} from 'react';
import {fireEvent, screen} from '@testing-library/react';
import * as reactRedux from 'react-redux'; import * as reactRedux from 'react-redux';
import {renderWithIntl} from 'tests/react_testing_utils'; import {fireEvent, renderWithIntl, screen} from 'tests/react_testing_utils';
import {trackEvent} from 'actions/telemetry_actions'; import {trackEvent} from 'actions/telemetry_actions';
import configureStore from 'store'; import configureStore from 'store';
import {ModalIdentifiers, TELEMETRY_CATEGORIES} from 'utils/constants'; import {ModalIdentifiers, TELEMETRY_CATEGORIES} from 'utils/constants';

Просмотреть файл

@@ -2,12 +2,11 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React from 'react'; import React from 'react';
import {screen, fireEvent} from '@testing-library/react';
import {shallowWithIntl} from 'tests/helpers/intl-test-helper'; import {shallowWithIntl} from 'tests/helpers/intl-test-helper';
import {Locations} from 'utils/constants'; import {Locations} from 'utils/constants';
import {TestHelper} from 'utils/test_helper'; import {TestHelper} from 'utils/test_helper';
import {renderWithIntlAndStore} from 'tests/react_testing_utils'; import {fireEvent, renderWithIntlAndStore, screen} from 'tests/react_testing_utils';
import {GlobalState} from 'types/store'; import {GlobalState} from 'types/store';
import {DeepPartial} from '@mattermost/types/utilities'; import {DeepPartial} from '@mattermost/types/utilities';

Просмотреть файл

@@ -2,12 +2,13 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React from 'react'; import React from 'react';
import {render, screen} from '@testing-library/react';
import {IntlProvider} from 'react-intl'; import {IntlProvider} from 'react-intl';
import {render, screen} from 'tests/react_testing_utils';
import EmojiMap from 'utils/emoji_map'; import EmojiMap from 'utils/emoji_map';
import EmojiPicker from 'components/emoji_picker/emoji_picker'; import EmojiPicker from './emoji_picker';
jest.mock('components/emoji_picker/components/emoji_picker_skin', () => () => ( jest.mock('components/emoji_picker/components/emoji_picker_skin', () => () => (
<div/> <div/>

Просмотреть файл

@@ -2,12 +2,11 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React from 'react'; import React from 'react';
import {screen} from '@testing-library/react';
import {BrowserRouter} from 'react-router-dom'; import {BrowserRouter} from 'react-router-dom';
import {GlobalState} from '@mattermost/types/store'; import {GlobalState} from '@mattermost/types/store';
import {renderWithIntlAndStore} from 'tests/react_testing_utils'; import {renderWithIntlAndStore, screen} from 'tests/react_testing_utils';
import {ErrorPageTypes} from 'utils/constants'; import {ErrorPageTypes} from 'utils/constants';

Просмотреть файл

@@ -3,7 +3,6 @@
import React from 'react'; import React from 'react';
import {mount} from 'enzyme'; import {mount} from 'enzyme';
import {screen} from '@testing-library/react';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
@@ -11,7 +10,7 @@ import {DeepPartial} from 'redux';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';
import {renderWithIntlAndStore} from 'tests/react_testing_utils'; import {renderWithIntlAndStore, screen} from 'tests/react_testing_utils';
import {GlobalState} from 'types/store'; import {GlobalState} from 'types/store';

Просмотреть файл

@@ -4,11 +4,9 @@
import {shallow} from 'enzyme'; import {shallow} from 'enzyme';
import React from 'react'; import React from 'react';
import {screen} from '@testing-library/react';
import {mountWithIntl} from 'tests/helpers/intl-test-helper'; import {mountWithIntl} from 'tests/helpers/intl-test-helper';
import {renderWithIntl, renderWithIntlAndStore} from 'tests/react_testing_utils'; import {renderWithIntl, renderWithIntlAndStore, screen} from 'tests/react_testing_utils';
import {GlobalState} from '@mattermost/types/store'; import {GlobalState} from '@mattermost/types/store';

Просмотреть файл

@@ -2,10 +2,9 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React from 'react'; import React from 'react';
import {screen} from '@testing-library/react';
import {mountWithIntl} from 'tests/helpers/intl-test-helper'; import {mountWithIntl} from 'tests/helpers/intl-test-helper';
import {renderWithIntl} from 'tests/react_testing_utils'; import {renderWithIntl, screen} from 'tests/react_testing_utils';
import deepFreeze from 'mattermost-redux/utils/deep_freeze'; import deepFreeze from 'mattermost-redux/utils/deep_freeze';
import {Channel} from '@mattermost/types/channels'; import {Channel} from '@mattermost/types/channels';
import CloseCircleIcon from 'components/widgets/icons/close_circle_icon'; import CloseCircleIcon from 'components/widgets/icons/close_circle_icon';

Просмотреть файл

@@ -2,13 +2,17 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React from 'react'; import React from 'react';
import {act, fireEvent, screen} from '@testing-library/react';
import {DeepPartial} from '@mattermost/types/utilities'; import {DeepPartial} from '@mattermost/types/utilities';
import {GlobalState} from 'types/store'; import {GlobalState} from 'types/store';
import {General} from 'mattermost-redux/constants'; import {General} from 'mattermost-redux/constants';
import {LicenseLinks, OverActiveUserLimits, Preferences, SelfHostedProducts, StatTypes} from 'utils/constants'; import {LicenseLinks, OverActiveUserLimits, Preferences, SelfHostedProducts, StatTypes} from 'utils/constants';
import {renderWithIntlAndStore} from 'tests/react_testing_utils'; import {
act,
fireEvent,
renderWithIntlAndStore,
screen,
} from 'tests/react_testing_utils';
import {savePreferences} from 'mattermost-redux/actions/preferences'; import {savePreferences} from 'mattermost-redux/actions/preferences';
import {trackEvent} from 'actions/telemetry_actions'; import {trackEvent} from 'actions/telemetry_actions';
import {TestHelper} from 'utils/test_helper'; import {TestHelper} from 'utils/test_helper';

Просмотреть файл

@@ -4,18 +4,25 @@
import React from 'react'; import React from 'react';
import {act} from 'react-dom/test-utils'; import {act} from 'react-dom/test-utils';
import {createChannel} from 'mattermost-redux/actions/channels';
import Permissions from 'mattermost-redux/constants/permissions';
import {
render,
renderWithIntl,
screen,
userEvent,
waitFor,
} from 'tests/react_testing_utils';
import {GlobalState} from 'types/store';
import {suitePluginIds} from 'utils/constants'; import {suitePluginIds} from 'utils/constants';
import {cleanUpUrlable} from 'utils/url'; import {cleanUpUrlable} from 'utils/url';
import {GlobalState} from 'types/store';
import Permissions from 'mattermost-redux/constants/permissions';
import {createChannel} from 'mattermost-redux/actions/channels';
jest.mock('mattermost-redux/actions/channels');
import NewChannelModal from './new_channel_modal'; import NewChannelModal from './new_channel_modal';
import {render, screen, waitFor} from '@testing-library/react';
import userEvent from '@testing-library/user-event'; jest.mock('mattermost-redux/actions/channels');
import {renderWithIntl} from 'tests/react_testing_utils';
const mockDispatch = jest.fn(); const mockDispatch = jest.fn();
let mockState: GlobalState; let mockState: GlobalState;

Просмотреть файл

@@ -1,11 +1,15 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import {fireEvent, screen, act} from '@testing-library/react';
import React from 'react'; import React from 'react';
import * as reactRedux from 'react-redux'; import * as reactRedux from 'react-redux';
import {renderWithIntlAndStore} from 'tests/react_testing_utils'; import {
act,
fireEvent,
renderWithIntlAndStore,
screen,
} from 'tests/react_testing_utils';
import {TestHelper} from 'utils/test_helper'; import {TestHelper} from 'utils/test_helper';
import {GatherIntent} from './gather_intent'; import {GatherIntent} from './gather_intent';

Просмотреть файл

@@ -1,10 +1,9 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import {fireEvent, screen} from '@testing-library/react';
import React from 'react'; import React from 'react';
import {renderWithIntl} from 'tests/react_testing_utils'; import {fireEvent, renderWithIntl, screen} from 'tests/react_testing_utils';
import {GatherIntentModal, GatherIntentModalProps} from './gather_intent_modal'; import {GatherIntentModal, GatherIntentModalProps} from './gather_intent_modal';

Просмотреть файл

@@ -1,12 +1,11 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import {screen} from '@testing-library/react';
import React from 'react'; import React from 'react';
import {DeepPartial} from '@mattermost/types/utilities'; import {DeepPartial} from '@mattermost/types/utilities';
import {renderWithFullContext} from 'tests/react_testing_utils'; import {renderWithFullContext, screen} from 'tests/react_testing_utils';
import {GlobalState} from 'types/store'; import {GlobalState} from 'types/store';

Просмотреть файл

@@ -3,8 +3,9 @@
import React from 'react'; import React from 'react';
import {render, screen} from 'tests/react_testing_utils';
import PostEmoji from './post_emoji'; import PostEmoji from './post_emoji';
import {render, screen} from '@testing-library/react';
describe('PostEmoji', () => { describe('PostEmoji', () => {
const baseProps = { const baseProps = {

Просмотреть файл

@@ -3,14 +3,15 @@
import React from 'react'; import React from 'react';
import {Post, PostType} from '@mattermost/types/posts';
import {Posts} from 'mattermost-redux/constants'; import {Posts} from 'mattermost-redux/constants';
import PostMarkdown from 'components/post_markdown/post_markdown'; import {renderWithIntlAndStore, screen} from 'tests/react_testing_utils';
import {TestHelper} from 'utils/test_helper'; import {TestHelper} from 'utils/test_helper';
import {Post, PostType} from '@mattermost/types/posts'; import PostMarkdown from './post_markdown';
import {screen} from '@testing-library/react';
import {renderWithIntlAndStore} from 'tests/react_testing_utils';
describe('components/PostMarkdown', () => { describe('components/PostMarkdown', () => {
const baseProps = { const baseProps = {

Просмотреть файл

@@ -3,10 +3,11 @@
import React, {ComponentProps} from 'react'; import React, {ComponentProps} from 'react';
import {render, screen} from 'tests/react_testing_utils';
import {TestHelper} from 'utils/test_helper'; import {TestHelper} from 'utils/test_helper';
import PostProfilePicture from './post_profile_picture'; import PostProfilePicture from './post_profile_picture';
import {render, screen} from '@testing-library/react';
type Props = ComponentProps<typeof PostProfilePicture>; type Props = ComponentProps<typeof PostProfilePicture>;

Просмотреть файл

@@ -9,8 +9,7 @@ import {UserProfile} from '@mattermost/types/users';
import {Channel, ChannelType} from '@mattermost/types/channels'; import {Channel, ChannelType} from '@mattermost/types/channels';
import ChannelIntroMessage from './channel_intro_message'; import ChannelIntroMessage from './channel_intro_message';
import {screen} from '@testing-library/react'; import {renderWithIntlAndStore, screen} from 'tests/react_testing_utils';
import {renderWithIntlAndStore} from 'tests/react_testing_utils';
import {TestHelper} from 'utils/test_helper'; import {TestHelper} from 'utils/test_helper';
describe('components/post_view/ChannelIntroMessages', () => { describe('components/post_view/ChannelIntroMessages', () => {

Просмотреть файл

@@ -5,11 +5,11 @@ import React from 'react';
import {Posts} from 'mattermost-redux/constants'; import {Posts} from 'mattermost-redux/constants';
import LastUsers from './last_users'; import {renderWithIntlAndStore, screen, userEvent} from 'tests/react_testing_utils';
import {renderWithIntlAndStore} from 'tests/react_testing_utils';
import {screen} from '@testing-library/react';
import {TestHelper} from 'utils/test_helper'; import {TestHelper} from 'utils/test_helper';
import userEvent from '@testing-library/user-event';
import LastUsers from './last_users';
describe('components/post_view/combined_system_message/LastUsers', () => { describe('components/post_view/combined_system_message/LastUsers', () => {
const formatOptions = { const formatOptions = {

Просмотреть файл

@@ -3,9 +3,9 @@
import React from 'react'; import React from 'react';
import {render, renderWithIntl, screen} from 'tests/react_testing_utils';
import CommentedOnFilesMessage from './commented_on_files_message'; import CommentedOnFilesMessage from './commented_on_files_message';
import {render, screen} from '@testing-library/react';
import {renderWithIntl} from 'tests/react_testing_utils';
describe('components/CommentedOnFilesMessage', () => { describe('components/CommentedOnFilesMessage', () => {
const baseProps = { const baseProps = {

Просмотреть файл

@@ -3,9 +3,9 @@
import React from 'react'; import React from 'react';
import DateSeparator from 'components/post_view/date_separator/date_separator'; import {renderWithIntlAndStore, screen} from 'tests/react_testing_utils';
import {screen} from '@testing-library/react';
import {renderWithIntlAndStore} from 'tests/react_testing_utils'; import DateSeparator from './date_separator';
describe('components/post_view/DateSeparator', () => { describe('components/post_view/DateSeparator', () => {
const initialState = { const initialState = {

Просмотреть файл

@@ -4,13 +4,17 @@
import React from 'react'; import React from 'react';
import {AppBinding, AppCallResponse} from '@mattermost/types/apps'; import {AppBinding, AppCallResponse} from '@mattermost/types/apps';
import {Post} from '@mattermost/types/posts'; import {Post} from '@mattermost/types/posts';
import {
renderWithIntlAndStore,
screen,
userEvent,
waitFor,
} from 'tests/react_testing_utils';
import ButtonBinding, {ButtonBinding as ButtonBindingUnwrapped} from './button_binding'; import ButtonBinding, {ButtonBinding as ButtonBindingUnwrapped} from './button_binding';
import {renderWithIntlAndStore} from 'tests/react_testing_utils';
import {screen, waitFor} from '@testing-library/react';
import userEvent from '@testing-library/user-event';
describe('components/post_view/embedded_bindings/button_binding/', () => { describe('components/post_view/embedded_bindings/button_binding/', () => {
const post = { const post = {
id: 'some_post_id', id: 'some_post_id',

Просмотреть файл

@@ -3,12 +3,11 @@
import React from 'react'; import React from 'react';
import {TestHelper} from 'utils/test_helper';
import FailedPostOptions from 'components/post_view/failed_post_options/failed_post_options'; import FailedPostOptions from 'components/post_view/failed_post_options/failed_post_options';
import {renderWithIntl} from 'tests/react_testing_utils';
import {screen} from '@testing-library/react'; import {renderWithIntl, screen, userEvent} from 'tests/react_testing_utils';
import userEvent from '@testing-library/user-event';
import {TestHelper} from 'utils/test_helper';
describe('components/post_view/FailedPostOptions', () => { describe('components/post_view/FailedPostOptions', () => {
const baseProps = { const baseProps = {

Просмотреть файл

@@ -3,9 +3,9 @@
import React from 'react'; import React from 'react';
import {renderWithIntlAndStore, screen} from 'tests/react_testing_utils';
import FloatingTimestamp from './floating_timestamp'; import FloatingTimestamp from './floating_timestamp';
import {screen} from '@testing-library/react';
import {renderWithIntlAndStore} from 'tests/react_testing_utils';
describe('components/post_view/FloatingTimestamp', () => { describe('components/post_view/FloatingTimestamp', () => {
const baseProps = { const baseProps = {

Просмотреть файл

@@ -3,13 +3,13 @@
import React from 'react'; import React from 'react';
import {Preferences} from 'mattermost-redux/constants';
import {Theme} from 'mattermost-redux/selectors/entities/preferences'; import {Theme} from 'mattermost-redux/selectors/entities/preferences';
import {changeOpacity} from 'mattermost-redux/utils/theme_utils'; import {changeOpacity} from 'mattermost-redux/utils/theme_utils';
import {Preferences} from 'mattermost-redux/constants';
import ActionButton from 'components/post_view/message_attachments/action_button/action_button'; import {render, screen, userEvent} from 'tests/react_testing_utils';
import {render, screen} from '@testing-library/react';
import userEvent from '@testing-library/user-event'; import ActionButton from './action_button';
describe('components/post_view/message_attachments/action_button.jsx', () => { describe('components/post_view/message_attachments/action_button.jsx', () => {
const baseProps = { const baseProps = {

Просмотреть файл

@@ -3,9 +3,9 @@
import React from 'react'; import React from 'react';
import {renderWithIntlAndStore, screen} from 'tests/react_testing_utils';
import ActionMenu from './action_menu'; import ActionMenu from './action_menu';
import {screen} from '@testing-library/react';
import {renderWithIntlAndStore} from 'tests/react_testing_utils';
describe('components/post_view/message_attachments/ActionMenu', () => { describe('components/post_view/message_attachments/ActionMenu', () => {
const baseProps = { const baseProps = {

Просмотреть файл

@@ -3,9 +3,9 @@
import React from 'react'; import React from 'react';
import {renderWithIntl, screen} from 'tests/react_testing_utils';
import NewMessageSeparator from './new_message_separator'; import NewMessageSeparator from './new_message_separator';
import {screen} from '@testing-library/react';
import {renderWithIntl} from 'tests/react_testing_utils';
describe('components/post_view/new_message_separator', () => { describe('components/post_view/new_message_separator', () => {
test('should render new_message_separator', () => { test('should render new_message_separator', () => {

Просмотреть файл

@@ -3,12 +3,12 @@
import React from 'react'; import React from 'react';
import PostAttachmentContainer, {Props} from './post_attachment_container'; import {renderWithIntlAndStore, screen} from 'tests/react_testing_utils';
import {screen} from '@testing-library/react';
import {renderWithIntlAndStore} from 'tests/react_testing_utils';
import {DeepPartial} from '@mattermost/types/utilities'; import {DeepPartial} from '@mattermost/types/utilities';
import {GlobalState} from '@mattermost/types/store'; import {GlobalState} from '@mattermost/types/store';
import PostAttachmentContainer, {Props} from './post_attachment_container';
describe('PostAttachmentContainer', () => { describe('PostAttachmentContainer', () => {
const baseProps: Props = { const baseProps: Props = {
children: <p>{'some children'}</p>, children: <p>{'some children'}</p>,

Просмотреть файл

@@ -3,18 +3,17 @@
import React from 'react'; import React from 'react';
import {createIntl, useIntl} from 'react-intl'; import {createIntl, useIntl} from 'react-intl';
import {Provider} from 'react-redux';
import enMessages from 'i18n/en.json'; import enMessages from 'i18n/en.json';
import esMessages from 'i18n/es.json'; import esMessages from 'i18n/es.json';
import {render, renderWithIntlAndStore, screen} from 'tests/react_testing_utils';
import {mockStore} from 'tests/test_store'; import {mockStore} from 'tests/test_store';
import {TestHelper} from 'utils/test_helper'; import {TestHelper} from 'utils/test_helper';
import LatestPostReader from './latest_post_reader'; import LatestPostReader from './latest_post_reader';
import {render, screen} from '@testing-library/react';
import {renderWithIntlAndStore} from 'tests/react_testing_utils';
import {Provider} from 'react-redux';
jest.mock('react-intl', () => ({ jest.mock('react-intl', () => ({
...jest.requireActual('react-intl'), ...jest.requireActual('react-intl'),

Просмотреть файл

@@ -2,7 +2,8 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React, {ComponentProps} from 'react'; import React, {ComponentProps} from 'react';
import {render, screen, fireEvent} from '@testing-library/react';
import {fireEvent, render, screen} from 'tests/react_testing_utils';
import {withIntl} from 'tests/helpers/intl-test-helper'; import {withIntl} from 'tests/helpers/intl-test-helper';
import InviteMembers from './invite_members'; import InviteMembers from './invite_members';

Просмотреть файл

@@ -2,11 +2,14 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React from 'react'; import React from 'react';
import {render, screen, fireEvent} from '@testing-library/react';
import {trackEvent} from 'actions/telemetry_actions'; import {trackEvent} from 'actions/telemetry_actions';
import InviteMembersLink from './invite_members_link';
import {fireEvent, render, screen} from 'tests/react_testing_utils';
import {withIntl} from 'tests/helpers/intl-test-helper'; import {withIntl} from 'tests/helpers/intl-test-helper';
import InviteMembersLink from './invite_members_link';
jest.mock('actions/telemetry_actions', () => ({ jest.mock('actions/telemetry_actions', () => ({
trackEvent: jest.fn(), trackEvent: jest.fn(),
})); }));

Просмотреть файл

@@ -2,11 +2,14 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React from 'react'; import React from 'react';
import {render} from '@testing-library/react';
import {BadUrlReasons} from 'utils/url'; import {render} from 'tests/react_testing_utils';
import OrganizationStatus, {TeamApiError} from './organization_status';
import {withIntl} from 'tests/helpers/intl-test-helper'; import {withIntl} from 'tests/helpers/intl-test-helper';
import {BadUrlReasons} from 'utils/url';
import OrganizationStatus, {TeamApiError} from './organization_status';
describe('components/preparing-workspace/organization_status', () => { describe('components/preparing-workspace/organization_status', () => {
const defaultProps = { const defaultProps = {
error: null, error: null,

Просмотреть файл

@@ -2,11 +2,9 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React from 'react'; import React from 'react';
import * as redux from 'react-redux'; import * as redux from 'react-redux';
import {screen} from '@testing-library/react';
import {renderWithIntl} from 'tests/react_testing_utils'; import {renderWithIntl, screen} from 'tests/react_testing_utils';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';
import {CloudProducts} from 'utils/constants'; import {CloudProducts} from 'utils/constants';

Просмотреть файл

@@ -2,11 +2,10 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React from 'react'; import React from 'react';
import {screen} from '@testing-library/react';
import {DeepPartial} from '@mattermost/types/utilities'; import {DeepPartial} from '@mattermost/types/utilities';
import {renderWithIntlAndStore} from 'tests/react_testing_utils'; import {renderWithIntlAndStore, screen} from 'tests/react_testing_utils';
import {GlobalState} from 'types/store'; import {GlobalState} from 'types/store';
import {TestHelper as TH} from 'utils/test_helper'; import {TestHelper as TH} from 'utils/test_helper';
import {Client4} from 'mattermost-redux/client'; import {Client4} from 'mattermost-redux/client';

Просмотреть файл

@@ -2,7 +2,8 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React from 'react'; import React from 'react';
import {render} from '@testing-library/react';
import {render} from 'tests/react_testing_utils';
import RootPortal from './root_portal'; import RootPortal from './root_portal';

Просмотреть файл

@@ -2,9 +2,8 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React from 'react'; import React from 'react';
import {screen} from '@testing-library/react';
import {renderWithIntlAndStore} from 'tests/react_testing_utils'; import {renderWithIntlAndStore, screen} from 'tests/react_testing_utils';
import * as controlModalHooks from 'components/common/hooks/useControlModal'; import * as controlModalHooks from 'components/common/hooks/useControlModal';

Просмотреть файл

@@ -2,15 +2,16 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React, {ComponentProps} from 'react'; import React, {ComponentProps} from 'react';
import {render} from '@testing-library/react';
import {IntlProvider} from 'react-intl'; import {IntlProvider} from 'react-intl';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
import SearchDateProvider from 'components/suggestion/search_date_provider'; import SearchDateProvider from 'components/suggestion/search_date_provider';
import SearchChannelProvider from 'components/suggestion/search_channel_provider'; import SearchChannelProvider from 'components/suggestion/search_channel_provider';
import SearchUserProvider from 'components/suggestion/search_user_provider'; import SearchUserProvider from 'components/suggestion/search_user_provider';
import en from 'i18n/en.json'; import en from 'i18n/en.json';
import {render} from 'tests/react_testing_utils';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';
import SearchBar from './search_bar'; import SearchBar from './search_bar';

Просмотреть файл

@@ -2,9 +2,8 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React from 'react'; import React from 'react';
import {screen} from '@testing-library/react';
import {renderWithIntl} from 'tests/react_testing_utils'; import {renderWithIntl, screen} from 'tests/react_testing_utils';
import {RHSStates} from 'utils/constants'; import {RHSStates} from 'utils/constants';
import {RhsState} from 'types/store/rhs'; import {RhsState} from 'types/store/rhs';

Просмотреть файл

@@ -3,13 +3,16 @@
import React from 'react'; import React from 'react';
import {screen, fireEvent, waitFor} from '@testing-library/react';
import {GlobalState} from 'types/store'; import {GlobalState} from 'types/store';
import {SelfHostedSignupForm, SelfHostedSignupProgress} from '@mattermost/types/hosted_customer'; import {SelfHostedSignupForm, SelfHostedSignupProgress} from '@mattermost/types/hosted_customer';
import {renderWithIntlAndStore} from 'tests/react_testing_utils'; import {
fireEvent,
renderWithIntlAndStore,
screen,
waitFor,
} from 'tests/react_testing_utils';
import {TestHelper as TH} from 'utils/test_helper'; import {TestHelper as TH} from 'utils/test_helper';
import {SelfHostedProducts, ModalIdentifiers, RecurringIntervals} from 'utils/constants'; import {SelfHostedProducts, ModalIdentifiers, RecurringIntervals} from 'utils/constants';

Просмотреть файл

@@ -3,13 +3,17 @@
import React from 'react'; import React from 'react';
import {screen, fireEvent, waitFor} from '@testing-library/react';
import {GlobalState} from 'types/store'; import {GlobalState} from 'types/store';
import {SelfHostedSignupForm, SelfHostedSignupProgress} from '@mattermost/types/hosted_customer'; import {SelfHostedSignupForm, SelfHostedSignupProgress} from '@mattermost/types/hosted_customer';
import {renderWithIntlAndStore} from 'tests/react_testing_utils'; import {
fireEvent,
renderWithIntlAndStore,
screen,
waitFor,
} from 'tests/react_testing_utils';
import {TestHelper as TH} from 'utils/test_helper'; import {TestHelper as TH} from 'utils/test_helper';
import {SelfHostedProducts, ModalIdentifiers} from 'utils/constants'; import {SelfHostedProducts, ModalIdentifiers} from 'utils/constants';

Просмотреть файл

@@ -5,7 +5,6 @@ import React from 'react';
import {shallow, ReactWrapper} from 'enzyme'; import {shallow, ReactWrapper} from 'enzyme';
import {IntlProvider} from 'react-intl'; import {IntlProvider} from 'react-intl';
import {BrowserRouter} from 'react-router-dom'; import {BrowserRouter} from 'react-router-dom';
import {act, screen} from '@testing-library/react';
import {mountWithIntl} from 'tests/helpers/intl-test-helper'; import {mountWithIntl} from 'tests/helpers/intl-test-helper';
@@ -19,7 +18,7 @@ import {RequestStatus} from 'mattermost-redux/constants';
import {ClientConfig} from '@mattermost/types/config'; import {ClientConfig} from '@mattermost/types/config';
import {GlobalState} from 'types/store'; import {GlobalState} from 'types/store';
import {WindowSizes} from 'utils/constants'; import {WindowSizes} from 'utils/constants';
import {renderWithIntlAndStore} from 'tests/react_testing_utils'; import {act, renderWithIntlAndStore, screen} from 'tests/react_testing_utils';
let mockState: GlobalState; let mockState: GlobalState;
let mockLocation = {pathname: '', search: '', hash: ''}; let mockLocation = {pathname: '', search: '', hash: ''};

Просмотреть файл

@@ -1,14 +1,18 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import {act, RenderResult, screen} from '@testing-library/react';
import React from 'react'; import React from 'react';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';
import {ModalIdentifiers} from 'utils/constants'; import {ModalIdentifiers} from 'utils/constants';
import StartTrialFormModal from '.'; import StartTrialFormModal from '.';
import {BrowserRouter} from 'react-router-dom'; import {BrowserRouter} from 'react-router-dom';
import {renderWithIntl} from 'tests/react_testing_utils'; import {
act,
RenderResult,
renderWithIntl,
screen,
} from 'tests/react_testing_utils';
import {trackEvent} from 'actions/telemetry_actions'; import {trackEvent} from 'actions/telemetry_actions';
jest.mock('actions/telemetry_actions.jsx', () => { jest.mock('actions/telemetry_actions.jsx', () => {

Просмотреть файл

@@ -3,13 +3,13 @@
import React from 'react'; import React from 'react';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
import {act} from '@testing-library/react';
import {ReactWrapper} from 'enzyme'; import {ReactWrapper} from 'enzyme';
import {BrowserRouter} from 'react-router-dom'; import {BrowserRouter} from 'react-router-dom';
import {General} from 'mattermost-redux/constants'; import {General} from 'mattermost-redux/constants';
import {displayUsername} from 'mattermost-redux/utils/user_utils'; import {displayUsername} from 'mattermost-redux/utils/user_utils';
import {mountWithIntl} from 'tests/helpers/intl-test-helper'; import {mountWithIntl} from 'tests/helpers/intl-test-helper';
import {act} from 'tests/react_testing_utils';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';
import {TestHelper} from 'utils/test_helper'; import {TestHelper} from 'utils/test_helper';

Просмотреть файл

@@ -3,7 +3,6 @@
import React from 'react'; import React from 'react';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
import {act} from '@testing-library/react';
import {ReactWrapper} from 'enzyme'; import {ReactWrapper} from 'enzyme';
import {BrowserRouter} from 'react-router-dom'; import {BrowserRouter} from 'react-router-dom';
@@ -11,6 +10,7 @@ import {UserProfile} from '@mattermost/types/users';
import {Group} from '@mattermost/types/groups'; import {Group} from '@mattermost/types/groups';
import {mountWithIntl} from 'tests/helpers/intl-test-helper'; import {mountWithIntl} from 'tests/helpers/intl-test-helper';
import {act} from 'tests/react_testing_utils';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';
import {TestHelper} from 'utils/test_helper'; import {TestHelper} from 'utils/test_helper';

Просмотреть файл

@@ -4,8 +4,8 @@
import React from 'react'; import React from 'react';
import {mount, ReactWrapper} from 'enzyme'; import {mount, ReactWrapper} from 'enzyme';
import * as reactRedux from 'react-redux'; import * as reactRedux from 'react-redux';
import {act} from '@testing-library/react';
import {act} from 'tests/react_testing_utils';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';
import {CloudProducts, LicenseSkus} from 'utils/constants'; import {CloudProducts, LicenseSkus} from 'utils/constants';

Просмотреть файл

@@ -5,14 +5,14 @@ import React, {ComponentProps} from 'react';
import {shallow} from 'enzyme'; import {shallow} from 'enzyme';
import {IntlProvider} from 'react-intl'; import {IntlProvider} from 'react-intl';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
import {render, fireEvent, screen} from '@testing-library/react';
import {Preferences} from 'mattermost-redux/constants'; import {Preferences} from 'mattermost-redux/constants';
import UserSettingsTheme from 'components/user_settings/display/user_settings_theme/user_settings_theme'; import {render, fireEvent, screen} from 'tests/react_testing_utils';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';
import UserSettingsTheme from './user_settings_theme';
jest.mock('utils/utils', () => ({ jest.mock('utils/utils', () => ({
applyTheme: jest.fn(), applyTheme: jest.fn(),
toTitleCase: jest.fn(), toTitleCase: jest.fn(),

Просмотреть файл

@@ -2,10 +2,9 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import React from 'react'; import React from 'react';
import {screen} from '@testing-library/react';
import {Provider} from 'react-redux'; import {Provider} from 'react-redux';
import {renderWithIntl} from 'tests/react_testing_utils'; import {renderWithIntl, screen} from 'tests/react_testing_utils';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';
import {LimitSummary} from 'components/common/hooks/useGetHighestThresholdCloudLimit'; import {LimitSummary} from 'components/common/hooks/useGetHighestThresholdCloudLimit';

Просмотреть файл

@@ -1,7 +1,6 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import {screen} from '@testing-library/react';
import React from 'react'; import React from 'react';
import {FormattedMessage, useIntl} from 'react-intl'; import {FormattedMessage, useIntl} from 'react-intl';
import {connect, useSelector} from 'react-redux'; import {connect, useSelector} from 'react-redux';
@@ -14,7 +13,7 @@ import {GlobalState} from 'types/store';
import {TestHelper} from 'utils/test_helper'; import {TestHelper} from 'utils/test_helper';
import {renderWithFullContext} from './react_testing_utils'; import {renderWithFullContext, screen} from './react_testing_utils';
describe('renderWithFullContext', () => { describe('renderWithFullContext', () => {
test('should be able to render anything', () => { test('should be able to render anything', () => {

Просмотреть файл

@@ -2,6 +2,7 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import {render} from '@testing-library/react'; import {render} from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import {createBrowserHistory} from 'history'; import {createBrowserHistory} from 'history';
import React from 'react'; import React from 'react';
import {IntlProvider} from 'react-intl'; import {IntlProvider} from 'react-intl';
@@ -10,12 +11,16 @@ import {Router} from 'react-router-dom';
import {DeepPartial} from '@mattermost/types/utilities'; import {DeepPartial} from '@mattermost/types/utilities';
import mergeObjects from 'packages/mattermost-redux/test/merge_objects';
import configureStore from 'store'; import configureStore from 'store';
import mockStore from 'tests/test_store'; import mockStore from 'tests/test_store';
import {GlobalState} from 'types/store'; import {GlobalState} from 'types/store';
import mergeObjects from 'packages/mattermost-redux/test/merge_objects';
export * from '@testing-library/react';
export {userEvent};
export const renderWithIntl = (component: React.ReactNode | React.ReactNodeArray, locale = 'en') => { export const renderWithIntl = (component: React.ReactNode | React.ReactNodeArray, locale = 'en') => {
return render(<IntlProvider locale={locale}>{component}</IntlProvider>); return render(<IntlProvider locale={locale}>{component}</IntlProvider>);