Skip to content
Open
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
bb4001c
I have made a simple interface to test backend functionality
songa1 Feb 24, 2021
10604b2
I have made actions and reducers to fetch users to chat with. And I a…
songa1 Feb 25, 2021
a2041c3
I can now get a list of all users and get a list of all messages
songa1 Feb 27, 2021
fd6fce5
I can now read messages and read message for each user
songa1 Feb 28, 2021
1f4fb0f
a visitor can now send a message to support team
songa1 Mar 2, 2021
18c7ead
a visitor can now add a new message and the message can be received b…
songa1 Mar 2, 2021
1d07fcd
I have accepted changes from remote develop
songa1 Mar 3, 2021
e8668c5
The visitor can chat with support in real time environment and the me…
songa1 Mar 3, 2021
521f727
Most of my features are done, I only have to do tests.
songa1 Mar 6, 2021
5314cf2
Merge branch 'develop' of https://github.com/atlp-rwanda/c4-barefoot-…
songa1 Mar 6, 2021
730c0c1
Modified package lock
songa1 Mar 6, 2021
971320b
Commit to receive new changes
songa1 Mar 8, 2021
f4c21ab
Merge branch 'develop' of https://github.com/atlp-rwanda/c4-barefoot-…
songa1 Mar 8, 2021
5868a99
Accepting changes
songa1 Mar 8, 2021
638c6ca
Accepted changes from develop
songa1 Mar 8, 2021
c8c15ca
Accepted changes from develop
songa1 Mar 8, 2021
4488453
added missing package
songa1 Mar 8, 2021
fb09a92
Saving to move to new branch
songa1 Mar 8, 2021
2224086
I have added a test that renders <ChatRoom/> without any errors.
songa1 Mar 10, 2021
5209a7f
Worked on two actions tests not passing
songa1 Mar 10, 2021
8c67944
I have started working on testing, and started with chatActions I hav…
songa1 Mar 10, 2021
793b783
Initial commit after cloning
songa1 Mar 10, 2021
b2b6f50
I have fixed a test which wasn't running
songa1 Mar 10, 2021
14604ed
Merge branch 'develop' into ft-chat-feature
songa1 Mar 11, 2021
5cb5ded
All tests for Chat Actions and Chat Reducer are passing
songa1 Mar 12, 2021
972cdb0
Merge branch 'ft-chat-feature' of https://github.com/atlp-rwanda/c4-b…
songa1 Mar 12, 2021
51afd10
Merge branch 'develop' of https://github.com/atlp-rwanda/c4-barefoot-…
songa1 Mar 12, 2021
4983b6d
Merge branch 'develop' into ft-chat-feature
songa1 Mar 12, 2021
6fbc5b9
I am trying to upload image
songa1 Mar 16, 2021
e21db2d
I can now upload photos in messages
songa1 Mar 17, 2021
7032102
New message form control not defined
songa1 Mar 17, 2021
8a8a2ab
Clearing input field after message is sent by visitor
songa1 Mar 17, 2021
514fcf7
Fixed freezing issue, and changed component to send a new message to …
songa1 Mar 21, 2021
20c57c7
I have made all data available in real time
songa1 Mar 22, 2021
74ce7db
Sending a message to every point is working, I only have getting mess…
songa1 Mar 22, 2021
b753d5a
Started using sockets
songa1 Mar 23, 2021
86c910c
I have tried to add web sockets
songa1 Mar 25, 2021
c947818
Tried to use web sockets
songa1 Mar 25, 2021
0ccdbdc
I was trying to connect to backend with web sockets
songa1 Mar 26, 2021
20e6cd9
I edited the variable that I use to pass data to console from sockets
songa1 Mar 26, 2021
c6ed314
implementing web sockets
songa1 Mar 27, 2021
2fca4ff
I have added loaders while pending
songa1 Mar 27, 2021
cfc9247
I'm handling errors
songa1 Mar 27, 2021
3e90078
Solved conflicts
songa1 Mar 27, 2021
21a0748
Ft update profile page (#14)
edgar929 Mar 28, 2021
6b2ab25
created custom socket connection file
songa1 Mar 29, 2021
36bf0f4
Received new changes from remote develop
songa1 Mar 31, 2021
b120142
Received new changes from remote develop
songa1 Mar 31, 2021
df31d3f
Merge branch 'ft-chat-feature' of https://github.com/atlp-rwanda/c4-b…
songa1 Apr 2, 2021
8ca59e4
Merged changes from develop
songa1 Apr 2, 2021
43e7ea9
I have merged with changes from develop branch
songa1 Apr 3, 2021
3a89a52
Accepting changes from develop
songa1 Apr 4, 2021
e9ea4c8
I have added last message
songa1 Apr 4, 2021
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
233 changes: 233 additions & 0 deletions __tests__/actions/ChatAction.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
import configureStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import * as actions from '../../src/redux/actions/ChatAction';
import { chattedUsers, allUsers, vList, messageList, supportReply } from '../../dummyData'
import moxios from 'moxios';


const middlewares = [thunk]
const mockStore = configureStore(middlewares);

describe('testing fetchUsersChat', () => {
let store;
beforeEach(() => {
moxios.install()
store = mockStore({fetchUsersChat: {}})
})
afterEach(() => moxios.uninstall())

it('it should fetch chatted users successfully', () => {
moxios.wait(() => {
const request = moxios.requests.mostRecent()
request.respondWith({
status: 200,
response: {
users: {
rows: chattedUsers
}
}
})
})
return store.dispatch(actions.fetchUsersChat()).then(() => {
const expectedActions = store.getActions();
expect(expectedActions[0].type).toEqual('CHATTED_USERS')
})
})

})

describe('testing getVisitorsList', () => {
let store;
beforeEach(() => {
moxios.install()
store = mockStore({getVisitorsList: {}})
})
afterEach(() => moxios.uninstall())

it('should get a list of visitors', () => {
moxios.wait(() => {
const request = moxios.requests.mostRecent()
request.respondWith({
status: 200,
response: {
visitors: {
rows: vList
}
}
})
})
return store.dispatch(actions.getVisitorsList()).then(() => {
const expectedActions = store.getActions();
expect(expectedActions[0].type).toEqual('GET_VISITORS')
})
})
})


describe('test getting all users', () => {
let store;
beforeEach(() => {
moxios.install()
store = mockStore({fetchUsers: {}})
})
afterEach(() => moxios.uninstall())

it('should get a list of all users', () => {
moxios.wait(() => {
const request = moxios.requests.mostRecent()
request.respondWith({
status: 200,
response: {
allusers: {
rows: allUsers
}
}
})
})
return store.dispatch(actions.fetchUsers()).then(() => {
const expectedActions = store.getActions();
expect(expectedActions[0].type).toEqual('ALL_USERS')
})
})


})


describe('test getting all messages between two users', () => {
let store;
beforeEach(() => {
moxios.install()
store = mockStore({getChats: {}})
})
afterEach(() => moxios.uninstall())

it('should get all messages between users', () => {
moxios.wait(() => {
const request = moxios.requests.mostRecent()
request.respondWith({
status: 200,
response: {
messages: messageList
}
})
})
return store.dispatch(actions.getChats()).then(() => {
const expectedActions = store.getActions();
expect(expectedActions[0].type).toEqual('GETALL_CHATS')
})
})
})

describe('visitors get support message', () => {
let store;
beforeEach(() => {
moxios.install()
store = mockStore({getSupportResponse: {}})
})
afterEach(() => moxios.uninstall())

it('should getSupportResponse', () => {
moxios.wait(() => {
const request = moxios.requests.mostRecent()
request.respondWith({
status: 200,
response: {
support: supportReply
}
})
})
return store.dispatch(actions.getSupportResponse()).then(() => {
const expectedActions = store.getActions();
expect(expectedActions[0].type).toEqual('GETSUPPORT_RESPONSE')
})
})
})

describe('should return NEW_MESSAGE', () => {
let store;
beforeEach(() => {
moxios.install()
store = mockStore({newMessageAction: {}})
})
afterEach(() => moxios.uninstall())

it('should return NEW_MESSAGE', () => {
moxios.wait(() => {
const request = moxios.requests.mostRecent()
request.respondWith({
status: 200
})
})
return store.dispatch(actions.newMessageAction()).then(() => {
const expectedActions = store.getActions();
expect(expectedActions[0].type).toEqual('NEW_MESSAGE')
})
})
})

describe('should return VISITOR_MESSAGE', () => {
let store;
beforeEach(() => {
moxios.install()
store = mockStore({visitorsMessage: {}})
})
afterEach(() => moxios.uninstall())

it('should return VISITOR_MESSAGE', () => {
moxios.wait(() => {
const request = moxios.requests.mostRecent()
request.respondWith({
status: 200
})
})
return store.dispatch(actions.visitorsMessage()).then(() => {
const expectedActions = store.getActions();
expect(expectedActions[0].type).toEqual('VISITOR_MESSAGE')
})
})
})

describe('should return NEW_MESSAGE', () => {
let store;
beforeEach(() => {
moxios.install()
store = mockStore({newMessageAction: {}})
})
afterEach(() => moxios.uninstall())

it('should return NEW_MESSAGE', () => {
moxios.wait(() => {
const request = moxios.requests.mostRecent()
request.respondWith({
status: 200
})
})
return store.dispatch(actions.newMessageAction()).then(() => {
const expectedActions = store.getActions();
expect(expectedActions[0].type).toEqual('NEW_MESSAGE')
})
})
})

describe('should return SUPPORT_RESPONDS', () => {
let store;
beforeEach(() => {
moxios.install()
store = mockStore({supportResponds: {}})
})
afterEach(() => moxios.uninstall())

it('should return SUPPORT_RESPONDS', () => {
moxios.wait(() => {
const request = moxios.requests.mostRecent()
request.respondWith({
status: 200
})
})
return store.dispatch(actions.supportResponds()).then(() => {
const expectedActions = store.getActions();
expect(expectedActions[0].type).toEqual('SUPPORT_RESPONDS')
})
})
})
12 changes: 12 additions & 0 deletions __tests__/components/Chat.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import ChatRoom from '../../src/components/Chat/ChatRoom';
import { shallow, mount } from 'enzyme';
import { expect } from 'chai';
import { Grid } from '@material-ui/core'

describe('<ChatRoom /> tests', () => {
it('Should render ChatRoom component without any errors', () => {
const wrapper = shallow(<ChatRoom ><Grid/></ChatRoom>);
expect(wrapper.find(<Grid></Grid>)).to.have.lengthOf(0);
})
})
Loading