Navigation Menu

Skip to content

Commit

Permalink
Merge branch 'hotfix/2.4.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
sojan-official committed Apr 21, 2022
2 parents 480eb30 + f769471 commit 3584bbb
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 5 deletions.
6 changes: 5 additions & 1 deletion app/javascript/widget/mixins/availability.js
Expand Up @@ -34,10 +34,14 @@ export default {
openAllDay,
} = this.currentDayAvailability;

if (openAllDay || closedAllDay) {
if (openAllDay) {
return true;
}

if (closedAllDay) {
return false;
}

const { utcOffset } = this.channelConfig;
const today = this.getDateWithOffset(utcOffset);
const currentHours = today.getHours();
Expand Down
44 changes: 42 additions & 2 deletions app/javascript/widget/mixins/specs/availabilityMixin.spec.js
Expand Up @@ -28,6 +28,10 @@ global.chatwootWebChannel = {
};

describe('availabilityMixin', () => {
beforeEach(() => {
jest.useRealTimers();
});

it('returns valid isInBetweenWorkingHours if in different timezone', () => {
const Component = {
render() {},
Expand All @@ -40,7 +44,6 @@ describe('availabilityMixin', () => {
const vm = new Constructor().$mount();
const wrapper = createWrapper(vm);
expect(wrapper.vm.isInBetweenTheWorkingHours).toBe(true);
jest.useRealTimers();
});

it('returns valid isInBetweenWorkingHours if in same timezone', () => {
Expand All @@ -55,6 +58,43 @@ describe('availabilityMixin', () => {
const Constructor = Vue.extend(Component);
const wrapper = createWrapper(new Constructor().$mount());
expect(wrapper.vm.isInBetweenTheWorkingHours).toBe(true);
jest.useRealTimers();
});

it('returns false if closed all day', () => {
const Component = {
render() {},
mixins: [availabilityMixin],
};
global.chatwootWebChannel.utcOffset = '-07:00';
global.chatwootWebChannel.workingHours = [
{ day_of_week: 3, closed_all_day: true },
];
jest
.useFakeTimers('modern')
.setSystemTime(new Date('Thu Apr 14 2022 09:01:46 GMT+0530'));

const Constructor = Vue.extend(Component);
const vm = new Constructor().$mount();
const wrapper = createWrapper(vm);
expect(wrapper.vm.isInBetweenTheWorkingHours).toBe(false);
});

it('returns true if open all day', () => {
const Component = {
render() {},
mixins: [availabilityMixin],
};
global.chatwootWebChannel.utcOffset = '-07:00';
global.chatwootWebChannel.workingHours = [
{ day_of_week: 3, open_all_day: true },
];
jest
.useFakeTimers('modern')
.setSystemTime(new Date('Thu Apr 14 2022 09:01:46 GMT+0530'));

const Constructor = Vue.extend(Component);
const vm = new Constructor().$mount();
const wrapper = createWrapper(vm);
expect(wrapper.vm.isInBetweenTheWorkingHours).toBe(true);
});
});
2 changes: 1 addition & 1 deletion config/app.yml
@@ -1,5 +1,5 @@
shared: &shared
version: '2.4.0'
version: '2.4.1'

development:
<<: *shared
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@chatwoot/chatwoot",
"version": "2.4.0",
"version": "2.4.1",
"license": "MIT",
"scripts": {
"eslint": "eslint app/**/*.{js,vue} --fix",
Expand Down

0 comments on commit 3584bbb

Please sign in to comment.