Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

[PLT-7814] Upgrade to enzyme-adapter-react-16 and enable unit/components tests at Jenkins build #303

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ check-style: .yarninstall
yarn run check

test: .yarninstall
cd $(BUILD_SERVER_DIR) && $(MAKE) internal-test-web-client
@echo Running jest unit/component testing

yarn run test

.yarninstall: package.json
@echo Getting dependencies using yarn
Expand Down
1 change: 1 addition & 0 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ When filling in a section please remove the help text and the above text.
#### Checklist
[Place an '[x]' (no spaces) in all applicable fields. Please remove unrelated fields.]
- [ ] Ran `make check-style` to check for style errors (required for all pull requests)
- [ ] Ran `make test` to ensure unit and component tests passed
- [ ] Added or updated unit tests (required for all new features)
- [ ] Has server changes (please link)
- [ ] Has redux changes (please link)
Expand Down
7 changes: 7 additions & 0 deletions build/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ podTemplate(label: 'jenkins-slave-webapp',
}
}
}
stage('Unit/Component Tests') {
container('mattermost-node') {
dir('mattermost-webapp') {
sh 'make test'
}
}
}
stage('Build') {
container('mattermost-node') {
dir('mattermost-webapp') {
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"cross-env": "5.1.1",
"css-loader": "0.28.7",
"enzyme": "3.1.1",
"enzyme-adapter-react-15": "1.0.5",
"enzyme-adapter-react-16": "1.1.0",
"enzyme-to-json": "3.2.2",
"eslint": "3.17.1",
"eslint-import-resolver-webpack": "0.8.3",
Expand Down Expand Up @@ -113,12 +113,15 @@
"/node_modules/",
"/non_npm_dependencies/"
],
"clearMocks": true,
"collectCoverageFrom": [
"actions/**/*.{js,jsx}",
"client/**/*.{js,jsx}",
"components/**/*.jsx",
"plugins/**/*.{js,jsx}",
"reducers/**/*.{js,jsx}",
"routes/**/*.{js,jsx}",
"selectors/**/*.{js,jsx}",
"stores/**/*.{js,jsx}",
"utils/**/*.{js,jsx}"
],
Expand Down
1 change: 0 additions & 1 deletion tests/components/about_build_modal.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import React from 'react';
import {Modal} from 'react-bootstrap';

import {shallow} from 'enzyme';

import {mountWithIntl} from 'tests/helpers/intl-test-helper.jsx';
Expand Down
4 changes: 0 additions & 4 deletions tests/components/audio_video_preview.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ describe('component/AudioVideoPreview', () => {
fileUrl: '/api/v4/files/file_id'
};

afterAll(() => {
jest.clearAllMocks();
});

test('should match snapshot without children', () => {
const wrapper = shallow(
<AudioVideoPreview {...requiredProps}/>
Expand Down
1 change: 0 additions & 1 deletion tests/components/channel_info_modal.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import React from 'react';
import {Modal} from 'react-bootstrap';

import {shallow} from 'enzyme';

import {mountWithIntl} from 'tests/helpers/intl-test-helper.jsx';
Expand Down
1 change: 0 additions & 1 deletion tests/components/get_link_modal.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// See License.txt for license information.

import React from 'react';

import {shallow} from 'enzyme';
import {Modal} from 'react-bootstrap';

Expand Down
4 changes: 0 additions & 4 deletions tests/components/pdf_preview.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ describe('component/PDFPreview', () => {
fileUrl: 'https://pre-release.mattermost.com/api/v4/files/ips59w4w9jnfbrs3o94m1dbdie'
};

afterAll(() => {
jest.clearAllMocks();
});

test('should match snapshot, loading', () => {
const wrapper = shallow(
<PDFPreview {...requiredProps}/>
Expand Down
1 change: 0 additions & 1 deletion tests/plugins/__snapshots__/pluggable.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ exports[`plugins/Pluggable should match snapshot with no overridden component 1`
<div
data-toggle="tooltip"
key="user-popover-email"
title={undefined}
>
<a
className="text-nowrap text-lowercase user-popover__email"
Expand Down
1 change: 0 additions & 1 deletion tests/plugins/__snapshots__/post_type.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ exports[`plugins/PostMessageView should match snapshot with extended post type 1
}
>
<PostTypePlugin
compactDisplay={undefined}
isRHS={false}
mentionKeys={Array []}
post={
Expand Down
2 changes: 1 addition & 1 deletion tests/setup.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

import Adapter from 'enzyme-adapter-react-15';
import Adapter from 'enzyme-adapter-react-16';
import {configure} from 'enzyme';

configure({adapter: new Adapter()});
Expand Down
23 changes: 13 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2607,15 +2607,16 @@ entities@^1.1.1, entities@~1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0"

enzyme-adapter-react-15@1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/enzyme-adapter-react-15/-/enzyme-adapter-react-15-1.0.5.tgz#99f9a03ff2c2303e517342935798a6bdfbb75fac"
enzyme-adapter-react-16@1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/enzyme-adapter-react-16/-/enzyme-adapter-react-16-1.1.0.tgz#86c5db7c10f0be6ec25d54ca41b59f2abb397cf4"
dependencies:
enzyme-adapter-utils "^1.1.0"
lodash "^4.17.4"
object.assign "^4.0.4"
object.values "^1.0.4"
prop-types "^15.5.10"
react-test-renderer "^16.0.0-0"

enzyme-adapter-utils@^1.1.0:
version "1.1.1"
Expand Down Expand Up @@ -5713,7 +5714,7 @@ mime-db@~1.27.0:
version "1.27.0"
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.27.0.tgz#820f572296bbd20ec25ed55e5b5de869e5436eb1"

mime-types@^2.1.12:
mime-types@^2.1.12, mime-types@~2.1.17:
version "2.1.17"
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.17.tgz#09d7a393f03e995a79f8af857b70a9e0ab16557a"
dependencies:
Expand All @@ -5725,12 +5726,6 @@ mime-types@~2.1.11, mime-types@~2.1.15, mime-types@~2.1.7:
dependencies:
mime-db "~1.27.0"

mime-types@~2.1.17:
version "2.1.17"
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.17.tgz#09d7a393f03e995a79f8af857b70a9e0ab16557a"
dependencies:
mime-db "~1.30.0"

mime@1.3.4:
version "1.3.4"
resolved "https://registry.yarnpkg.com/mime/-/mime-1.3.4.tgz#115f9e3b6b3daf2959983cb38f149a2d40eb5d53"
Expand Down Expand Up @@ -7113,6 +7108,14 @@ react-test-renderer@16.1.0:
object-assign "^4.1.1"
prop-types "^15.6.0"

react-test-renderer@^16.0.0-0:
version "16.1.1"
resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-16.1.1.tgz#a05184688d564be799f212449262525d1e350537"
dependencies:
fbjs "^0.8.16"
object-assign "^4.1.1"
prop-types "^15.6.0"

react@16.1.0:
version "16.1.0"
resolved "https://registry.yarnpkg.com/react/-/react-16.1.0.tgz#1c2bdac3c17fe7ee9282fa35aca6cc36387903e1"
Expand Down