Skip to content

Commit

Permalink
Merge pull request #20 from Brightscout/MI-809
Browse files Browse the repository at this point in the history
MI-809 add test cases for webapp
  • Loading branch information
jatinkksharma authored Feb 14, 2020
2 parents a73d44f + 0227c38 commit 6435ef5
Show file tree
Hide file tree
Showing 11 changed files with 3,988 additions and 813 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,6 @@ plugin.exe
vendor/
.history/
coverage.txt

# webapp test cases
build/test-results.xml
6 changes: 0 additions & 6 deletions webapp/.babelrc

This file was deleted.

41 changes: 41 additions & 0 deletions webapp/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const config = {
presets: [
['@babel/preset-env', {
targets: {
chrome: 66,
firefox: 60,
edge: 42,
safari: 12,
},
modules: false,
corejs: 3,
debug: false,
useBuiltIns: 'usage',
shippedProposals: true,
}],
['@babel/preset-react', {
useBuiltIns: true,
}],
['@babel/typescript', {
allExtensions: true,
isTSX: true,
}],
],
plugins: [
'@babel/plugin-proposal-class-properties',
'@babel/plugin-syntax-dynamic-import',
'@babel/proposal-object-rest-spread',
'babel-plugin-typescript-to-proptypes',
],
};

// Jest needs module transformation
config.env = {
test: {
presets: config.presets,
plugins: config.plugins,
},
};
config.env.test.presets[0][1].modules = 'auto';

module.exports = config;
4,332 changes: 3,530 additions & 802 deletions webapp/package-lock.json

Large diffs are not rendered by default.

64 changes: 62 additions & 2 deletions webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,37 @@
"devDependencies": {
"@babel/cli": "7.4.4",
"@babel/core": "7.4.5",
"@babel/plugin-proposal-class-properties": "7.4.4",
"@babel/plugin-proposal-class-properties": "^7.4.4",
"@babel/plugin-proposal-object-rest-spread": "7.5.5",
"@babel/plugin-syntax-dynamic-import": "7.2.0",
"@babel/polyfill": "7.4.4",
"@babel/preset-env": "7.4.5",
"@babel/preset-react": "7.0.0",
"@babel/preset-typescript": "^7.8.3",
"@babel/runtime": "7.4.5",
"@types/enzyme": "^3.10.5",
"@types/jest": "^25.1.2",
"babel-eslint": "10.0.2",
"babel-jest": "24.8.0",
"babel-loader": "8.0.6",
"babel-plugin-typescript-to-proptypes": "^1.2.1",
"compass-mixins": "0.12.10",
"css-loader": "3.1.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "1.14.0",
"enzyme-to-json": "3.3.5",
"eslint": "6.0.1",
"eslint-config-mattermost": "github:mattermost/eslint-config-mattermost",
"eslint-import-resolver-webpack": "0.11.1",
"eslint-plugin-header": "^3.0.0",
"eslint-plugin-import": "2.18.0",
"eslint-plugin-react": "7.14.2",
"file-loader": "4.0.0",
"jest": "^24.8.0",
"identity-obj-proxy": "3.0.0",
"jest": "^24.9.0",
"jest-canvas-mock": "2.1.0",
"jest-junit": "6.4.0",
"typescript": "^3.7.5",
"url-loader": "^3.0.0",
"webpack": "4.35.0",
"webpack-cli": "3.3.5"
Expand All @@ -40,6 +54,7 @@
"core-js": "3.6.4",
"js-cookie": "^2.2.1",
"mattermost-redux": "^5.18.0",
"mattermost-webapp": "github:mattermost/mattermost-webapp#23f5f93d9f12a7e2b5623e5cee6814366abd9a0f",
"prop-types": "15.7.2",
"react": "16.8.6",
"react-bootstrap": "^0.32.4",
Expand All @@ -48,5 +63,50 @@
"react-select": "^3.0.8",
"redux": "4.0.1",
"superagent": "^5.2.1"
},
"jest": {
"snapshotSerializers": [
"<rootDir>/node_modules/enzyme-to-json/serializer"
],
"testPathIgnorePatterns": [
"/node_modules/",
"/non_npm_dependencies/"
],
"clearMocks": true,
"collectCoverageFrom": [
"src/**/*.{js,jsx}"
],
"coverageReporters": [
"lcov",
"text-summary"
],
"moduleNameMapper": {
"^.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "identity-obj-proxy",
"^.+\\.(css|less|scss)$": "identity-obj-proxy",
"^.*i18n.*\\.(json)$": "<rootDir>/tests/i18n_mock.json",
"^bundle-loader\\?lazy\\!(.*)$": "$1"
},
"moduleDirectories": [
"",
"node_modules",
"non_npm_dependencies"
],
"reporters": [
"default",
"jest-junit"
],
"transformIgnorePatterns": [
"node_modules/(?!react-native|react-router|mattermost-webapp)"
],
"setupFiles": [
"jest-canvas-mock"
],
"setupFilesAfterEnv": [
"<rootDir>/tests/setup.js"
],
"testURL": "http://localhost:8065"
},
"jest-junit": {
"output": "build/test-results.xml"
}
}
6 changes: 5 additions & 1 deletion webapp/src/components/confluence_field.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ export default class ConfluenceField extends React.PureComponent {
removeValidation: PropTypes.func.isRequired,
theme: PropTypes.object,
fieldType: PropTypes.string.isRequired,
readOnly: PropTypes.bool.isRequired,
readOnly: PropTypes.bool,
};

