feat: Conversation transcript in widget (#2549)

This commit is contained in:
Muhsin Keloth
2021-07-13 11:31:21 +05:30
committed by GitHub
parent fc4ef1595b
commit 15085cfb98
13 changed files with 200 additions and 46 deletions

View File

@@ -0,0 +1,38 @@
import { API } from 'widget/helpers/axios';
import { actions } from '../../message';
const commit = jest.fn();
jest.mock('widget/helpers/axios');
describe('#actions', () => {
describe('#update', () => {
it('sends correct actions', async () => {
const user = {
email: 'john@acme.inc',
messageId: 10,
submittedValues: {
email: 'john@acme.inc',
},
};
API.patch.mockResolvedValue({
data: { contact: { pubsub_token: '8npuMUfDgizrwVoqcK1t7FMY' } },
});
await actions.update({ commit }, user);
expect(commit.mock.calls).toEqual([
['toggleUpdateStatus', true],
[
'conversation/updateMessage',
{
id: 10,
content_attributes: {
submitted_email: 'john@acme.inc',
submitted_values: null,
},
},
{ root: true },
],
['toggleUpdateStatus', false],
]);
});
});
});

View File

@@ -0,0 +1,14 @@
import { getters } from '../../message';
describe('#getters', () => {
it('getUIFlags', () => {
const state = {
uiFlags: {
isUpdating: false,
},
};
expect(getters.getUIFlags(state)).toEqual({
isUpdating: false,
});
});
});

View File

@@ -0,0 +1,11 @@
import { mutations } from '../../message';
describe('#mutations', () => {
describe('#toggleUpdateStatus', () => {
it('set update flags', () => {
const state = { uiFlags: { status: '' } };
mutations.toggleUpdateStatus(state, 'sent');
expect(state.uiFlags.isUpdating).toEqual('sent');
});
});
});