feat(channels): add Shangwutong connector
This commit is contained in:
@@ -310,11 +310,9 @@ const actions = {
|
||||
: await MessageApi.create(pendingMessage);
|
||||
commit(types.ADD_MESSAGE, {
|
||||
...response.data,
|
||||
status: MESSAGE_STATUS.SENT,
|
||||
});
|
||||
commit(types.ADD_CONVERSATION_ATTACHMENTS, {
|
||||
...response.data,
|
||||
status: MESSAGE_STATUS.SENT,
|
||||
});
|
||||
} catch (error) {
|
||||
const errorMessage = error.response
|
||||
|
||||
@@ -290,6 +290,39 @@ describe('#actions', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#sendMessageWithData', () => {
|
||||
it('keeps the status returned by the server', async () => {
|
||||
const localCommit = vi.fn();
|
||||
const pendingMessage = {
|
||||
id: 'echo-1',
|
||||
conversation_id: 7,
|
||||
message: 'hello',
|
||||
status: 'progress',
|
||||
content_attributes: {},
|
||||
};
|
||||
const responseMessage = {
|
||||
id: 42,
|
||||
conversation_id: 7,
|
||||
content: 'hello',
|
||||
status: 'progress',
|
||||
};
|
||||
axios.mockResolvedValue({ data: responseMessage });
|
||||
|
||||
await actions.sendMessageWithData({ commit: localCommit }, pendingMessage);
|
||||
|
||||
expect(localCommit).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
types.ADD_MESSAGE,
|
||||
responseMessage
|
||||
);
|
||||
expect(localCommit).toHaveBeenNthCalledWith(
|
||||
3,
|
||||
types.ADD_CONVERSATION_ATTACHMENTS,
|
||||
responseMessage
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#markMessagesRead', () => {
|
||||
beforeEach(() => {
|
||||
vi.useFakeTimers();
|
||||
|
||||
Reference in New Issue
Block a user