feat: One off campaign UI (#2621)
This commit is contained in:
4
app/javascript/shared/constants/campaign.js
Normal file
4
app/javascript/shared/constants/campaign.js
Normal file
@@ -0,0 +1,4 @@
|
||||
export const CAMPAIGN_TYPES = {
|
||||
ONGOING: 'ongoing',
|
||||
ONE_OFF: 'one_off',
|
||||
};
|
||||
19
app/javascript/shared/mixins/campaignMixin.js
Normal file
19
app/javascript/shared/mixins/campaignMixin.js
Normal file
@@ -0,0 +1,19 @@
|
||||
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;
|
||||
},
|
||||
isOngoingType() {
|
||||
return this.campaignType === CAMPAIGN_TYPES.ONGOING;
|
||||
},
|
||||
isOnOffType() {
|
||||
return this.campaignType === CAMPAIGN_TYPES.ONE_OFF;
|
||||
},
|
||||
},
|
||||
};
|
||||
49
app/javascript/shared/mixins/specs/campaignMixin.spec.js
Normal file
49
app/javascript/shared/mixins/specs/campaignMixin.spec.js
Normal file
@@ -0,0 +1,49 @@
|
||||
import { shallowMount } from '@vue/test-utils';
|
||||
import campaignMixin from '../campaignMixin';
|
||||
import inboxMixin from '../inboxMixin';
|
||||
|
||||
describe('campaignMixin', () => {
|
||||
it('returns the correct campaign type', () => {
|
||||
const Component = {
|
||||
render() {},
|
||||
mixins: [campaignMixin, inboxMixin],
|
||||
data() {
|
||||
return {
|
||||
inbox: {
|
||||
channel_type: 'Channel::TwilioSms',
|
||||
phone_number: '+91944444444',
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
const wrapper = shallowMount(Component);
|
||||
expect(wrapper.vm.campaignType).toBe('one_off');
|
||||
});
|
||||
it('isOnOffType returns true if campaign type is ongoing', () => {
|
||||
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',
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
const wrapper = shallowMount(Component);
|
||||
expect(wrapper.vm.isOnOffType).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user