static defaultProps = {
readOnly: false,
};

constructor(props) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`components/ChannelSettingsModal subscription modal snapshot test 1`] = `
<Modal
animation={true}
autoFocus={true}
backdrop="static"
bsClass="modal"
dialogComponentClass={[Function]}
enforceFocus={true}
keyboard={true}
manager={
ModalManager {
"add": [Function],
"containers": Array [],
"data": Array [],
"handleContainerOverflow": true,
"hideSiblingNodes": true,
"isTopModal": [Function],
"modals": Array [],
"remove": [Function],
}
}
onHide={[Function]}
renderBackdrop={[Function]}
restoreFocus={true}
show={true}
>
<ModalHeader
bsClass="modal-header"
closeButton={true}
closeLabel="Close"
>
<ModalTitle
bsClass="modal-title"
componentClass="h4"
>
Edit Your Confluence Subscription
</ModalTitle>
</ModalHeader>
<ModalBody
bsClass="modal-body"
componentClass="div"
>
<div>
<ConfluenceField
addValidation={[Function]}
fieldType="input"
label="Alias"
onChange={[Function]}
placeholder="Enter an alias for this subscription."
readOnly={false}
removeValidation={[Function]}
required={true}
type="text"
value=""
/>
<ConfluenceField
addValidation={[Function]}
fieldType="input"
label="Confluence Base URL"
onChange={[Function]}
placeholder="Enter the Confluence Base URL."
readOnly={false}
removeValidation={[Function]}
required={true}
type="text"
value=""
/>
<ConfluenceField
addValidation={[Function]}
fieldType="input"
label="Space Key"
onChange={[Function]}
placeholder="Enter the Confluence Space Key."
readOnly={false}
removeValidation={[Function]}
required={true}
type="text"
value=""
/>
<ConfluenceField
addValidation={[Function]}
fieldType="dropDown"
isMulti={true}
label="Events"
name="events"
onChange={[Function]}
options={
Array [
Object {
"label": "Comment Create",
"value": "comment_created",
},
Object {
"label": "Comment Update",
"value": "comment_updated",
},
Object {
"label": "Comment Remove",
"value": "comment_removed",
},
Object {
"label": "Page Create",
"value": "page_created",
},
Object {
"label": "Page Update",
"value": "page_updated",
},
Object {
"label": "Page Trash",
"value": "page_trashed",
},
Object {
"label": "Page Restore",
"value": "page_restored",
},
Object {
"label": "Page Remove",
"value": "page_removed",
},
]
}
readOnly={false}
removeValidation={[Function]}
required={false}
theme={Object {}}
value={
Array [
Object {
"label": "Comment Create",
"value": "comment_created",
},
Object {
"label": "Comment Update",
"value": "comment_updated",
},
Object {
"label": "Comment Remove",
"value": "comment_removed",
},
Object {
"label": "Page Create",
"value": "page_created",
},
Object {
"label": "Page Update",
"value": "page_updated",
},
Object {
"label": "Page Trash",
"value": "page_trashed",
},
Object {
"label": "Page Restore",
"value": "page_restored",
},
Object {
"label": "Page Remove",
"value": "page_removed",
},
]
}
/>
</div>
</ModalBody>
<ModalFooter
bsClass="modal-footer"
componentClass="div"
>
<Button
active={false}
block={false}
bsClass="btn"
bsStyle="link"
disabled={false}
onClick={[Function]}
type="button"
>
Cancel
</Button>
<Button
active={false}
block={false}
bsClass="btn"
bsStyle="primary"
disabled={false}
onClick={[Function]}
type="submit"
>
Save Subscription
</Button>
</ModalFooter>
</Modal>
`;
Loading

0 comments on commit 6435ef5

Please sign in to comment.