feat: Dedicated tab for campaigns (#2741)
This commit is contained in:
parent
8daf1fe033
commit
4d668d8db3
22 changed files with 477 additions and 505 deletions
|
@ -1,13 +1,10 @@
|
|||
import { CAMPAIGN_TYPES } from '../constants/campaign';
|
||||
import inboxMixin from './inboxMixin';
|
||||
export default {
|
||||
mixins: [inboxMixin],
|
||||
computed: {
|
||||
campaignType() {
|
||||
if (this.isAWebWidgetInbox) {
|
||||
return CAMPAIGN_TYPES.ONGOING;
|
||||
}
|
||||
return CAMPAIGN_TYPES.ONE_OFF;
|
||||
const pageURL = window.location.href;
|
||||
const type = pageURL.substr(pageURL.lastIndexOf('/') + 1);
|
||||
return type;
|
||||
},
|
||||
isOngoingType() {
|
||||
return this.campaignType === CAMPAIGN_TYPES.ONGOING;
|
||||
|
|
|
@ -1,49 +1,38 @@
|
|||
import { shallowMount } from '@vue/test-utils';
|
||||
import campaignMixin from '../campaignMixin';
|
||||
import inboxMixin from '../inboxMixin';
|
||||
|
||||
describe('campaignMixin', () => {
|
||||
beforeEach(() => {
|
||||
global.window = Object.create(window);
|
||||
});
|
||||
it('returns the correct campaign type', () => {
|
||||
const url = 'http://localhost:3000/app/accounts/1/campaigns/one_off';
|
||||
Object.defineProperty(window, 'location', {
|
||||
value: {
|
||||
href: url,
|
||||
},
|
||||
});
|
||||
window.location.href = url;
|
||||
const Component = {
|
||||
render() {},
|
||||
mixins: [campaignMixin, inboxMixin],
|
||||
data() {
|
||||
return {
|
||||
inbox: {
|
||||
channel_type: 'Channel::TwilioSms',
|
||||
phone_number: '+91944444444',
|
||||
},
|
||||
};
|
||||
},
|
||||
mixins: [campaignMixin],
|
||||
};
|
||||
const wrapper = shallowMount(Component);
|
||||
expect(wrapper.vm.campaignType).toBe('one_off');
|
||||
});
|
||||
it('isOnOffType returns true if campaign type is ongoing', () => {
|
||||
it('isOnOffType returns true if campaign type is one_off', () => {
|
||||
const url = 'http://localhost:3000/app/accounts/1/campaigns/one_off';
|
||||
Object.defineProperty(window, 'location', {
|
||||
value: {
|
||||
href: url,
|
||||
},
|
||||
});
|
||||
const Component = {
|
||||
render() {},
|
||||
mixins: [campaignMixin, inboxMixin],
|
||||
data() {
|
||||
return { inbox: { channel_type: 'Channel::WebWidget' } };
|
||||
},
|
||||
};
|
||||
const wrapper = shallowMount(Component);
|
||||
expect(wrapper.vm.isOngoingType).toBe(true);
|
||||
});
|
||||
it('isOngoingType returns true if campaign type is one_off', () => {
|
||||
const Component = {
|
||||
render() {},
|
||||
mixins: [campaignMixin, inboxMixin],
|
||||
data() {
|
||||
return {
|
||||
inbox: {
|
||||
channel_type: 'Channel::TwilioSms',
|
||||
phone_number: '+91944444444',
|
||||
},
|
||||
};
|
||||
},
|
||||
mixins: [campaignMixin],
|
||||
};
|
||||
const wrapper = shallowMount(Component);
|
||||
expect(wrapper.vm.isOnOffType).toBe(true);
|
||||
});
|
||||
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue