feat: Show pre-chat form before triggering the campaign (#3215)
This commit is contained in:
@@ -94,14 +94,28 @@ describe('#actions', () => {
|
||||
it('reset campaign if campaign id is not present in the campaign list', async () => {
|
||||
API.get.mockResolvedValue({ data: campaigns });
|
||||
await actions.startCampaign(
|
||||
{ dispatch, getters: { getCampaigns: campaigns }, commit },
|
||||
{
|
||||
dispatch,
|
||||
getters: { getCampaigns: campaigns },
|
||||
commit,
|
||||
rootState: {
|
||||
events: { isOpen: true },
|
||||
},
|
||||
},
|
||||
{ campaignId: 32 }
|
||||
);
|
||||
});
|
||||
it('start campaign if campaign id passed', async () => {
|
||||
API.get.mockResolvedValue({ data: campaigns });
|
||||
await actions.startCampaign(
|
||||
{ dispatch, getters: { getCampaigns: campaigns }, commit },
|
||||
{
|
||||
dispatch,
|
||||
getters: { getCampaigns: campaigns },
|
||||
commit,
|
||||
rootState: {
|
||||
events: { isOpen: false },
|
||||
},
|
||||
},
|
||||
{ campaignId: 1 }
|
||||
);
|
||||
expect(commit.mock.calls).toEqual([['setActiveCampaign', campaigns[0]]]);
|
||||
@@ -112,7 +126,10 @@ describe('#actions', () => {
|
||||
const params = { campaignId: 12, websiteToken: 'XDsafmADasd' };
|
||||
API.post.mockResolvedValue({});
|
||||
await actions.executeCampaign({ commit }, params);
|
||||
expect(commit.mock.calls).toEqual([['setActiveCampaign', {}]]);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
['setCampaignExecuted'],
|
||||
['setActiveCampaign', {}],
|
||||
]);
|
||||
});
|
||||
it('sends correct actions if execute campaign API is failed', async () => {
|
||||
const params = { campaignId: 12, websiteToken: 'XDsafmADasd' };
|
||||
@@ -121,4 +138,12 @@ describe('#actions', () => {
|
||||
expect(commit.mock.calls).toEqual([['setError', true]]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#resetCampaign', () => {
|
||||
it('sends correct actions if execute campaign API is success', async () => {
|
||||
API.post.mockResolvedValue({});
|
||||
await actions.resetCampaign({ commit });
|
||||
expect(commit.mock.calls).toEqual([['setActiveCampaign', {}]]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -129,4 +129,17 @@ describe('#getters', () => {
|
||||
updated_at: '2021-05-03T04:53:36.354Z',
|
||||
});
|
||||
});
|
||||
it('getCampaignHasExecuted', () => {
|
||||
const state = {
|
||||
records: [],
|
||||
uiFlags: {
|
||||
isError: false,
|
||||
hasFetched: false,
|
||||
},
|
||||
activeCampaign: {},
|
||||
campaignHasExecuted: false,
|
||||
};
|
||||
|
||||
expect(getters.getCampaignHasExecuted(state)).toEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -33,4 +33,12 @@ describe('#mutations', () => {
|
||||
expect(state.activeCampaign).toEqual(campaigns[0]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#setCampaignExecuted', () => {
|
||||
it('set campaign executed flag', () => {
|
||||
const state = { records: [], uiFlags: {}, campaignHasExecuted: false };
|
||||
mutations.setCampaignExecuted(state);
|
||||
expect(state.campaignHasExecuted).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user