From 97ca23bc93f0d549269d4f316f6a0ba1dc7e0099 Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Thu, 29 Jun 2023 08:44:09 -0400 Subject: [PATCH 1/3] some debugging code added --- .../service-location-helper/service-location-helper.js | 4 ++++ .../shop-question/shop-list-button/shop-list-button.vue | 9 +++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/layouts/service-location/helpers/service-location-helper/service-location-helper.js b/src/layouts/service-location/helpers/service-location-helper/service-location-helper.js index b100a50b5..dfae12bba 100644 --- a/src/layouts/service-location/helpers/service-location-helper/service-location-helper.js +++ b/src/layouts/service-location/helpers/service-location-helper/service-location-helper.js @@ -62,11 +62,15 @@ export async function getAvailabilityRating( false ); + console.log(shopTimeSlots) + // Rate the availability for the shop let numberOfAppointmentsPerDay = []; for (let i = 0; i < shopTimeSlots.data.days.length; i++) { numberOfAppointmentsPerDay.push(shopTimeSlots.data.days[i].timeSlots.length); } + + console.log(numberOfAppointmentsPerDay) const dateRange = 7; const minimumNumberOfAppointmentsPerDay = 1; diff --git a/src/layouts/service-location/shop-question/shop-list-button/shop-list-button.vue b/src/layouts/service-location/shop-question/shop-list-button/shop-list-button.vue index df80fdffa..6eb34382e 100644 --- a/src/layouts/service-location/shop-question/shop-list-button/shop-list-button.vue +++ b/src/layouts/service-location/shop-question/shop-list-button/shop-list-button.vue @@ -73,10 +73,11 @@ export default { }, computed: { displayAvailabilityIndicators() { - return experimentMixin.methods.hasSettingEqualTo( - experimentSettings.DISPLAY_AVAILABILITY_INDICATORS, - "true" - ); + return true; //TODO: REMOVE THIS + // return experimentMixin.methods.hasSettingEqualTo( + // experimentSettings.DISPLAY_AVAILABILITY_INDICATORS, + // "true" + // ); }, isLoaderDisplayed() { return this.availabilityRating == null; From 2a89764989027eed0b71ee35b172ee2bc0b35072 Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Fri, 30 Jun 2023 07:34:35 -0400 Subject: [PATCH 2/3] Fixed logic in getAvailabilityRating --- .../service-location-helper.js | 27 +-- .../service-location-helper.spec.js | 170 +++++++----------- 2 files changed, 70 insertions(+), 127 deletions(-) diff --git a/src/layouts/service-location/helpers/service-location-helper/service-location-helper.js b/src/layouts/service-location/helpers/service-location-helper/service-location-helper.js index dfae12bba..19758bd07 100644 --- a/src/layouts/service-location/helpers/service-location-helper/service-location-helper.js +++ b/src/layouts/service-location/helpers/service-location-helper/service-location-helper.js @@ -62,31 +62,10 @@ export async function getAvailabilityRating( false ); - console.log(shopTimeSlots) - - // Rate the availability for the shop - let numberOfAppointmentsPerDay = []; - for (let i = 0; i < shopTimeSlots.data.days.length; i++) { - numberOfAppointmentsPerDay.push(shopTimeSlots.data.days[i].timeSlots.length); - } - - console.log(numberOfAppointmentsPerDay) - - const dateRange = 7; - const minimumNumberOfAppointmentsPerDay = 1; const numberOfDaysToEvaluate = 2; - - let daysWithMinimalAppointmentsCount = 0; - for (let i = 0; i < dateRange; i++) { - if (numberOfAppointmentsPerDay[i] >= minimumNumberOfAppointmentsPerDay) { - daysWithMinimalAppointmentsCount++; - if (daysWithMinimalAppointmentsCount >= numberOfDaysToEvaluate) { - break; - } - } - } - - const isGoodAvailability = daysWithMinimalAppointmentsCount >= numberOfDaysToEvaluate; + const isGoodAvailability = + shopTimeSlots.data.days.filter((x) => x.timeSlots.length > 0).length >= + numberOfDaysToEvaluate; const shopStatus = isGoodAvailability ? "high" : "low"; diff --git a/src/layouts/service-location/helpers/service-location-helper/service-location-helper.spec.js b/src/layouts/service-location/helpers/service-location-helper/service-location-helper.spec.js index 81d336968..2c0e5a95e 100644 --- a/src/layouts/service-location/helpers/service-location-helper/service-location-helper.spec.js +++ b/src/layouts/service-location/helpers/service-location-helper/service-location-helper.spec.js @@ -92,94 +92,54 @@ const mockStoreActionGetServiceabilityDetails = storeActions.GET_SERVICEABILITY_ const mockStoreActionGetShopTimeSlots = storeActions.GET_SHOP_TIME_SLOTS; const mockGetShopTimeSlotsGoodAvailability = { - estimatedServiceMinutesMinimum: 0, - estimatedServiceMinutesMaximimum: 0, - days: [ - { - date: "string", - timeSlots: [ - { - id: "string", - startTime: "", - endTime: "", - offerPremium: true, - }, - ], - }, - { - date: "string", - timeSlots: [], - }, - { - date: "string", - timeSlots: [], - }, - { - date: "string", - timeSlots: [], - }, - { - date: "string", - timeSlots: [], - }, - { - date: "string", - timeSlots: [], - }, - { - date: "string", - timeSlots: [ - { - id: "string", - startTime: "", - endTime: "", - offerPremium: true, - }, - ], - }, - ], + data: { + estimatedServiceMinutesMinimum: 0, + estimatedServiceMinutesMaximimum: 0, + days: [ + { + date: "string", + timeSlots: [ + { + id: "string", + startTime: "", + endTime: "", + offerPremium: true, + }, + ], + }, + { + date: "string", + timeSlots: [ + { + id: "string", + startTime: "", + endTime: "", + offerPremium: true, + }, + ], + }, + ], + } }; const mockGetShopTimeSlotsLowAvailability = { - estimatedServiceMinutesMinimum: 0, - estimatedServiceMinutesMaximimum: 0, - days: [ - { - date: "string", - timeSlots: [], - }, - { - date: "string", - timeSlots: [], - }, - { - date: "string", - timeSlots: [], - }, - { - date: "string", - timeSlots: [], - }, - { - date: "string", - timeSlots: [], - }, - { - date: "string", - timeSlots: [], - }, - { - date: "string", - timeSlots: [ - { - id: "string", - startTime: "", - endTime: "", - offerPremium: true, - }, - ], - }, - ], + data: { + estimatedServiceMinutesMinimum: 0, + estimatedServiceMinutesMaximimum: 0, + days: [ + { + date: "string", + timeSlots: [ + { + id: "string", + startTime: "", + endTime: "", + offerPremium: true, + }, + ], + }, + ], + } }; jest.mock("@/mixins/base-mixin.js", () => ({ @@ -228,6 +188,7 @@ jest.mock("@/mixins/base-mixin.js", () => ({ } if (actionName === mockStoreActionGetShopTimeSlots) { + console.log(request) if (request.providerNumber == "0000001") { return Promise.resolve(mockGetShopTimeSlotsGoodAvailability); } @@ -310,23 +271,26 @@ describe("service-location-helper.js", () => { }); describe("getAvailabilityRating", () => { - // it("Should return a 'Good' rating", async () => { - // // Arrange - // const providerNumber = "0000001"; - // const expected = "Good"; - // // Act - // const result = await getAvailabilityRating(providerNumber); - // // Assert - // expect(result).toEqual(expected); - // }); - // it("Should return a 'Low' rating", async () => { - // // Arrange - // const providerNumber = "0000000"; - // const expected = "Low"; - // // Act - // const result = await getAvailabilityRating(providerNumber); - // // Assert - // expect(result).toEqual(expected); - // }); + it("Should return a 'high' rating", async () => { + // Arrange + const providerNumber = "0000001"; + const expected = "high"; + // Act + const result = await getAvailabilityRating("2023-06-30", "2023-07-06", "Inshop", providerNumber); + + // Assert + expect(result).toEqual(expected); + }); + + it("Should return a 'low' rating", async () => { + // Arrange + const providerNumber = "0000000"; + const expected = "low"; + // Act + const result = await getAvailabilityRating("2023-06-30", "2023-07-06", "Inshop", providerNumber); + + // Assert + expect(result).toEqual(expected); + }); }); }); From 842bd8a20ac112375b5515aac4b130d1994f63a3 Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Fri, 30 Jun 2023 07:35:04 -0400 Subject: [PATCH 3/3] Prettified --- .../service-location-helper.spec.js | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/layouts/service-location/helpers/service-location-helper/service-location-helper.spec.js b/src/layouts/service-location/helpers/service-location-helper/service-location-helper.spec.js index 2c0e5a95e..ceea2db7a 100644 --- a/src/layouts/service-location/helpers/service-location-helper/service-location-helper.spec.js +++ b/src/layouts/service-location/helpers/service-location-helper/service-location-helper.spec.js @@ -119,7 +119,7 @@ const mockGetShopTimeSlotsGoodAvailability = { ], }, ], - } + }, }; const mockGetShopTimeSlotsLowAvailability = { @@ -139,7 +139,7 @@ const mockGetShopTimeSlotsLowAvailability = { ], }, ], - } + }, }; jest.mock("@/mixins/base-mixin.js", () => ({ @@ -188,7 +188,7 @@ jest.mock("@/mixins/base-mixin.js", () => ({ } if (actionName === mockStoreActionGetShopTimeSlots) { - console.log(request) + console.log(request); if (request.providerNumber == "0000001") { return Promise.resolve(mockGetShopTimeSlotsGoodAvailability); } @@ -276,7 +276,12 @@ describe("service-location-helper.js", () => { const providerNumber = "0000001"; const expected = "high"; // Act - const result = await getAvailabilityRating("2023-06-30", "2023-07-06", "Inshop", providerNumber); + const result = await getAvailabilityRating( + "2023-06-30", + "2023-07-06", + "Inshop", + providerNumber + ); // Assert expect(result).toEqual(expected); @@ -287,7 +292,12 @@ describe("service-location-helper.js", () => { const providerNumber = "0000000"; const expected = "low"; // Act - const result = await getAvailabilityRating("2023-06-30", "2023-07-06", "Inshop", providerNumber); + const result = await getAvailabilityRating( + "2023-06-30", + "2023-07-06", + "Inshop", + providerNumber + ); // Assert expect(result).toEqual(expected);