Skip to content

Commit 876bf07

Browse files
committed
chore: react update
1 parent b52bb44 commit 876bf07

File tree

9 files changed

+1749
-426
lines changed

9 files changed

+1749
-426
lines changed

package-lock.json

Lines changed: 1712 additions & 404 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,16 @@
2121
],
2222
"dependencies": {
2323
"@stomp/stompjs": "^5.4.2",
24-
"har-validator": "^5.1.3",
25-
"html-loader": "^0.5.5",
2624
"html-webpack-plugin": "^3.2.0",
27-
"html-webpack-template": "^6.2.0",
2825
"immutable": "^3.8.2",
29-
"node-sass": "^4.12.0",
3026
"prop-types": "^15.7.2",
31-
"react-dom": "^15.6.2",
3227
"react-immutable-proptypes": "^2.1.0",
3328
"react-markdown": "^4.2.2",
3429
"react-redux": "^5.1.1",
3530
"redux": "^3.7.2",
3631
"socket.io": "^2.2.0",
3732
"socket.io-client": "^2.2.0",
38-
"sockjs-client": "^1.4.0",
39-
"uniqueid": "^1.0.0",
40-
"websocket": "^1.0.29"
33+
"sockjs-client": "^1.4.0"
4134
},
4235
"devDependencies": {
4336
"@commitlint/cli": "^8.2.0",
@@ -54,7 +47,8 @@
5447
"babel-preset-stage-0": "^6.24.1",
5548
"clean-webpack-plugin": "^0.1.19",
5649
"css-loader": "^0.28.11",
57-
"enzyme": "^2.9.1",
50+
"enzyme": "^3.10.0",
51+
"enzyme-adapter-react-16": "^1.15.1",
5852
"eslint": "^4.18.2",
5953
"eslint-config-airbnb": "^14.1.0",
6054
"eslint-config-prettier": "^1.6.0",
@@ -66,10 +60,11 @@
6660
"eslint-plugin-react": "^6.10.3",
6761
"husky": "^3.0.7",
6862
"jest": "^20.0.4",
63+
"node-sass": "^4.12.0",
6964
"prettier": "^1.18.2",
7065
"prettier-eslint": "^5.1.0",
71-
"react": "^15.6.2",
72-
"react-test-renderer": "^15.6.2",
66+
"react": "^16.12.0",
67+
"react-dom": "^16.12.0",
7368
"redux-mock-store": "^1.5.3",
7469
"sass-loader": "^6.0.7",
7570
"standard-version": "^7.0.0",
@@ -80,14 +75,15 @@
8075
"webpack-dev-server": "^3.8.0"
8176
},
8277
"peerDependencies": {
83-
"react": "^15.6.1"
78+
"react": "16.x"
8479
},
8580
"jest": {
8681
"verbose": true,
8782
"moduleNameMapper": {
8883
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/mocks/fileMock.js",
8984
"\\.(css|scss)$": "<rootDir>/mocks/styleMock.js"
90-
}
85+
},
86+
"setupTestFrameworkScriptFile": "<rootDir>/test-setup.js"
9187
},
9288
"husky": {
9389
"hooks": {

src/components/Widget/components/Conversation/components/Messages/components/Message/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ class Message extends PureComponent {
4444

4545
Message.propTypes = {
4646
message: PROP_TYPES.MESSAGE,
47-
docViewer: PropTypes.bool.isRequired
47+
docViewer: PropTypes.bool
48+
};
49+
50+
Message.defaultTypes = {
51+
docViewer: false
4852
};
4953

5054
const mapStateToProps = state => ({

src/components/Widget/components/Conversation/components/Messages/components/QuickReply/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class QuickReply extends PureComponent {
5555
<div className="quickReplies-container">
5656
<Message message={message} />
5757
{isLast && (
58-
<div className="replies">
58+
<div className="replies">
5959
{message.get('quick_replies').map((reply, index) => {
6060
if (reply.type === 'web_url') {
6161
return (
@@ -108,7 +108,7 @@ const mapDispatchToProps = dispatch => ({
108108
QuickReply.propTypes = {
109109
getChosenReply: PropTypes.func,
110110
chooseReply: PropTypes.func,
111-
id: PropTypes.string,
111+
id: PropTypes.number,
112112
isLast: PropTypes.bool,
113113
message: PROP_TYPES.QUICK_REPLY
114114
};

src/components/Widget/components/Conversation/components/Messages/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ const formatDate = (date) => {
2323

2424
const scrollToBottom = () => {
2525
const messagesDiv = document.getElementById('messages');
26-
messagesDiv.scrollTop = messagesDiv.scrollHeight;
26+
if (messagesDiv) {
27+
messagesDiv.scrollTop = messagesDiv.scrollHeight;
28+
}
2729
};
2830

2931
class Messages extends Component {
@@ -158,7 +160,11 @@ Messages.propTypes = {
158160
profileAvatar: PropTypes.string,
159161
customComponent: PropTypes.func,
160162
showMessageDate: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
161-
displayTypingIndication: PropTypes.bool.isRequired
163+
displayTypingIndication: PropTypes.bool
164+
};
165+
166+
Message.defaultTypes = {
167+
displayTypingIndication: false
162168
};
163169

164170
export default connect(store => ({

src/components/Widget/components/Conversation/components/Messages/test/index.test.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import QuickReply from '../components/QuickReply';
2020
import Snippet from '../components/Snippet';
2121

2222
describe('<Messages />', () => {
23-
2423
const RealDate = Date;
2524

2625
const mockDate = (isoDate) => {
@@ -135,7 +134,7 @@ describe('<Messages />', () => {
135134
const renderedComponent = createComponent(true, messageToRender);
136135
const date = renderedComponent.find('.message-date');
137136
expect(date).toHaveLength(1);
138-
expect(date.text()).toEqual(today.toLocaleTimeString());
137+
expect(date.text()).toEqual(today.toLocaleTimeString('en-US', { timeStyle: 'short' }));
139138
});
140139

141140
it('should render date and time', () => {
@@ -146,7 +145,7 @@ describe('<Messages />', () => {
146145
const renderedComponent = createComponent(true, messageToRender);
147146
const date = renderedComponent.find('.message-date');
148147
expect(date).toHaveLength(1);
149-
expect(date.text()).toEqual(`${twoDaysAgo.toLocaleDateString()} ${twoDaysAgo.toLocaleTimeString()}`);
148+
expect(date.text()).toEqual(`${twoDaysAgo.toLocaleDateString()} ${twoDaysAgo.toLocaleTimeString('en-US', { timeStyle: 'short' })}`);
150149
});
151150

152151
it('should render custom date', () => {

src/components/Widget/test/index.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ describe('<Widget />', () => {
2323
handleNewUserMessage={handleUserMessage}
2424
profileAvatar={profile}
2525
dispatch={dispatch}
26+
customMessageDelay={() => {}}
27+
tooltipSent
28+
tooltipDelay={0}
29+
socket={{
30+
isInitialized: () => true
31+
}}
2632
/>
2733
);
2834

src/store/reducers/helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export function storeLocalSession(storage, key, sid) {
108108
const cachedSession = storage.getItem(key);
109109
let session;
110110
if (cachedSession) {
111-
// Found exisiting session in storage
111+
// Found exisiting session in storage
112112
const parsedSession = JSON.parse(cachedSession);
113113
session = {
114114
...parsedSession,

test-setup.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import Enzyme from 'enzyme';
2+
import Adapter from 'enzyme-adapter-react-16';
3+
4+
Enzyme.configure({ adapter: new Adapter() });

0 commit comments

Comments
 (0)