From f2815a2c002a81516473825ce7432cd4cc35846e Mon Sep 17 00:00:00 2001 From: Sojan Date: Thu, 21 Apr 2022 14:10:54 +0530 Subject: [PATCH 1/2] Bump version to 2.4.1 --- config/app.yml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/app.yml b/config/app.yml index bcbe685e8..d370e1d74 100644 --- a/config/app.yml +++ b/config/app.yml @@ -1,5 +1,5 @@ shared: &shared - version: '2.4.0' + version: '2.4.1' development: <<: *shared diff --git a/package.json b/package.json index da44aecb2..498be6ca2 100644 --- a/package.json +++ b/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", From f7694714394c47e980b45e82f1e66de658146421 Mon Sep 17 00:00:00 2001 From: Pranav Raj S Date: Thu, 21 Apr 2022 14:14:56 +0530 Subject: [PATCH 2/2] fix: Issue with closed all hours (#4521) fixing the accidentally merged conditions for open all day and closed all day. --- app/javascript/widget/mixins/availability.js | 6 ++- .../mixins/specs/availabilityMixin.spec.js | 44 ++++++++++++++++++- 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/app/javascript/widget/mixins/availability.js b/app/javascript/widget/mixins/availability.js index 1c5cbc37f..56f33b214 100644 --- a/app/javascript/widget/mixins/availability.js +++ b/app/javascript/widget/mixins/availability.js @@ -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(); diff --git a/app/javascript/widget/mixins/specs/availabilityMixin.spec.js b/app/javascript/widget/mixins/specs/availabilityMixin.spec.js index 5b9e28caa..aa0cfd64c 100644 --- a/app/javascript/widget/mixins/specs/availabilityMixin.spec.js +++ b/app/javascript/widget/mixins/specs/availabilityMixin.spec.js @@ -28,6 +28,10 @@ global.chatwootWebChannel = { }; describe('availabilityMixin', () => { + beforeEach(() => { + jest.useRealTimers(); + }); + it('returns valid isInBetweenWorkingHours if in different timezone', () => { const Component = { render() {}, @@ -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', () => { @@ -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); }); });