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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 142 additions and 38 deletions

View file

@ -1,6 +1,7 @@
export default [
{
id: 1,
trigger_only_during_business_hours: false,
trigger_rules: {
time_on_page: 3,
url: 'https://www.chatwoot.com/pricing',
@ -8,6 +9,7 @@ export default [
},
{
id: 2,
trigger_only_during_business_hours: false,
trigger_rules: {
time_on_page: 6,
url: 'https://www.chatwoot.com/about',

View file

@ -3,8 +3,12 @@ import {
formatCampaigns,
filterCampaigns,
} from '../campaignHelper';
import campaigns from './camapginFixtures';
describe('#Campagin Helper', () => {
import campaigns from './campaignFixtures';
global.chatwootWebChannel = {
workingHoursEnabled: false,
};
describe('#Campaigns Helper', () => {
describe('stripTrailingSlash', () => {
it('should return striped trailing slash if url with trailing slash is passed', () => {
expect(
@ -14,15 +18,17 @@ describe('#Campagin Helper', () => {
});
describe('formatCampaigns', () => {
it('should return formated campaigns if camapgins are passed', () => {
it('should return formatted campaigns if campaigns are passed', () => {
expect(formatCampaigns({ campaigns })).toStrictEqual([
{
id: 1,
timeOnPage: 3,
triggerOnlyDuringBusinessHours: false,
url: 'https://www.chatwoot.com/pricing',
},
{
id: 2,
triggerOnlyDuringBusinessHours: false,
timeOnPage: 6,
url: 'https://www.chatwoot.com/about',
},
@ -30,7 +36,7 @@ describe('#Campagin Helper', () => {
});
});
describe('filterCampaigns', () => {
it('should return filtered campaigns if formatted camapgins are passed', () => {
it('should return filtered campaigns if formatted campaigns are passed', () => {
expect(
filterCampaigns({
campaigns: [