+
`;
exports[`components/admin_console/request_button/request_button.jsx should match snapshot with request error 1`] = `
-
- }
- disabled={false}
- errorMessage={
- Object {
- "defaultMessage": "Error Message: {error}",
- "id": "error.message",
- }
- }
- helpText={
-
- }
- includeDetailedError={true}
- requestAction={
- [MockFunction] {
- "calls": Array [
- Array [
- [Function],
- [Function],
- ],
- ],
- "results": Array [
- Object {
- "type": "return",
- "value": undefined,
- },
- ],
- }
- }
- saveNeeded={false}
- showSuccessMessage={true}
- successMessage={
- Object {
- "defaultMessage": "Test Successful",
- "id": "admin.requestButton.requestSuccess",
- }
- }
->
+
`;
exports[`components/admin_console/request_button/request_button.jsx should match snapshot with request error 2`] = `
-
- }
- disabled={false}
- errorMessage={
- Object {
- "defaultMessage": "Error Message: {error}",
- "id": "error.message",
- }
- }
- helpText={
-
- }
- includeDetailedError={false}
- requestAction={
- [MockFunction] {
- "calls": Array [
- Array [
- [Function],
- [Function],
- ],
- Array [
- [Function],
- [Function],
- ],
- ],
- "results": Array [
- Object {
- "type": "return",
- "value": undefined,
- },
- Object {
- "type": "return",
- "value": undefined,
- },
- ],
- }
- }
- saveNeeded={false}
- showSuccessMessage={true}
- successMessage={
- Object {
- "defaultMessage": "Test Successful",
- "id": "admin.requestButton.requestSuccess",
- }
- }
->
+
`;
exports[`components/admin_console/request_button/request_button.jsx should match snapshot with successMessage 1`] = `
-
- }
- disabled={false}
- errorMessage={
- Object {
- "defaultMessage": "Test Failure: {error}",
- "id": "admin.requestButton.requestFailure",
- }
- }
- helpText={
-
- }
- includeDetailedError={false}
- requestAction={
- [MockFunction] {
- "calls": Array [
- Array [
- [Function],
- [Function],
- ],
- ],
- "results": Array [
- Object {
- "type": "return",
- "value": undefined,
- },
- ],
- }
- }
- saveNeeded={false}
- showSuccessMessage={true}
- successMessage={
- Object {
- "defaultMessage": "Success Message",
- "id": "success.message",
- }
- }
->
+
`;
exports[`components/admin_console/request_button/request_button.jsx should match snapshot with successMessage 2`] = `
-
- }
- disabled={false}
- errorMessage={
- Object {
- "defaultMessage": "Test Failure: {error}",
- "id": "admin.requestButton.requestFailure",
- }
- }
- helpText={
-
- }
- includeDetailedError={false}
- requestAction={
- [MockFunction] {
- "calls": Array [
- Array [
- [Function],
- [Function],
- ],
- Array [
- [Function],
- [Function],
- ],
- ],
- "results": Array [
- Object {
- "type": "return",
- "value": undefined,
- },
- Object {
- "type": "return",
- "value": undefined,
- },
- ],
- }
- }
- saveNeeded={false}
- showSuccessMessage={false}
- successMessage={
- Object {
- "defaultMessage": "Success Message",
- "id": "success.message",
- }
- }
->
+
`;
diff --git a/webapp/channels/src/components/admin_console/request_button/request_button.test.tsx b/webapp/channels/src/components/admin_console/request_button/request_button.test.tsx
index 90c5d72365f..3cbd9b838fb 100644
--- a/webapp/channels/src/components/admin_console/request_button/request_button.test.tsx
+++ b/webapp/channels/src/components/admin_console/request_button/request_button.test.tsx
@@ -1,19 +1,18 @@
// 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 RequestButton from 'components/admin_console/request_button/request_button';
-import {mountWithIntl} from 'tests/helpers/intl-test-helper';
+import {renderWithContext, screen, userEvent} from 'tests/react_testing_utils';
describe('components/admin_console/request_button/request_button.jsx', () => {
test('should match snapshot', () => {
const emptyFunction = jest.fn();
- const wrapper = shallow
(
+ const {container} = renderWithContext(
{
}
/>,
);
- expect(wrapper).toMatchSnapshot();
+ expect(container).toMatchSnapshot();
});
- test('should call saveConfig and request actions when saveNeeded is true', () => {
+ test('should call saveConfig and request actions when saveNeeded is true', async () => {
const requestActionSuccess = jest.fn((success) => success());
const saveConfigActionSuccess = jest.fn((success) => success());
- const wrapper = mountWithIntl(
+ renderWithContext(
{
/>,
);
- wrapper.find('button').first().simulate('click');
+ await userEvent.click(screen.getByRole('button'));
expect(requestActionSuccess.mock.calls.length).toBe(1);
expect(saveConfigActionSuccess.mock.calls.length).toBe(0);
});
- test('should call only request action when saveNeeded is false', () => {
+ test('should call only request action when saveNeeded is false', async () => {
const requestActionSuccess = jest.fn((success) => success());
const saveConfigActionSuccess = jest.fn((success) => success());
- const wrapper = mountWithIntl(
+ renderWithContext(
{
/>,
);
- wrapper.find('button').first().simulate('click');
+ await userEvent.click(screen.getByRole('button'));
expect(requestActionSuccess.mock.calls.length).toBe(1);
expect(saveConfigActionSuccess.mock.calls.length).toBe(1);
});
- test('should match snapshot with successMessage', () => {
+ test('should match snapshot with successMessage', async () => {
const requestActionSuccess = jest.fn((success) => success());
// Success & showSuccessMessage=true
- const wrapper1 = mountWithIntl(
+ const {container: container1} = renderWithContext(
{
/>,
);
- wrapper1.find('button').first().simulate('click');
- expect(wrapper1).toMatchSnapshot();
+ await userEvent.click(screen.getAllByRole('button')[0]);
+ expect(container1).toMatchSnapshot();
// Success & showSuccessMessage=false
- const wrapper2 = mountWithIntl(
+ const {container: container2} = renderWithContext(
{
/>,
);
- wrapper2.find('button').first().simulate('click');
+ await userEvent.click(screen.getAllByRole('button')[1]);
- expect(wrapper2).toMatchSnapshot();
+ expect(container2).toMatchSnapshot();
});
- test('should match snapshot with request error', () => {
+ test('should match snapshot with request error', async () => {
const requestActionFailure = jest.fn((success, error) => error({
message: '__message__',
detailed_error: '__detailed_error__',
}));
// Error & includeDetailedError=true
- const wrapper1 = mountWithIntl(
+ const {container: container1} = renderWithContext(
{
/>,
);
- wrapper1.find('button').first().simulate('click');
- expect(wrapper1).toMatchSnapshot();
+ await userEvent.click(screen.getAllByRole('button')[0]);
+ expect(container1).toMatchSnapshot();
// Error & includeDetailedError=false
- const wrapper2 = mountWithIntl(
+ const {container: container2} = renderWithContext(
{
/>,
);
- wrapper2.find('button').first().simulate('click');
+ await userEvent.click(screen.getAllByRole('button')[1]);
- expect(wrapper2).toMatchSnapshot();
+ expect(container2).toMatchSnapshot();
});
});
diff --git a/webapp/channels/src/components/admin_console/schema_text.test.tsx b/webapp/channels/src/components/admin_console/schema_text.test.tsx
index fc3df8a674f..fdbf52b8e99 100644
--- a/webapp/channels/src/components/admin_console/schema_text.test.tsx
+++ b/webapp/channels/src/components/admin_console/schema_text.test.tsx
@@ -1,9 +1,10 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
-import {shallow} from 'enzyme';
import React from 'react';
+import {renderWithContext} from 'tests/react_testing_utils';
+
import SchemaText from './schema_text';
describe('SchemaText', () => {
@@ -14,9 +15,9 @@ describe('SchemaText', () => {
};
test('should render plain text correctly', () => {
- const wrapper = shallow( );
+ const {container} = renderWithContext( );
- expect(wrapper).toMatchSnapshot();
+ expect(container).toMatchSnapshot();
});
test('should render markdown text correctly', () => {
@@ -26,9 +27,9 @@ describe('SchemaText', () => {
text: 'This is **HELP TEXT**',
};
- const wrapper = shallow( );
+ const {container} = renderWithContext( );
- expect(wrapper).toMatchSnapshot();
+ expect(container).toMatchSnapshot();
});
test('should render translated text correctly', () => {
@@ -41,9 +42,9 @@ describe('SchemaText', () => {
},
};
- const wrapper = shallow( );
+ const {container} = renderWithContext( );
- expect(wrapper).toMatchSnapshot();
+ expect(container).toMatchSnapshot();
});
test('should render translated markdown text correctly', () => {
@@ -57,9 +58,9 @@ describe('SchemaText', () => {
},
};
- const wrapper = shallow( );
+ const {container} = renderWithContext( );
- expect(wrapper).toMatchSnapshot();
+ expect(container).toMatchSnapshot();
});
test('should open external markdown links in the new window', () => {
@@ -69,11 +70,10 @@ describe('SchemaText', () => {
text: 'This is [a link](https://example.com)',
};
- const wrapper = shallow( );
+ const {container} = renderWithContext( );
- expect(wrapper.find('span').prop('dangerouslySetInnerHTML')).toEqual({
- __html: 'This is a link ',
- });
+ const span = container.querySelector('span');
+ expect(span).toHaveProperty('innerHTML', 'This is a link ');
});
test('should open internal markdown links in the same window', () => {
@@ -83,11 +83,10 @@ describe('SchemaText', () => {
text: 'This is [a link](http://localhost:8065/api/v4/users/src_id)',
};
- const wrapper = shallow( );
+ const {container} = renderWithContext( );
- expect(wrapper.find('span').prop('dangerouslySetInnerHTML')).toEqual({
- __html: 'This is a link ',
- });
+ const span = container.querySelector('span');
+ expect(span).toHaveProperty('innerHTML', 'This is a link ');
});
test('should support explicit external links like FormattedMarkdownMessage', () => {
@@ -97,10 +96,9 @@ describe('SchemaText', () => {
text: 'This is [a link](!https://example.com)',
};
- const wrapper = shallow( );
+ const {container} = renderWithContext( );
- expect(wrapper.find('span').prop('dangerouslySetInnerHTML')).toEqual({
- __html: 'This is a link ',
- });
+ const span = container.querySelector('span');
+ expect(span).toHaveProperty('innerHTML', 'This is a link ');
});
});
diff --git a/webapp/channels/src/components/admin_console/user_grid/__snapshots__/user_grid.test.tsx.snap b/webapp/channels/src/components/admin_console/user_grid/__snapshots__/user_grid.test.tsx.snap
index a9b76d767de..a3513c01aa5 100644
--- a/webapp/channels/src/components/admin_console/user_grid/__snapshots__/user_grid.test.tsx.snap
+++ b/webapp/channels/src/components/admin_console/user_grid/__snapshots__/user_grid.test.tsx.snap
@@ -1,1120 +1,737 @@
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`components/admin_console/user_grid/UserGrid should match snapshot with 2 users 1`] = `
- ,
- "width": 3,
- },
- Object {
- "field": "new",
- "fixed": true,
- "name": "",
- },
- Object {
- "field": "role",
- "name": ,
- "overflow": "visible",
- },
- Object {
- "field": "remove",
- "fixed": true,
- "name": "",
- "textAlign": "right",
- },
- ]
- }
- endCount={2}
- filterProps={
- Object {
- "keys": Array [],
- "onFilter": [Function],
- "options": Object {},
- }
- }
- loading={false}
- nextPage={[Function]}
- onSearch={[Function]}
- placeholderEmpty={
-
- }
- previousPage={[Function]}
- rows={
- Array [
- Object {
- "cells": Object {
- "id": "userid1",
- "name": ,
- "new": null,
- "remove": ,
- "role": ,
- },
- },
- Object {
- "cells": Object {
- "id": "userid2",
- "name": ,
- "new": null,
- "remove": ,
- "role": ,
- },
- },
- ]
- }
- rowsContainerStyles={
- Object {
- "minHeight": "160px",
- }
- }
- startCount={1}
- term=""
- total={2}
-/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ user-1 -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ user-2 -
+
+
+
+
+
+
+
+
+
+
+
+
`;
exports[`components/admin_console/user_grid/UserGrid should match snapshot with 2 users and 1 added included 1`] = `
- ,
- "width": 3,
- },
- Object {
- "field": "new",
- "fixed": true,
- "name": "",
- },
- Object {
- "field": "role",
- "name": ,
- "overflow": "visible",
- },
- Object {
- "field": "remove",
- "fixed": true,
- "name": "",
- "textAlign": "right",
- },
- ]
- }
- endCount={3}
- filterProps={
- Object {
- "keys": Array [],
- "onFilter": [Function],
- "options": Object {},
- }
- }
- loading={false}
- nextPage={[Function]}
- onSearch={[Function]}
- placeholderEmpty={
-
- }
- previousPage={[Function]}
- rows={
- Array [
- Object {
- "cells": Object {
- "id": "userid-not-saved",
- "name": ,
- "new":
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ user-not-saved -
+
+
- }
- />,
- "remove": ,
- "role": ,
- },
- },
- Object {
- "cells": Object {
- "id": "userid1",
- "name": ,
- "new": null,
- "remove": ,
- "role": ,
- },
- },
- Object {
- "cells": Object {
- "id": "userid2",
- "name": ,
- "new": null,
- "remove": ,
- "role": ,
- },
- },
- ]
- }
- rowsContainerStyles={
- Object {
- "minHeight": "240px",
- }
- }
- startCount={1}
- term=""
- total={3}
-/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ user-1 -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ user-2 -
+
+
+
+
+
+
+
+
+
+
+
+
`;
exports[`components/admin_console/user_grid/UserGrid should match snapshot with 2 users and 1 removed user 1`] = `
-
-
-
- Child 1
-
-
-
-
-
- Child 2
-
-
+
+
`;
exports[`components/backstage/components/BackstageHeader should match snapshot without children 1`] = `
-
-
+
+
`;
diff --git a/webapp/channels/src/components/backstage/components/backstage_header.test.tsx b/webapp/channels/src/components/backstage/components/backstage_header.test.tsx
index cc5c14b5995..78a9f181268 100644
--- a/webapp/channels/src/components/backstage/components/backstage_header.test.tsx
+++ b/webapp/channels/src/components/backstage/components/backstage_header.test.tsx
@@ -1,26 +1,27 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
-import {shallow} from 'enzyme';
import React from 'react';
import BackstageHeader from 'components/backstage/components/backstage_header';
+import {render} from 'tests/react_testing_utils';
+
describe('components/backstage/components/BackstageHeader', () => {
test('should match snapshot without children', () => {
- const wrapper = shallow(
+ const {container} = render(
,
);
- expect(wrapper).toMatchSnapshot();
+ expect(container).toMatchSnapshot();
});
test('should match snapshot with children', () => {
- const wrapper = shallow(
+ const {container} = render(
{'Child 1'}
{'Child 2'}
,
);
- expect(wrapper).toMatchSnapshot();
+ expect(container).toMatchSnapshot();
});
});
diff --git a/webapp/channels/src/components/backstage/components/backstage_sidebar.test.tsx b/webapp/channels/src/components/backstage/components/backstage_sidebar.test.tsx
index d6c010ea2ed..47bf1f37897 100644
--- a/webapp/channels/src/components/backstage/components/backstage_sidebar.test.tsx
+++ b/webapp/channels/src/components/backstage/components/backstage_sidebar.test.tsx
@@ -1,15 +1,19 @@
// 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 {MemoryRouter} from 'react-router-dom';
+import {renderWithContext, screen} from 'tests/react_testing_utils';
import {TestHelper} from 'utils/test_helper';
-import BackstageCategory from './backstage_category';
import BackstageSidebar from './backstage_sidebar';
+// Mock permission gates to render their children
+jest.mock('components/permissions_gates/team_permission_gate', () => ({children}: {children: React.ReactNode}) => <>{children}>);
+jest.mock('components/permissions_gates/system_permission_gate', () => ({children}: {children: React.ReactNode}) => <>{children}>);
+
describe('components/backstage/components/BackstageSidebar', () => {
const defaultProps: ComponentProps
= {
team: TestHelper.getTeamMock({
@@ -26,6 +30,15 @@ describe('components/backstage/components/BackstageSidebar', () => {
enableOutgoingOAuthConnections: false,
};
+ // Helper to render with router at integrations path to show children
+ const renderAtIntegrationsPath = (props: ComponentProps) => {
+ return renderWithContext(
+
+
+ ,
+ );
+ };
+
describe('custom emoji', () => {
const testCases = [
{enableCustomEmoji: false, canCreateOrDeleteCustomEmoji: false, expectedResult: false},
@@ -41,11 +54,13 @@ describe('components/backstage/components/BackstageSidebar', () => {
enableCustomEmoji: testCase.enableCustomEmoji,
canCreateOrDeleteCustomEmoji: testCase.canCreateOrDeleteCustomEmoji,
};
- const wrapper = shallow(
- ,
- );
+ renderAtIntegrationsPath(props);
- expect(wrapper.find(BackstageCategory).find({name: 'emoji'}).exists()).toBe(testCase.expectedResult);
+ if (testCase.expectedResult) {
+ expect(screen.getByText('Custom Emoji')).toBeInTheDocument();
+ } else {
+ expect(screen.queryByText('Custom Emoji')).not.toBeInTheDocument();
+ }
});
});
});
@@ -65,11 +80,13 @@ describe('components/backstage/components/BackstageSidebar', () => {
enableIncomingWebhooks: testCase.enableIncomingWebhooks,
canManageIntegrations: testCase.canManageIntegrations,
};
- const wrapper = shallow(
- ,
- );
+ renderAtIntegrationsPath(props);
- expect(wrapper.find(BackstageCategory).find({name: 'incoming_webhooks'}).exists()).toBe(testCase.expectedResult);
+ if (testCase.expectedResult) {
+ expect(screen.getByText('Incoming Webhooks')).toBeInTheDocument();
+ } else {
+ expect(screen.queryByText('Incoming Webhooks')).not.toBeInTheDocument();
+ }
});
});
});
@@ -89,11 +106,13 @@ describe('components/backstage/components/BackstageSidebar', () => {
enableOutgoingWebhooks: testCase.enableOutgoingWebhooks,
canManageIntegrations: testCase.canManageIntegrations,
};
- const wrapper = shallow(
- ,
- );
+ renderAtIntegrationsPath(props);
- expect(wrapper.find(BackstageCategory).find({name: 'outgoing_webhooks'}).exists()).toBe(testCase.expectedResult);
+ if (testCase.expectedResult) {
+ expect(screen.getByText('Outgoing Webhooks')).toBeInTheDocument();
+ } else {
+ expect(screen.queryByText('Outgoing Webhooks')).not.toBeInTheDocument();
+ }
});
});
});
@@ -113,11 +132,13 @@ describe('components/backstage/components/BackstageSidebar', () => {
enableCommands: testCase.enableCommands,
canManageIntegrations: testCase.canManageIntegrations,
};
- const wrapper = shallow(
- ,
- );
+ renderAtIntegrationsPath(props);
- expect(wrapper.find(BackstageCategory).find({name: 'commands'}).exists()).toBe(testCase.expectedResult);
+ if (testCase.expectedResult) {
+ expect(screen.getByText('Slash Commands')).toBeInTheDocument();
+ } else {
+ expect(screen.queryByText('Slash Commands')).not.toBeInTheDocument();
+ }
});
});
});
@@ -137,11 +158,13 @@ describe('components/backstage/components/BackstageSidebar', () => {
enableOAuthServiceProvider: testCase.enableOAuthServiceProvider,
canManageIntegrations: testCase.canManageIntegrations,
};
- const wrapper = shallow(
- ,
- );
+ renderAtIntegrationsPath(props);
- expect(wrapper.find(BackstageCategory).find({name: 'oauth2-apps'}).exists()).toBe(testCase.expectedResult);
+ if (testCase.expectedResult) {
+ expect(screen.getByText('OAuth 2.0 Applications')).toBeInTheDocument();
+ } else {
+ expect(screen.queryByText('OAuth 2.0 Applications')).not.toBeInTheDocument();
+ }
});
});
});
@@ -161,11 +184,13 @@ describe('components/backstage/components/BackstageSidebar', () => {
enableOutgoingOAuthConnections: testCase.enableOutgoingOAuthConnections,
canManageIntegrations: testCase.canManageIntegrations,
};
- const wrapper = shallow(
- ,
- );
+ renderAtIntegrationsPath(props);
- expect(wrapper.find(BackstageCategory).find({name: 'outgoing-oauth2-connections'}).exists()).toBe(testCase.expectedResult);
+ if (testCase.expectedResult) {
+ expect(screen.getByText('Outgoing OAuth 2.0 Connections')).toBeInTheDocument();
+ } else {
+ expect(screen.queryByText('Outgoing OAuth 2.0 Connections')).not.toBeInTheDocument();
+ }
});
});
});
@@ -182,11 +207,13 @@ describe('components/backstage/components/BackstageSidebar', () => {
...defaultProps,
canManageIntegrations: testCase.canManageIntegrations,
};
- const wrapper = shallow(
- ,
- );
+ renderAtIntegrationsPath(props);
- expect(wrapper.find(BackstageCategory).find({name: 'bots'}).exists()).toBe(testCase.expectedResult);
+ if (testCase.expectedResult) {
+ expect(screen.getByText('Bot Accounts')).toBeInTheDocument();
+ } else {
+ expect(screen.queryByText('Bot Accounts')).not.toBeInTheDocument();
+ }
});
});
});
@@ -202,16 +229,14 @@ describe('components/backstage/components/BackstageSidebar', () => {
canManageIntegrations: true,
enableOutgoingOAuthConnections: true,
};
- const wrapper = shallow(
- ,
- );
+ renderAtIntegrationsPath(props);
- expect(wrapper.find(BackstageCategory).find({name: 'incoming_webhooks'}).exists()).toBe(true);
- expect(wrapper.find(BackstageCategory).find({name: 'outgoing_webhooks'}).exists()).toBe(true);
- expect(wrapper.find(BackstageCategory).find({name: 'commands'}).exists()).toBe(true);
- expect(wrapper.find(BackstageCategory).find({name: 'oauth2-apps'}).exists()).toBe(true);
- expect(wrapper.find(BackstageCategory).find({name: 'outgoing-oauth2-connections'}).exists()).toBe(true);
- expect(wrapper.find(BackstageCategory).find({name: 'bots'}).exists()).toBe(true);
+ expect(screen.getByText('Incoming Webhooks')).toBeInTheDocument();
+ expect(screen.getByText('Outgoing Webhooks')).toBeInTheDocument();
+ expect(screen.getByText('Slash Commands')).toBeInTheDocument();
+ expect(screen.getByText('OAuth 2.0 Applications')).toBeInTheDocument();
+ expect(screen.getByText('Outgoing OAuth 2.0 Connections')).toBeInTheDocument();
+ expect(screen.getByText('Bot Accounts')).toBeInTheDocument();
});
it('cannot manage integrations', () => {
@@ -224,16 +249,14 @@ describe('components/backstage/components/BackstageSidebar', () => {
enableOutgoingOAuthConnections: true,
canManageIntegrations: false,
};
- const wrapper = shallow(
- ,
- );
+ renderAtIntegrationsPath(props);
- expect(wrapper.find(BackstageCategory).find({name: 'incoming_webhooks'}).exists()).toBe(false);
- expect(wrapper.find(BackstageCategory).find({name: 'outgoing_webhooks'}).exists()).toBe(false);
- expect(wrapper.find(BackstageCategory).find({name: 'commands'}).exists()).toBe(false);
- expect(wrapper.find(BackstageCategory).find({name: 'oauth2-apps'}).exists()).toBe(false);
- expect(wrapper.find(BackstageCategory).find({name: 'outgoing-oauth2-connections'}).exists()).toBe(false);
- expect(wrapper.find(BackstageCategory).find({name: 'bots'}).exists()).toBe(false);
+ expect(screen.queryByText('Incoming Webhooks')).not.toBeInTheDocument();
+ expect(screen.queryByText('Outgoing Webhooks')).not.toBeInTheDocument();
+ expect(screen.queryByText('Slash Commands')).not.toBeInTheDocument();
+ expect(screen.queryByText('OAuth 2.0 Applications')).not.toBeInTheDocument();
+ expect(screen.queryByText('Outgoing OAuth 2.0 Connections')).not.toBeInTheDocument();
+ expect(screen.queryByText('Bot Accounts')).not.toBeInTheDocument();
});
});
});
diff --git a/webapp/channels/src/components/color_input.test.tsx b/webapp/channels/src/components/color_input.test.tsx
index ad36b67e9e5..cad3b93f2fa 100644
--- a/webapp/channels/src/components/color_input.test.tsx
+++ b/webapp/channels/src/components/color_input.test.tsx
@@ -1,9 +1,10 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
-import {shallow} from 'enzyme';
import React from 'react';
+import {render, screen, fireEvent, userEvent} from 'tests/react_testing_utils';
+
import ColorInput from './color_input';
describe('components/ColorInput', () => {
@@ -14,79 +15,102 @@ describe('components/ColorInput', () => {
};
test('should match snapshot, init', () => {
- const wrapper = shallow(
+ const {container} = render(
,
);
- expect(wrapper).toMatchSnapshot();
+ expect(container).toMatchSnapshot();
});
- test('should match snapshot, opened', () => {
- const wrapper = shallow(
+ test('should match snapshot, opened', async () => {
+ const {container} = render(
,
);
- wrapper.find('.input-group-addon').simulate('click');
+ await userEvent.click(container.querySelector('.input-group-addon')!);
- expect(wrapper).toMatchSnapshot();
+ expect(container).toMatchSnapshot();
});
- test('should match snapshot, toggle picker', () => {
- const wrapper = shallow(
+ test('should match snapshot, toggle picker', async () => {
+ const {container} = render(
,
);
- wrapper.find('.input-group-addon').simulate('click');
- wrapper.find('.input-group-addon').simulate('click');
+ await userEvent.click(container.querySelector('.input-group-addon')!);
+ await userEvent.click(container.querySelector('.input-group-addon')!);
- expect(wrapper).toMatchSnapshot();
+ expect(container).toMatchSnapshot();
});
- test('should match snapshot, click on picker', () => {
- const wrapper = shallow(
+ test('should match snapshot, click on picker', async () => {
+ const {container} = render(
,
);
- wrapper.find('.input-group-addon').simulate('click');
- wrapper.find('.color-popover').simulate('click');
+ await userEvent.click(container.querySelector('.input-group-addon')!);
+ await userEvent.click(container.querySelector('.color-popover')!);
- expect(wrapper).toMatchSnapshot();
+ expect(container).toMatchSnapshot();
});
- test('should have match state on togglePicker', () => {
- const wrapper = shallow(
+ test('should have match state on togglePicker', async () => {
+ const {container} = render(
,
);
- wrapper.setState({isOpened: true});
+ // Initially picker should be closed (no color-popover)
+ expect(container.querySelector('.color-popover')).not.toBeInTheDocument();
- wrapper.find('.input-group-addon').simulate('click');
- expect(wrapper.state('isOpened')).toEqual(false);
+ // Click to open
+ await userEvent.click(container.querySelector('.input-group-addon')!);
+ expect(container.querySelector('.color-popover')).toBeInTheDocument();
- wrapper.find('.input-group-addon').simulate('click');
- expect(wrapper.state('isOpened')).toEqual(true);
+ // Click to close
+ await userEvent.click(container.querySelector('.input-group-addon')!);
+ expect(container.querySelector('.color-popover')).not.toBeInTheDocument();
+
+ // Click to open again
+ await userEvent.click(container.querySelector('.input-group-addon')!);
+ expect(container.querySelector('.color-popover')).toBeInTheDocument();
});
test('should keep what the user types in the textbox until blur', () => {
- const wrapper = shallow(
- ,
+ let currentValue = '#ffffff';
+ const onChange = jest.fn((value: string) => {
+ currentValue = value;
+ });
+
+ const {container, rerender} = render(
+ ,
);
- baseProps.onChange.mockImplementation((value) => wrapper.setProps({value}));
+ const input = screen.getByRole('textbox');
+ const colorIcon = container.querySelector('.color-icon') as HTMLElement;
- wrapper.find('input').simulate('focus', {target: null});
- expect(wrapper.state('focused')).toBe(true);
+ fireEvent.focus(input);
- wrapper.find('input').simulate('change', {target: {value: '#abc'}});
- expect(wrapper.state('value')).toBe('#abc');
- expect(baseProps.onChange).toHaveBeenLastCalledWith('#aabbcc');
- expect(wrapper.find('input').prop('value')).toEqual('#abc');
- expect(wrapper.find('.color-icon').prop('style')).toHaveProperty('backgroundColor', '#abc');
+ fireEvent.change(input, {target: {value: '#abc'}});
+ expect(onChange).toHaveBeenLastCalledWith('#aabbcc');
+ expect(input).toHaveValue('#abc');
+ expect(colorIcon.style.backgroundColor).toBe('rgb(170, 187, 204)');
- wrapper.find('input').simulate('blur');
- expect(wrapper.state('focused')).toBe(false);
- expect(wrapper.state('value')).toBe('#aabbcc');
- expect(baseProps.onChange).toHaveBeenLastCalledWith('#aabbcc');
- expect(wrapper.find('input').prop('value')).toEqual('#aabbcc');
- expect(wrapper.find('.color-icon').prop('style')).toHaveProperty('backgroundColor', '#aabbcc');
+ // Rerender with updated value prop (simulating parent component update)
+ rerender(
+ ,
+ );
+
+ fireEvent.blur(input);
+
+ // After blur, the input should show the normalized value
+ expect(input).toHaveValue('#aabbcc');
+ expect(colorIcon.style.backgroundColor).toBe('rgb(170, 187, 204)');
});
});
diff --git a/webapp/channels/src/components/common/__snapshots__/infinite_scroll.test.tsx.snap b/webapp/channels/src/components/common/__snapshots__/infinite_scroll.test.tsx.snap
index 6ba7104091a..2b30901ff6f 100644
--- a/webapp/channels/src/components/common/__snapshots__/infinite_scroll.test.tsx.snap
+++ b/webapp/channels/src/components/common/__snapshots__/infinite_scroll.test.tsx.snap
@@ -1,72 +1,43 @@
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`/components/common/InfiniteScroll should match snapshot 1`] = `
-
+
`;
exports[`/components/common/InfiniteScroll should not show loading screen if there is no data 1`] = `
-
+
-
+
`;
diff --git a/webapp/channels/src/components/common/__snapshots__/radio_group.test.tsx.snap b/webapp/channels/src/components/common/__snapshots__/radio_group.test.tsx.snap
index 3304b14928e..c5f2f37529a 100644
--- a/webapp/channels/src/components/common/__snapshots__/radio_group.test.tsx.snap
+++ b/webapp/channels/src/components/common/__snapshots__/radio_group.test.tsx.snap
@@ -1,63 +1,54 @@
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`/components/common/RadioButtonGroup should match snapshot 1`] = `
-
`;
diff --git a/webapp/channels/src/components/common/__snapshots__/site_name_and_description.test.tsx.snap b/webapp/channels/src/components/common/__snapshots__/site_name_and_description.test.tsx.snap
index d647e628ff8..1fdfc3ac8a3 100644
--- a/webapp/channels/src/components/common/__snapshots__/site_name_and_description.test.tsx.snap
+++ b/webapp/channels/src/components/common/__snapshots__/site_name_and_description.test.tsx.snap
@@ -1,36 +1,33 @@
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`/components/common/SiteNameAndDescription should match snapshot, default 1`] = `
-
+
Mattermost
-
+ All team communication in one place, searchable and accessible anywhere
-
+
`;
exports[`/components/common/SiteNameAndDescription should match snapshot, with custom site name and description 1`] = `
-
+
other_site
custom_description_text
-
+
`;
diff --git a/webapp/channels/src/components/common/accordion/__snapshots__/accordion.test.tsx.snap b/webapp/channels/src/components/common/accordion/__snapshots__/accordion.test.tsx.snap
index b7f7ce5231b..8181205f473 100644
--- a/webapp/channels/src/components/common/accordion/__snapshots__/accordion.test.tsx.snap
+++ b/webapp/channels/src/components/common/accordion/__snapshots__/accordion.test.tsx.snap
@@ -1,51 +1,103 @@
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`/components/common/Accordion should match snapshot 1`] = `
-
-
+
+
+
+
+
First List Item
-
,
+
Second List Item
-
,
- ],
- "title": "First Accordion Item",
- }
- }
- isExpanded={false}
- key="0"
- onButtonClick={[Function]}
- onHeaderClick={[MockFunction]}
- />
-
+
+
+
+
+
+
+
Third List Item
-
,
- ],
- "title": "Second Accordion Item",
- }
- }
- isExpanded={false}
- key="1"
- onButtonClick={[Function]}
- onHeaderClick={[MockFunction]}
- />
-
+
+
+
+
+
+
`;
diff --git a/webapp/channels/src/components/common/accordion/accordion.test.tsx b/webapp/channels/src/components/common/accordion/accordion.test.tsx
index 4756f98012a..2d94a94da65 100644
--- a/webapp/channels/src/components/common/accordion/accordion.test.tsx
+++ b/webapp/channels/src/components/common/accordion/accordion.test.tsx
@@ -1,12 +1,11 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
-import {shallow} from 'enzyme';
import React from 'react';
import Accordion from 'components/common/accordion/accordion';
-import {mountWithIntl} from 'tests/helpers/intl-test-helper';
+import {renderWithContext, userEvent} from 'tests/react_testing_utils';
describe('/components/common/Accordion', () => {
const texts = ['First List Item', 'Second List Item', 'Third List Item'];
@@ -54,87 +53,73 @@ describe('/components/common/Accordion', () => {
};
test('should match snapshot', () => {
- const wrapper = shallow(
+
diff --git a/webapp/channels/src/components/common/carousel/carousel.test.tsx b/webapp/channels/src/components/common/carousel/carousel.test.tsx
index c5adb3dc9c6..630375970c1 100644
--- a/webapp/channels/src/components/common/carousel/carousel.test.tsx
+++ b/webapp/channels/src/components/common/carousel/carousel.test.tsx
@@ -1,12 +1,11 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
-import {shallow} from 'enzyme';
import React from 'react';
import Carousel from 'components/common/carousel/carousel';
-import {mountWithIntl} from 'tests/helpers/intl-test-helper';
+import {renderWithContext, userEvent, waitFor} from 'tests/react_testing_utils';
import {BtnStyle} from './carousel_button';
@@ -43,70 +42,67 @@ describe('/components/common/Carousel', () => {
};
test('should match snapshot', () => {
- const wrapper = shallow(
);
- expect(wrapper).toMatchSnapshot();
+ const {container} = renderWithContext(
);
+ expect(container).toMatchSnapshot();
});
test('test carouse slides lenght is as expected', () => {
- const wrapper = shallow(
);
- const slides = wrapper.find('p.slide');
+ const {container} = renderWithContext(
);
+ const slides = container.querySelectorAll('p.slide');
expect(slides.length).toBe(3);
});
test('test carousel shows next and previous button', () => {
- const wrapper = mountWithIntl(
);
- const buttonNext = wrapper.find('CarouselButton').find('a.next');
- const buttonPrev = wrapper.find('CarouselButton').find('a.prev');
+ const {container} = renderWithContext(
);
+ const buttonNext = container.querySelector('a.next');
+ const buttonPrev = container.querySelector('a.prev');
- expect(buttonNext).toHaveLength(1);
- expect(buttonPrev).toHaveLength(1);
+ expect(buttonNext).toBeInTheDocument();
+ expect(buttonPrev).toBeInTheDocument();
});
test('test carousel shows next and previous chevrons when this option is sent', () => {
- const wrapper = mountWithIntl(
+ const {container} = renderWithContext(
,
);
- const nextButton = wrapper.find(Carousel).find('CarouselButton div.chevron-right');
- const prevButton = wrapper.find(Carousel).find('CarouselButton div.chevron-left');
+ const nextButton = container.querySelector('.chevron-right');
+ const prevButton = container.querySelector('.chevron-left');
- expect(nextButton).toHaveLength(1);
- expect(prevButton).toHaveLength(1);
+ expect(nextButton).toBeInTheDocument();
+ expect(prevButton).toBeInTheDocument();
});
test('test carousel shows first slide as active', () => {
- const wrapper = shallow(
);
- const activeSlide = wrapper.find('div.active-anim');
+ const {container} = renderWithContext(
);
+ const activeSlide = container.querySelector('div.active-anim');
- const slideText = activeSlide.find('p.slide').text();
+ const slideText = activeSlide!.querySelector('p.slide')!.textContent;
expect(slideText).toEqual('First Slide');
});
- test('test carousel moves slides when clicking buttons', (done) => {
- const wrapper = mountWithIntl(
);
- const activeSlide = wrapper.find('div.active-anim');
+ test('test carousel moves slides when clicking buttons', async () => {
+ const {container} = renderWithContext(
);
+ const activeSlide = container.querySelector('div.active-anim');
- const slide1Text = activeSlide.find('p.slide').text();
+ const slide1Text = activeSlide!.querySelector('p.slide')!.textContent;
expect(slide1Text).toEqual('First Slide');
- const buttonNext = wrapper.find('CarouselButton').find('a.next');
+ const buttonNext = container.querySelector('a.next') as HTMLElement;
- buttonNext.simulate('click');
+ await userEvent.click(buttonNext);
- jest.useFakeTimers();
- setTimeout(() => {
- const activeSlide = wrapper.find('div.active-anim');
- const slide1Text = activeSlide.find('p.slide').text();
- expect(slide1Text).toEqual('Second Slide');
- done();
- }, 1000);
- jest.runAllTimers();
+ await waitFor(() => {
+ const activeSlideAfterClick = container.querySelector('div.active-anim');
+ const slideText = activeSlideAfterClick!.querySelector('p.slide')!.textContent;
+ expect(slideText).toEqual('Second Slide');
+ });
});
- test('test carousel executes custom next and prev btn callback functions', () => {
+ test('test carousel executes custom next and prev btn callback functions', async () => {
const onPrevSlideClick = jest.fn();
const onNextSlideClick = jest.fn();
const props = {
@@ -114,12 +110,12 @@ describe('/components/common/Carousel', () => {
onPrevSlideClick,
onNextSlideClick};
- const wrapper = mountWithIntl(
);
- const buttonNext = wrapper.find('CarouselButton').find('a.next');
- const buttonPrev = wrapper.find('CarouselButton').find('a.prev');
+ const {container} = renderWithContext(
);
+ const buttonNext = container.querySelector('a.next') as HTMLElement;
+ const buttonPrev = container.querySelector('a.prev') as HTMLElement;
- buttonNext.simulate('click');
- buttonPrev.simulate('click');
+ await userEvent.click(buttonNext);
+ await userEvent.click(buttonPrev);
expect(onNextSlideClick).toHaveBeenCalledWith(2);
expect(onPrevSlideClick).toHaveBeenCalledWith(1);
diff --git a/webapp/channels/src/components/common/infinite_scroll.test.tsx b/webapp/channels/src/components/common/infinite_scroll.test.tsx
index ec80236dd15..7237085f0c1 100644
--- a/webapp/channels/src/components/common/infinite_scroll.test.tsx
+++ b/webapp/channels/src/components/common/infinite_scroll.test.tsx
@@ -1,13 +1,11 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
-import type {ReactWrapper} from 'enzyme';
import React from 'react';
import InfiniteScroll from 'components/common/infinite_scroll';
-import {mountWithIntl} from 'tests/helpers/intl-test-helper';
-import {act, waitFor} from 'tests/react_testing_utils';
+import {renderWithContext, fireEvent, waitFor, act} from 'tests/react_testing_utils';
describe('/components/common/InfiniteScroll', () => {
const baseProps = {
@@ -18,83 +16,141 @@ describe('/components/common/InfiniteScroll', () => {
totalItems: 20,
itemsPerPage: 10,
pageNumber: 1,
+ bufferValue: 100,
};
- let wrapper: ReactWrapper
;
-
- beforeEach(() => {
- wrapper = mountWithIntl(
) as unknown as ReactWrapper;
- });
-
test('should match snapshot', () => {
- expect(wrapper).toMatchSnapshot();
+ const {container} = renderWithContext(
);
+ expect(container).toMatchSnapshot();
- const wrapperDiv = wrapper.find(`.${baseProps.styleClass}`);
+ const wrapperDiv = container.querySelector(`.${baseProps.styleClass}`);
// InfiniteScroll is styled by the user's style
- expect(wrapperDiv.exists()).toBe(true);
+ expect(wrapperDiv).toBeInTheDocument();
// Ensure that scroll is added to InfiniteScroll wrapper div
- expect(wrapperDiv.hasClass('infinite-scroll')).toBe(true);
+ expect(wrapperDiv).toHaveClass('infinite-scroll');
});
test('should attach and remove event listeners', () => {
- const instance = wrapper.instance();
- const node = instance.node;
- node.current!.addEventListener = jest.fn();
- node.current!.removeEventListener = jest.fn();
+ const addEventListenerSpy = jest.spyOn(HTMLDivElement.prototype, 'addEventListener');
+ const removeEventListenerSpy = jest.spyOn(HTMLDivElement.prototype, 'removeEventListener');
- instance.componentDidMount();
- expect(node.current!.addEventListener).toHaveBeenCalledTimes(1);
- expect(node.current!.removeEventListener).not.toHaveBeenCalled();
+ const {unmount} = renderWithContext(
);
- instance.componentWillUnmount();
+ expect(addEventListenerSpy).toHaveBeenCalledWith('scroll', expect.any(Function));
- expect(node.current!.removeEventListener).toHaveBeenCalledTimes(1);
+ unmount();
+
+ expect(removeEventListenerSpy).toHaveBeenCalledWith('scroll', expect.any(Function));
+
+ addEventListenerSpy.mockRestore();
+ removeEventListenerSpy.mockRestore();
});
test('should execute call back function when scroll reaches the bottom and there \'s more data and no current fetch is taking place', async () => {
- const instance = wrapper.instance();
+ const {container} = renderWithContext(
);
expect(baseProps.callBack).toHaveBeenCalledTimes(0);
- act(() => {
- instance.handleScroll();
+ const scrollContainer = container.querySelector('.infinite-scroll') as HTMLElement;
+
+ // Mock scroll position to simulate being at the bottom
+ Object.defineProperty(scrollContainer, 'scrollHeight', {value: 1000, configurable: true});
+ Object.defineProperty(scrollContainer, 'clientHeight', {value: 500, configurable: true});
+ Object.defineProperty(scrollContainer, 'scrollTop', {value: 500, configurable: true});
+
+ await act(async () => {
+ fireEvent.scroll(scrollContainer);
+
+ // Wait for debounce (200ms) plus some buffer
+ await new Promise((resolve) => setTimeout(resolve, 250));
});
await waitFor(() => {
- expect(wrapper.state().isFetching).toBe(true);
expect(baseProps.callBack).toHaveBeenCalledTimes(1);
});
});
- test('should not execute call back even if scroll is a the bottom when there \'s no more data', async () => {
- act(() => {
- wrapper.setState({isEndofData: true});
+ test('should not execute call back even if scroll is at the bottom when there \'s no more data', async () => {
+ // Set totalItems to 0 to simulate no data/end of data scenario
+ const propsWithNoData = {
+ ...baseProps,
+ totalItems: 0,
+ };
+
+ const {container} = renderWithContext(
+
,
+ );
+
+ const scrollContainer = container.querySelector('.infinite-scroll') as HTMLElement;
+
+ // Mock scroll position to simulate being at the bottom
+ Object.defineProperty(scrollContainer, 'scrollHeight', {value: 1000, configurable: true});
+ Object.defineProperty(scrollContainer, 'clientHeight', {value: 500, configurable: true});
+ Object.defineProperty(scrollContainer, 'scrollTop', {value: 500, configurable: true});
+
+ await act(async () => {
+ fireEvent.scroll(scrollContainer);
+
+ // Wait for debounce (200ms) plus some buffer
+ await new Promise((resolve) => setTimeout(resolve, 250));
});
- const instance = wrapper.instance();
-
- act(() => {
- instance.handleScroll();
+ // First scroll triggers callback, which then sets isEndofData to true since totalItems is 0
+ await waitFor(() => {
+ expect(baseProps.callBack).toHaveBeenCalledTimes(1);
});
- expect(baseProps.callBack).toHaveBeenCalledTimes(0);
+ // Subsequent scroll should not trigger callback since isEndofData is now true
+ await act(async () => {
+ fireEvent.scroll(scrollContainer);
+ await new Promise((resolve) => setTimeout(resolve, 250));
+ });
+
+ // Should still be only 1 call
+ expect(baseProps.callBack).toHaveBeenCalledTimes(1);
});
- test('should not show loading screen if there is no data', () => {
- let loadingDiv = wrapper.find('.loading-screen');
- expect(loadingDiv.exists()).toBe(false);
+ test('should not show loading screen if there is no data', async () => {
+ // Create a callback that doesn't resolve immediately to keep loading state
+ let resolveCallback: () => void;
+ const slowCallback = jest.fn(() => new Promise((resolve) => {
+ resolveCallback = resolve;
+ }));
- act(() => {
- wrapper.setState({isFetching: true});
+ const propsWithSlowCallback = {
+ ...baseProps,
+ callBack: slowCallback,
+ };
+
+ const {container} = renderWithContext(
);
+ let loadingDiv = container.querySelector('.loading-screen');
+ expect(loadingDiv).not.toBeInTheDocument();
+
+ // Mock scroll to trigger fetching state
+ const scrollContainer = container.querySelector('.infinite-scroll') as HTMLElement;
+
+ Object.defineProperty(scrollContainer, 'scrollHeight', {value: 1000, configurable: true});
+ Object.defineProperty(scrollContainer, 'clientHeight', {value: 500, configurable: true});
+ Object.defineProperty(scrollContainer, 'scrollTop', {value: 500, configurable: true});
+
+ await act(async () => {
+ fireEvent.scroll(scrollContainer);
+
+ // Wait for debounce (200ms) plus some buffer
+ await new Promise((resolve) => setTimeout(resolve, 250));
});
- expect(wrapper).toMatchSnapshot();
- expect(wrapper.state().isFetching).toBe(true);
+ // Now it should show the loader during fetching
+ loadingDiv = container.querySelector('.loading-screen');
+ expect(loadingDiv).toBeInTheDocument();
- // Now it should show the loader.
- loadingDiv = wrapper.find('.loading-screen');
- expect(loadingDiv.exists()).toBe(true);
+ expect(container).toMatchSnapshot();
+
+ // Resolve the callback to cleanup
+ await act(async () => {
+ resolveCallback!();
+ });
});
});
diff --git a/webapp/channels/src/components/common/radio_group.test.tsx b/webapp/channels/src/components/common/radio_group.test.tsx
index fa74eaecaa9..b8e9308ce2b 100644
--- a/webapp/channels/src/components/common/radio_group.test.tsx
+++ b/webapp/channels/src/components/common/radio_group.test.tsx
@@ -1,11 +1,12 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
-import {shallow} from 'enzyme';
import React from 'react';
import RadioButtonGroup from 'components/common/radio_group';
+import {render, screen, userEvent} from 'tests/react_testing_utils';
+
describe('/components/common/RadioButtonGroup', () => {
const onChange = jest.fn();
const baseProps = {
@@ -16,22 +17,22 @@ describe('/components/common/RadioButtonGroup', () => {
};
test('should match snapshot', () => {
- const wrapper = shallow( );
- expect(wrapper).toMatchSnapshot();
+ const {container} = render( );
+ expect(container).toMatchSnapshot();
});
test('test radio button group input lenght is as expected', () => {
- const wrapper = shallow( );
- const buttons = wrapper.find('input');
+ render( );
+ const buttons = screen.getAllByRole('radio');
expect(buttons.length).toBe(3);
});
- test('test radio button group onChange function', () => {
- const wrapper = shallow( );
+ test('test radio button group onChange function', async () => {
+ render( );
- const buttons = wrapper.find('input');
- buttons.at(0).simulate('change');
+ const buttons = screen.getAllByRole('radio');
+ await userEvent.click(buttons[0]);
expect(onChange).toHaveBeenCalledTimes(1);
});
diff --git a/webapp/channels/src/components/common/site_name_and_description.test.tsx b/webapp/channels/src/components/common/site_name_and_description.test.tsx
index c0d9892cc06..afdf74d2630 100644
--- a/webapp/channels/src/components/common/site_name_and_description.test.tsx
+++ b/webapp/channels/src/components/common/site_name_and_description.test.tsx
@@ -1,12 +1,12 @@
// 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 SiteNameAndDescription from 'components/common/site_name_and_description';
+import {renderWithContext, screen} from 'tests/react_testing_utils';
+
describe('/components/common/SiteNameAndDescription', () => {
const baseProps = {
customDescriptionText: '',
@@ -14,18 +14,18 @@ describe('/components/common/SiteNameAndDescription', () => {
};
test('should match snapshot, default', () => {
- const wrapper = shallow( );
- expect(wrapper).toMatchSnapshot();
- expect(wrapper.find('h1').text()).toEqual(baseProps.siteName);
- expect(wrapper.find(FormattedMessage).exists()).toBe(true);
+ const {container} = renderWithContext( );
+ expect(container).toMatchSnapshot();
+ expect(screen.getByRole('heading', {level: 1})).toHaveTextContent(baseProps.siteName);
+ expect(screen.getByText('All team communication in one place, searchable and accessible anywhere')).toBeInTheDocument();
});
test('should match snapshot, with custom site name and description', () => {
const props = {...baseProps, customDescriptionText: 'custom_description_text', siteName: 'other_site'};
- const wrapper = shallow( );
+ const {container} = renderWithContext( );
- expect(wrapper).toMatchSnapshot();
- expect(wrapper.find('h1').text()).toEqual(props.siteName);
- expect(wrapper.find('h3').text()).toEqual(props.customDescriptionText);
+ expect(container).toMatchSnapshot();
+ expect(screen.getByRole('heading', {level: 1})).toHaveTextContent(props.siteName);
+ expect(screen.getByRole('heading', {level: 3})).toHaveTextContent(props.customDescriptionText);
});
});
diff --git a/webapp/channels/src/components/create_team/__snapshots__/create_team.test.tsx.snap b/webapp/channels/src/components/create_team/__snapshots__/create_team.test.tsx.snap
index 75aa09295b1..5cd4a8ed093 100644
--- a/webapp/channels/src/components/create_team/__snapshots__/create_team.test.tsx.snap
+++ b/webapp/channels/src/components/create_team/__snapshots__/create_team.test.tsx.snap
@@ -2,36 +2,111 @@
exports[`component/create_team should match snapshot default 1`] = `
-
-
-
+
diff --git a/webapp/channels/src/components/create_team/components/__snapshots__/display_name.test.tsx.snap b/webapp/channels/src/components/create_team/components/__snapshots__/display_name.test.tsx.snap
index 515cda38953..e81b93741ed 100644
--- a/webapp/channels/src/components/create_team/components/__snapshots__/display_name.test.tsx.snap
+++ b/webapp/channels/src/components/create_team/components/__snapshots__/display_name.test.tsx.snap
@@ -2,66 +2,74 @@
exports[`/components/create_team/components/display_name should match snapshot 1`] = `
-
+
+ Name your team in any language. Your team name shows in menus and headings.
+
+
+ Next
+
+
+
+
`;
diff --git a/webapp/channels/src/components/create_team/components/display_name.test.tsx b/webapp/channels/src/components/create_team/components/display_name.test.tsx
index e57f72f9c9f..02b886ae463 100644
--- a/webapp/channels/src/components/create_team/components/display_name.test.tsx
+++ b/webapp/channels/src/components/create_team/components/display_name.test.tsx
@@ -1,13 +1,11 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
-import {shallow} from 'enzyme';
-import type {ReactWrapper} from 'enzyme';
import React from 'react';
import DisplayName from 'components/create_team/components/display_name';
-import {mountWithIntl} from 'tests/helpers/intl-test-helper';
+import {renderWithContext, screen, fireEvent, userEvent} from 'tests/react_testing_utils';
import {cleanUpUrlable} from 'utils/url';
jest.mock('images/logo.png', () => 'logo.png');
@@ -22,50 +20,48 @@ describe('/components/create_team/components/display_name', () => {
};
test('should match snapshot', () => {
- const wrapper = shallow(
);
- expect(wrapper).toMatchSnapshot();
+ const {container} = renderWithContext(
);
+ expect(container).toMatchSnapshot();
});
- test('should run updateParent function', () => {
- const wrapper = mountWithIntl(
);
+ test('should run updateParent function', async () => {
+ renderWithContext(
);
- wrapper.find('button').simulate('click', {
- preventDefault: () => jest.fn(),
- });
+ await userEvent.click(screen.getByRole('button', {name: /next/i}));
- expect(wrapper.prop('updateParent')).toHaveBeenCalled();
+ expect(defaultProps.updateParent).toHaveBeenCalled();
});
- test('should pass state to updateParent function', () => {
- const wrapper = mountWithIntl(
);
+ test('should pass state to updateParent function', async () => {
+ renderWithContext(
);
- wrapper.find('button').simulate('click', {
- preventDefault: () => jest.fn(),
- });
+ await userEvent.click(screen.getByRole('button', {name: /next/i}));
- expect(wrapper.prop('updateParent')).toHaveBeenCalledWith(defaultProps.state);
+ expect(defaultProps.updateParent).toHaveBeenCalledWith(expect.objectContaining({
+ wizard: 'team_url',
+ team: expect.objectContaining({
+ display_name: 'test-team',
+ }),
+ }));
});
- test('should pass updated team name to updateParent function', () => {
- const wrapper = mountWithIntl(
);
+ test('should pass updated team name to updateParent function', async () => {
+ renderWithContext(
);
const teamDisplayName = 'My Test Team';
- const newState = {
- ...defaultProps.state,
- team: {
- ...defaultProps.state.team,
- display_name: teamDisplayName,
- name: cleanUpUrlable(teamDisplayName),
- },
+ const expectedTeam = {
+ ...defaultProps.state.team,
+ display_name: teamDisplayName,
+ name: cleanUpUrlable(teamDisplayName),
};
- (wrapper.find('.form-control') as unknown as ReactWrapper
).instance().value = teamDisplayName;
- wrapper.find('.form-control').simulate('change');
+ const input = screen.getByRole('textbox');
+ fireEvent.change(input, {target: {value: teamDisplayName}});
- wrapper.find('button').simulate('click', {
- preventDefault: () => jest.fn(),
- });
+ await userEvent.click(screen.getByRole('button', {name: /next/i}));
- expect(wrapper.prop('updateParent')).toHaveBeenCalledWith(defaultProps.state);
- expect(wrapper.prop('updateParent').mock.calls[0][0]).toEqual(newState);
+ expect(defaultProps.updateParent).toHaveBeenCalledWith(expect.objectContaining({
+ wizard: 'team_url',
+ team: expectedTeam,
+ }));
});
});
diff --git a/webapp/channels/src/components/create_team/components/team_url/__snapshots__/team_url.test.tsx.snap b/webapp/channels/src/components/create_team/components/team_url/__snapshots__/team_url.test.tsx.snap
index 98e0b521df7..dd7ca647781 100644
--- a/webapp/channels/src/components/create_team/components/team_url/__snapshots__/team_url.test.tsx.snap
+++ b/webapp/channels/src/components/create_team/components/team_url/__snapshots__/team_url.test.tsx.snap
@@ -2,119 +2,88 @@
exports[`/components/create_team/components/display_name should match snapshot 1`] = `
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
+ Choose the web address of your new team:
+
+
-
-
+
+
+
`;
diff --git a/webapp/channels/src/components/create_team/components/team_url/team_url.test.tsx b/webapp/channels/src/components/create_team/components/team_url/team_url.test.tsx
index cf56770979a..3d3a62a4243 100644
--- a/webapp/channels/src/components/create_team/components/team_url/team_url.test.tsx
+++ b/webapp/channels/src/components/create_team/components/team_url/team_url.test.tsx
@@ -1,7 +1,6 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
-import {shallow} from 'enzyme';
import React from 'react';
import TeamUrl from 'components/create_team/components/team_url/team_url';
@@ -26,8 +25,8 @@ describe('/components/create_team/components/display_name', () => {
};
test('should match snapshot', () => {
- const wrapper = shallow( );
- expect(wrapper).toMatchSnapshot();
+ const {container} = renderWithContext( );
+ expect(container).toMatchSnapshot();
});
test('should return to display_name.jsx page', async () => {
diff --git a/webapp/channels/src/components/create_team/create_team.test.tsx b/webapp/channels/src/components/create_team/create_team.test.tsx
index 57bfaa55ec1..a123fd6913f 100644
--- a/webapp/channels/src/components/create_team/create_team.test.tsx
+++ b/webapp/channels/src/components/create_team/create_team.test.tsx
@@ -1,9 +1,9 @@
// 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 {renderWithContext, screen} from 'tests/react_testing_utils';
import {CreateTeam} from './create_team';
@@ -29,11 +29,11 @@ describe('component/create_team', () => {
} as any;
test('should match snapshot default', () => {
- const wrapper = shallow(
+ const {container} = renderWithContext(
,
);
- expect(wrapper).toMatchSnapshot();
+ expect(container).toMatchSnapshot();
});
test('should show title and message when cloud and team limit reached', () => {
@@ -48,22 +48,11 @@ describe('component/create_team', () => {
},
};
- const wrapper = shallow(
+ renderWithContext(
,
);
- expect(wrapper.contains(
- ,
- )).toEqual(true);
- expect(wrapper.contains(
- ,
- )).toEqual(true);
+ expect(screen.getByText('Professional feature')).toBeInTheDocument();
+ expect(screen.getByText('Your workspace plan has reached the limit on the number of teams. Create unlimited teams with a free 30-day trial. Contact your System Administrator.')).toBeInTheDocument();
});
});
diff --git a/webapp/channels/src/components/quick_input/__snapshots__/max_length_input.test.tsx.snap b/webapp/channels/src/components/quick_input/__snapshots__/max_length_input.test.tsx.snap
index 051a8df46fd..6ee1085d5fc 100644
--- a/webapp/channels/src/components/quick_input/__snapshots__/max_length_input.test.tsx.snap
+++ b/webapp/channels/src/components/quick_input/__snapshots__/max_length_input.test.tsx.snap
@@ -1,33 +1,34 @@
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`components/MaxLengthInput should match snapshot 1`] = `
-
+
-
+
`;
exports[`components/MaxLengthInput should match snapshot 2`] = `
-
+
-
+
`;
exports[`components/MaxLengthInput should match snapshot 3`] = `
-
+
-
2
-
+
`;
diff --git a/webapp/channels/src/components/quick_input/max_length_input.test.tsx b/webapp/channels/src/components/quick_input/max_length_input.test.tsx
index 0de79a56c06..0116e799fd4 100644
--- a/webapp/channels/src/components/quick_input/max_length_input.test.tsx
+++ b/webapp/channels/src/components/quick_input/max_length_input.test.tsx
@@ -1,11 +1,12 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
-import {shallow} from 'enzyme';
import React from 'react';
import {MaxLengthInput} from 'components/quick_input/index';
+import {render, screen} from 'tests/react_testing_utils';
+
describe('components/MaxLengthInput', () => {
const requiredProps = {
className: 'input',
@@ -17,13 +18,13 @@ describe('components/MaxLengthInput', () => {
['less than 20'],
['Where is Jessica Hyde?'],
])('should match snapshot', (defaultValue) => {
- const wrapper = shallow(
+ const {container} = render(
,
);
- expect(wrapper).toMatchSnapshot();
+ expect(container).toMatchSnapshot();
});
test.each([
@@ -31,15 +32,16 @@ describe('components/MaxLengthInput', () => {
['less than 20', false, false],
['Where is Jessica Hyde?', true, true],
])('defaultValue: %s .has-error: %s, .MaxLengthInput__validation: %s', (defaultValue, hasError, maxLengthExists) => {
- const wrapper = shallow(
+ const {container} = render(
,
);
- expect(wrapper.find('input').hasClass('has-error')).toBe(hasError);
- expect(wrapper.exists('.MaxLengthInput__validation')).toBe(maxLengthExists);
+ const input = screen.getByRole('textbox');
+ expect(input.classList.contains('has-error')).toBe(hasError);
+ expect(container.querySelector('.MaxLengthInput__validation') !== null).toBe(maxLengthExists);
});
test('should display the number of times value length exceeds maxLength', () => {
@@ -48,10 +50,10 @@ describe('components/MaxLengthInput', () => {
...requiredProps,
};
- const wrapper = shallow(
+ const {container} = render(
,
);
- expect(wrapper.find('.MaxLengthInput__validation').text()).toBe('-2');
+ expect(container.querySelector('.MaxLengthInput__validation')!.textContent).toBe('-2');
});
});
diff --git a/webapp/channels/src/components/search_hint/__snapshots__/search_hint.test.tsx.snap b/webapp/channels/src/components/search_hint/__snapshots__/search_hint.test.tsx.snap
index e9b9737cf85..bf636e58a0e 100644
--- a/webapp/channels/src/components/search_hint/__snapshots__/search_hint.test.tsx.snap
+++ b/webapp/channels/src/components/search_hint/__snapshots__/search_hint.test.tsx.snap
@@ -1,620 +1,462 @@
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`components/SearchHint should match snapshot, with searchType 1`] = `
-
+
From:
-
+ Messages from a user
In:
-
+ Messages in a channel
On:
-
+ Messages on a date
Before:
-
+ Messages before a date
After:
-
+ Messages after a date
—
-
+ Exclude search terms
""
-
+ Messages with phrases
-
+
`;
exports[`components/SearchHint should match snapshot, with title 1`] = `
-
+
-
+ Search options
From:
-
+ Messages from a user
In:
-
+ Messages in a channel
On:
-
+ Messages on a date
Before:
-
+ Messages before a date
After:
-
+ Messages after a date
—
-
+ Exclude search terms
""
-
+ Messages with phrases
-
+
`;
exports[`components/SearchHint should match snapshot, without searchType 1`] = `
-
+
-
-
-
-
-
-
-
-
-
+
+ Learn about search
+
+
+
+
+
-
-
-
+
+
+ Messages
+
+
+
+ Files
+
+
`;
exports[`components/SearchHint should match snapshot, without title 1`] = `
-
+
From:
-
+ Messages from a user
In:
-
+ Messages in a channel
On:
-
+ Messages on a date
Before:
-
+ Messages before a date
After:
-
+ Messages after a date
—
-
+ Exclude search terms
""
-
+ Messages with phrases
-
+
`;
diff --git a/webapp/channels/src/components/search_hint/search_hint.test.tsx b/webapp/channels/src/components/search_hint/search_hint.test.tsx
index 8b2ad35bf98..2aef1e3edc7 100644
--- a/webapp/channels/src/components/search_hint/search_hint.test.tsx
+++ b/webapp/channels/src/components/search_hint/search_hint.test.tsx
@@ -1,54 +1,51 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
-import {shallow} from 'enzyme';
import React from 'react';
import SearchHint from 'components/search_hint/search_hint';
+import {renderWithContext} from 'tests/react_testing_utils';
import {searchHintOptions} from 'utils/constants';
-let mockState: any;
-
-jest.mock('react-redux', () => ({
- ...jest.requireActual('react-redux') as typeof import('react-redux'),
- useSelector: (selector: (state: typeof mockState) => unknown) => selector(mockState),
-}));
-
describe('components/SearchHint', () => {
const baseProps = {
withTitle: false,
onOptionSelected: jest.fn(),
options: searchHintOptions,
};
- beforeEach(() => {
- mockState = {
- entities: {
- general: {
- config: {
- EnableFileAttachments: 'true',
- },
+
+ const initialState = {
+ entities: {
+ general: {
+ config: {
+ EnableFileAttachments: 'true',
},
},
- };
- });
+ users: {
+ currentUserId: 'currentUserId',
+ },
+ },
+ };
test('should match snapshot, with title', () => {
const props = {
...baseProps,
withTitle: true,
};
- const wrapper = shallow(
+ const {container} = renderWithContext(
,
+ initialState,
);
- expect(wrapper).toMatchSnapshot();
+ expect(container).toMatchSnapshot();
});
test('should match snapshot, without title', () => {
- const wrapper = shallow(
+ const {container} = renderWithContext(
,
+ initialState,
);
- expect(wrapper).toMatchSnapshot();
+ expect(container).toMatchSnapshot();
});
test('should match snapshot, without searchType', () => {
@@ -58,10 +55,11 @@ describe('components/SearchHint', () => {
onSearchTypeSelected: jest.fn(),
searchType: '' as 'files' | 'messages' | '',
};
- const wrapper = shallow(
+ const {container} = renderWithContext(
,
+ initialState,
);
- expect(wrapper).toMatchSnapshot();
+ expect(container).toMatchSnapshot();
});
test('should match snapshot, with searchType', () => {
@@ -70,9 +68,10 @@ describe('components/SearchHint', () => {
onSearchTypeSelected: jest.fn(),
searchType: 'files' as 'files' | 'messages' | '',
};
- const wrapper = shallow(
+ const {container} = renderWithContext(
,
+ initialState,
);
- expect(wrapper).toMatchSnapshot();
+ expect(container).toMatchSnapshot();
});
});
diff --git a/webapp/channels/src/components/search_results/__snapshots__/files_filter_menu.test.tsx.snap b/webapp/channels/src/components/search_results/__snapshots__/files_filter_menu.test.tsx.snap
index 453023240be..9aa19255656 100644
--- a/webapp/channels/src/components/search_results/__snapshots__/files_filter_menu.test.tsx.snap
+++ b/webapp/channels/src/components/search_results/__snapshots__/files_filter_menu.test.tsx.snap
@@ -1,790 +1,270 @@
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`components/search_results/FilesFilterMenu should match snapshot, on all filter selected 1`] = `
-
-
+
`;
exports[`components/search_results/FilesFilterMenu should match snapshot, on audio filter selected 1`] = `
-
-
+
`;
exports[`components/search_results/FilesFilterMenu should match snapshot, on code filter selected 1`] = `
-
-
+
`;
exports[`components/search_results/FilesFilterMenu should match snapshot, on documents filter selected 1`] = `
-
-
+
`;
exports[`components/search_results/FilesFilterMenu should match snapshot, on images filter selected 1`] = `
-
-
+
`;
exports[`components/search_results/FilesFilterMenu should match snapshot, on presentations filter selected 1`] = `
-
-
+
`;
exports[`components/search_results/FilesFilterMenu should match snapshot, on spreadsheets filter selected 1`] = `
-
-
+
`;
exports[`components/search_results/FilesFilterMenu should match snapshot, on video filter selected 1`] = `
-
-
+
`;
diff --git a/webapp/channels/src/components/search_results/__snapshots__/messages_or_files_selector.test.tsx.snap b/webapp/channels/src/components/search_results/__snapshots__/messages_or_files_selector.test.tsx.snap
index 23150cc7ecb..3a8051c0111 100644
--- a/webapp/channels/src/components/search_results/__snapshots__/messages_or_files_selector.test.tsx.snap
+++ b/webapp/channels/src/components/search_results/__snapshots__/messages_or_files_selector.test.tsx.snap
@@ -1,124 +1,179 @@
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`components/search_results/MessagesOrFilesSelector should match snapshot, on files selected 1`] = `
-
-
-
+
+
+
+
+ Messages
+
+ 5
+
+
+
+ Files
+
+ 10
+
+
+
+
+
+
`;
exports[`components/search_results/MessagesOrFilesSelector should match snapshot, on messages selected 1`] = `
-
-
-
+
+
+
+
+ Messages
+
+ 5
+
+
+
+ Files
+
+ 10
+
+
+
+
+
`;
exports[`components/search_results/MessagesOrFilesSelector should match snapshot, without files tab 1`] = `
-
-
-
+
+
+
+
+ Messages
+
+ 5
+
+
+
+
+
+
`;
diff --git a/webapp/channels/src/components/search_results/files_filter_menu.test.tsx b/webapp/channels/src/components/search_results/files_filter_menu.test.tsx
index 9e193dab1fd..026896ebc28 100644
--- a/webapp/channels/src/components/search_results/files_filter_menu.test.tsx
+++ b/webapp/channels/src/components/search_results/files_filter_menu.test.tsx
@@ -1,24 +1,24 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
-import {shallow} from 'enzyme';
-import type {ShallowWrapper} from 'enzyme';
import React from 'react';
import FilesFilterMenu from 'components/search_results/files_filter_menu';
+import {renderWithContext} from 'tests/react_testing_utils';
+
describe('components/search_results/FilesFilterMenu', () => {
const filters = ['all', 'documents', 'spreadsheets', 'presentations', 'code', 'images', 'audio', 'video'];
for (const filter of filters) {
test(`should match snapshot, on ${filter} filter selected`, () => {
- const wrapper: ShallowWrapper = shallow(
+ const {container} = renderWithContext(
,
);
- expect(wrapper).toMatchSnapshot();
+ expect(container).toMatchSnapshot();
});
}
});
diff --git a/webapp/channels/src/components/search_results/messages_or_files_selector.test.tsx b/webapp/channels/src/components/search_results/messages_or_files_selector.test.tsx
index 5e8e9a2b3b7..3aa9136b4f7 100644
--- a/webapp/channels/src/components/search_results/messages_or_files_selector.test.tsx
+++ b/webapp/channels/src/components/search_results/messages_or_files_selector.test.tsx
@@ -1,77 +1,81 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
-import {shallow} from 'enzyme';
-import type {ShallowWrapper} from 'enzyme';
import React from 'react';
-import {Provider} from 'react-redux';
+import type {SearchFilterType} from 'components/search/types';
import MessagesOrFilesSelector from 'components/search_results/messages_or_files_selector';
-import mockStore from 'tests/test_store';
+import {renderWithContext} from 'tests/react_testing_utils';
describe('components/search_results/MessagesOrFilesSelector', () => {
- const store = mockStore({});
+ const baseProps = {
+ selected: 'messages' as 'messages' | 'files',
+ selectedFilter: 'code' as SearchFilterType,
+ messagesCounter: '5',
+ filesCounter: '10',
+ isFileAttachmentsEnabled: true,
+ onChange: jest.fn(),
+ onFilter: jest.fn(),
+ onTeamChange: jest.fn(),
+ crossTeamSearchEnabled: false,
+ };
+
+ const initialState = {
+ entities: {
+ teams: {
+ currentTeamId: 'team1',
+ teams: {
+ team1: {id: 'team1', name: 'team1', display_name: 'Team 1'},
+ },
+ myMembers: {
+ team1: {team_id: 'team1', user_id: 'user1'},
+ },
+ },
+ users: {
+ currentUserId: 'user1',
+ },
+ general: {
+ config: {},
+ },
+ },
+ };
test('should match snapshot, on messages selected', () => {
- const wrapper: ShallowWrapper = shallow(
-
-
- ,
+ const {container} = renderWithContext(
+ ,
+ initialState,
);
- expect(wrapper).toMatchSnapshot();
+ expect(container).toMatchSnapshot();
});
test('should match snapshot, on files selected', () => {
- const wrapper: ShallowWrapper = shallow(
+ const props = {
+ ...baseProps,
+ selected: 'files' as 'messages' | 'files',
+ };
-
-
- ,
+ const {container} = renderWithContext(
+ ,
+ initialState,
);
- expect(wrapper).toMatchSnapshot();
+ expect(container).toMatchSnapshot();
});
+
test('should match snapshot, without files tab', () => {
- const wrapper: ShallowWrapper = shallow(
+ const props = {
+ ...baseProps,
+ selected: 'files' as 'messages' | 'files',
+ isFileAttachmentsEnabled: false,
+ };
-
-
-
- ,
+ const {container} = renderWithContext(
+ ,
+ initialState,
);
- expect(wrapper).toMatchSnapshot();
+ expect(container).toMatchSnapshot();
});
});
diff --git a/webapp/channels/src/components/search_shortcut/__snapshots__/search_shortcut.test.tsx.snap b/webapp/channels/src/components/search_shortcut/__snapshots__/search_shortcut.test.tsx.snap
index 263b079bd09..cc25d48a87f 100644
--- a/webapp/channels/src/components/search_shortcut/__snapshots__/search_shortcut.test.tsx.snap
+++ b/webapp/channels/src/components/search_shortcut/__snapshots__/search_shortcut.test.tsx.snap
@@ -1,89 +1,87 @@
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`components/SearchShortcut should match snapshot on Mac desktop 1`] = `
-
-
+
- Ctrl
-
-
- Shift
-
-
- F
-
-
+
+ ⌘
+
+
+ F
+
+
+
`;
exports[`components/SearchShortcut should match snapshot on Mac webapp 1`] = `
-