fix: Retry message not working if the conversation has an external issue (#8529)
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import axios from 'axios';
|
||||
import actions from '../../conversations/actions';
|
||||
import actions, {
|
||||
hasMessageFailedWithExternalError,
|
||||
} from '../../conversations/actions';
|
||||
import types from '../../../mutation-types';
|
||||
const dataToSend = {
|
||||
payload: [
|
||||
@@ -18,6 +20,41 @@ const dispatch = jest.fn();
|
||||
global.axios = axios;
|
||||
jest.mock('axios');
|
||||
|
||||
describe('#hasMessageFailedWithExternalError', () => {
|
||||
it('returns false if message is sent', () => {
|
||||
const pendingMessage = {
|
||||
status: 'sent',
|
||||
content_attributes: {},
|
||||
};
|
||||
expect(hasMessageFailedWithExternalError(pendingMessage)).toBe(false);
|
||||
});
|
||||
it('returns false if status is not failed', () => {
|
||||
const pendingMessage = {
|
||||
status: 'progress',
|
||||
content_attributes: {},
|
||||
};
|
||||
expect(hasMessageFailedWithExternalError(pendingMessage)).toBe(false);
|
||||
});
|
||||
|
||||
it('returns false if status is failed but no external error', () => {
|
||||
const pendingMessage = {
|
||||
status: 'failed',
|
||||
content_attributes: {},
|
||||
};
|
||||
expect(hasMessageFailedWithExternalError(pendingMessage)).toBe(false);
|
||||
});
|
||||
|
||||
it('returns true if status is failed and has external error', () => {
|
||||
const pendingMessage = {
|
||||
status: 'failed',
|
||||
content_attributes: {
|
||||
external_error: 'error',
|
||||
},
|
||||
};
|
||||
expect(hasMessageFailedWithExternalError(pendingMessage)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#actions', () => {
|
||||
describe('#getConversation', () => {
|
||||
it('sends correct actions if API is success', async () => {
|
||||
|
||||
Reference in New Issue
Block a user