mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 12:08:01 +00:00
Feature: Typing Indicator on widget and dashboard (#811)
* Adds typing indicator for widget * typing indicator for agents in dashboard Co-authored-by: Pranav Raj Sreepuram <pranavrajs@gmail.com>
This commit is contained in:
committed by
GitHub
parent
fabc3170b7
commit
5bc8219db5
@@ -0,0 +1,36 @@
|
||||
import { actions } from '../../conversationTypingStatus';
|
||||
import * as types from '../../../mutation-types';
|
||||
|
||||
const commit = jest.fn();
|
||||
|
||||
describe('#actions', () => {
|
||||
describe('#create', () => {
|
||||
it('sends correct actions', () => {
|
||||
actions.create(
|
||||
{ commit },
|
||||
{ conversationId: 1, user: { id: 1, name: 'user-1' } }
|
||||
);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[
|
||||
types.default.ADD_USER_TYPING_TO_CONVERSATION,
|
||||
{ conversationId: 1, user: { id: 1, name: 'user-1' } },
|
||||
],
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#destroy', () => {
|
||||
it('sends correct actions', () => {
|
||||
actions.destroy(
|
||||
{ commit },
|
||||
{ conversationId: 1, user: { id: 1, name: 'user-1' } }
|
||||
);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[
|
||||
types.default.REMOVE_USER_TYPING_FROM_CONVERSATION,
|
||||
{ conversationId: 1, user: { id: 1, name: 'user-1' } },
|
||||
],
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
import { getters } from '../../conversationTypingStatus';
|
||||
|
||||
describe('#getters', () => {
|
||||
it('getUserList', () => {
|
||||
const state = {
|
||||
records: {
|
||||
1: [
|
||||
{ id: 1, name: 'user-1' },
|
||||
{ id: 2, name: 'user-2' },
|
||||
],
|
||||
},
|
||||
};
|
||||
expect(getters.getUserList(state)(1)).toEqual([
|
||||
{ id: 1, name: 'user-1' },
|
||||
{ id: 2, name: 'user-2' },
|
||||
]);
|
||||
expect(getters.getUserList(state)(2)).toEqual([]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,67 @@
|
||||
import * as types from '../../../mutation-types';
|
||||
import { mutations } from '../../conversationTypingStatus';
|
||||
|
||||
describe('#mutations', () => {
|
||||
describe('#ADD_USER_TYPING_TO_CONVERSATION', () => {
|
||||
it('add user to state', () => {
|
||||
const state = { records: {} };
|
||||
mutations[types.default.ADD_USER_TYPING_TO_CONVERSATION](state, {
|
||||
conversationId: 1,
|
||||
user: { id: 1, type: 'contact', name: 'user-1' },
|
||||
});
|
||||
expect(state.records).toEqual({
|
||||
1: [{ id: 1, type: 'contact', name: 'user-1' }],
|
||||
});
|
||||
});
|
||||
|
||||
it('doesnot add user if user already exist', () => {
|
||||
const state = {
|
||||
records: {
|
||||
1: [{ id: 1, type: 'contact', name: 'user-1' }],
|
||||
},
|
||||
};
|
||||
mutations[types.default.ADD_USER_TYPING_TO_CONVERSATION](state, {
|
||||
conversationId: 1,
|
||||
user: { id: 1, type: 'contact', name: 'user-1' },
|
||||
});
|
||||
expect(state.records).toEqual({
|
||||
1: [{ id: 1, type: 'contact', name: 'user-1' }],
|
||||
});
|
||||
});
|
||||
|
||||
it('add user to state if no matching user profiles are seen', () => {
|
||||
const state = {
|
||||
records: {
|
||||
1: [{ id: 1, type: 'user', name: 'user-1' }],
|
||||
},
|
||||
};
|
||||
mutations[types.default.ADD_USER_TYPING_TO_CONVERSATION](state, {
|
||||
conversationId: 1,
|
||||
user: { id: 1, type: 'contact', name: 'user-1' },
|
||||
});
|
||||
expect(state.records).toEqual({
|
||||
1: [
|
||||
{ id: 1, type: 'user', name: 'user-1' },
|
||||
{ id: 1, type: 'contact', name: 'user-1' },
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#REMOVE_USER_TYPING_FROM_CONVERSATION', () => {
|
||||
it('remove add user if user exist', () => {
|
||||
const state = {
|
||||
records: {
|
||||
1: [{ id: 1, type: 'contact', name: 'user-1' }],
|
||||
},
|
||||
};
|
||||
mutations[types.default.REMOVE_USER_TYPING_FROM_CONVERSATION](state, {
|
||||
conversationId: 1,
|
||||
user: { id: 1, type: 'contact', name: 'user-1' },
|
||||
});
|
||||
expect(state.records).toEqual({
|
||||
1: [],
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user