fix: Trigger campaigns only during business hours (#3085)

Fixes #2433
This commit is contained in:
Muhsin Keloth
2021-10-12 17:58:33 +05:30
committed by GitHub
parent 7c21cf2255
commit 6bfa551c85
16 changed files with 142 additions and 38 deletions

View File

@@ -15,7 +15,11 @@ describe('#actions', () => {
API.get.mockResolvedValue({ data: campaigns });
await actions.fetchCampaigns(
{ commit },
{ websiteToken: 'XDsafmADasd', currentURL: 'https://chatwoot.com' }
{
websiteToken: 'XDsafmADasd',
currentURL: 'https://chatwoot.com',
isInBusinessHours: true,
}
);
expect(commit.mock.calls).toEqual([
['setCampaigns', campaigns],
@@ -25,7 +29,12 @@ describe('#actions', () => {
expect(campaignTimer.initTimers).toHaveBeenCalledWith(
{
campaigns: [
{ id: 11, timeOnPage: '20', url: 'https://chatwoot.com' },
{
id: 11,
timeOnPage: '20',
url: 'https://chatwoot.com',
triggerOnlyDuringBusinessHours: false,
},
],
},
'XDsafmADasd'
@@ -35,7 +44,11 @@ describe('#actions', () => {
API.get.mockRejectedValue({ message: 'Authentication required' });
await actions.fetchCampaigns(
{ commit },
{ websiteToken: 'XDsafmADasd', currentURL: 'https://www.chatwoot.com' }
{
websiteToken: 'XDsafmADasd',
currentURL: 'https://www.chatwoot.com',
isInBusinessHours: true,
}
);
expect(commit.mock.calls).toEqual([
['setError', true],
@@ -65,7 +78,12 @@ describe('#actions', () => {
expect(campaignTimer.initTimers).toHaveBeenCalledWith(
{
campaigns: [
{ id: 11, timeOnPage: '20', url: 'https://chatwoot.com' },
{
id: 11,
timeOnPage: '20',
url: 'https://chatwoot.com',
triggerOnlyDuringBusinessHours: false,
},
],
},
'XDsafmADasd'