From 6c4c5c5ed1757efa1916fea36928976e081dbcc3 Mon Sep 17 00:00:00 2001 From: Roger Gutierrez Date: Thu, 29 Jan 2026 17:44:36 -0600 Subject: [PATCH] feat: combo page header fixed for 0 remaining loans on goals --- src/composables/useGoalData.js | 5 ++- .../specs/composables/useGoalData.spec.js | 36 +++---------------- 2 files changed, 9 insertions(+), 32 deletions(-) diff --git a/src/composables/useGoalData.js b/src/composables/useGoalData.js index e6d5826a8b3..2a7d0810977 100644 --- a/src/composables/useGoalData.js +++ b/src/composables/useGoalData.js @@ -241,7 +241,10 @@ export default function useGoalData({ apollo } = {}) { const string = `Support ${remaining} more ${categoryHeader} to reach your goal`; const encodedHeader = encodeURIComponent(string); const loanFindingUrl = getLoanFindingUrl(categoryId, router.currentRoute.value); - return `${loanFindingUrl}?header=${encodedHeader}`; + if (remaining > 0) { + return `${loanFindingUrl}?header=${encodedHeader}`; + } + return `${loanFindingUrl}`; } /** diff --git a/test/unit/specs/composables/useGoalData.spec.js b/test/unit/specs/composables/useGoalData.spec.js index f5af65555df..503412ae2d6 100644 --- a/test/unit/specs/composables/useGoalData.spec.js +++ b/test/unit/specs/composables/useGoalData.spec.js @@ -1920,32 +1920,6 @@ describe('useGoalData', () => { expect(href).toBe(expectedHref); }); - it('should return 0 remaining when currentLoanCount exceeds target', () => { - const selectedGoalNumber = 5; - const categoryId = ID_WOMENS_EQUALITY; - const router = { currentRoute: { value: {} } }; - const currentLoanCount = 10; // More than target, should clamp to 0 - - const href = composable.getCtaHref(selectedGoalNumber, categoryId, router, currentLoanCount); - const expectedString = 'Support 0 more women to reach your goal'; - const expectedHref = `/lend/${categoryId}?header=${encodeURIComponent(expectedString)}`; - - expect(href).toBe(expectedHref); - }); - - it('should return 0 remaining when currentLoanCount equals target', () => { - const selectedGoalNumber = 5; - const categoryId = ID_WOMENS_EQUALITY; - const router = { currentRoute: { value: {} } }; - const currentLoanCount = 5; // Equals target - - const href = composable.getCtaHref(selectedGoalNumber, categoryId, router, currentLoanCount); - const expectedString = 'Support 0 more women to reach your goal'; - const expectedHref = `/lend/${categoryId}?header=${encodeURIComponent(expectedString)}`; - - expect(href).toBe(expectedHref); - }); - it('should handle undefined selectedGoalNumber', () => { const categoryId = ID_WOMENS_EQUALITY; const router = { currentRoute: { value: {} } }; @@ -1956,15 +1930,15 @@ describe('useGoalData', () => { expect(href).toContain('/lend/'); }); - it('should handle zero selectedGoalNumber', () => { + it('should return href without query parameter when remaining is 0', () => { + const selectedGoalNumber = 5; const categoryId = ID_WOMENS_EQUALITY; const router = { currentRoute: { value: {} } }; + const currentLoanCount = 5; // Equals target - const href = composable.getCtaHref(0, categoryId, router, 0); - const expectedString = 'Support 0 more women to reach your goal'; - const expectedHref = `/lend/${categoryId}?header=${encodeURIComponent(expectedString)}`; + const href = composable.getCtaHref(selectedGoalNumber, categoryId, router, currentLoanCount); - expect(href).toBe(expectedHref); + expect(href).toBe(`/lend/${categoryId}`); }); });