From b67ae7157b0fd854e4394bb7773199a9974c747a Mon Sep 17 00:00:00 2001 From: Snehal Sonawane Date: Wed, 4 Sep 2024 11:29:28 +0530 Subject: [PATCH 01/11] Adding container for for search in standalone gnav --- libs/blocks/global-navigation/global-navigation.js | 6 ++++++ libs/navigation/navigation.js | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libs/blocks/global-navigation/global-navigation.js b/libs/blocks/global-navigation/global-navigation.js index 90e85421d7..cf127b2482 100644 --- a/libs/blocks/global-navigation/global-navigation.js +++ b/libs/blocks/global-navigation/global-navigation.js @@ -813,6 +813,11 @@ class Gnav { analyticsValue: 'Logo', }); + decorateCustomSearch = () => { + this.elements.customSearch = toFragment``; + return this.elements.customSearch; + }; + decorateMainNav = async () => { const breadcrumbs = isDesktop.matches ? '' : await this.decorateBreadcrumbs(); this.elements.mainNav = toFragment`
`; @@ -822,6 +827,7 @@ class Gnav { ${isDesktop.matches ? '' : this.decorateSearch()} ${this.elements.mainNav} ${isDesktop.matches ? this.decorateSearch() : ''} + ${getConfig().searchEnabled === 'on' ? this.decorateCustomSearch() : ''} `; diff --git a/libs/navigation/navigation.js b/libs/navigation/navigation.js index e31dd77195..36e70eab8b 100644 --- a/libs/navigation/navigation.js +++ b/libs/navigation/navigation.js @@ -4,7 +4,7 @@ const blockConfig = [ name: 'global-navigation', targetEl: 'header', appendType: 'prepend', - params: ['imsClientId'], + params: ['imsClientId', 'searchEnabled'], }, { key: 'footer', From 13497fd925c788538cf9f79e7fd0e6ced7e142aa Mon Sep 17 00:00:00 2001 From: Snehal Sonawane Date: Thu, 5 Sep 2024 10:21:39 +0530 Subject: [PATCH 02/11] Updating class name --- libs/blocks/global-navigation/global-navigation.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/blocks/global-navigation/global-navigation.js b/libs/blocks/global-navigation/global-navigation.js index cf127b2482..1a66a84e91 100644 --- a/libs/blocks/global-navigation/global-navigation.js +++ b/libs/blocks/global-navigation/global-navigation.js @@ -813,8 +813,8 @@ class Gnav { analyticsValue: 'Logo', }); - decorateCustomSearch = () => { - this.elements.customSearch = toFragment``; + decorateClientSearch = () => { + this.elements.customSearch = toFragment``; return this.elements.customSearch; }; @@ -827,7 +827,7 @@ class Gnav { ${isDesktop.matches ? '' : this.decorateSearch()} ${this.elements.mainNav} ${isDesktop.matches ? this.decorateSearch() : ''} - ${getConfig().searchEnabled === 'on' ? this.decorateCustomSearch() : ''} + ${getConfig().searchEnabled === 'on' ? this.decorateClientSearch() : ''} `; From 65d345a4cc82499b0a3a0aae4d0de98c74b64798 Mon Sep 17 00:00:00 2001 From: Snehal Sonawane Date: Thu, 5 Sep 2024 11:46:42 +0530 Subject: [PATCH 03/11] Adding unit test --- .../global-navigation/global-navigation.test.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/blocks/global-navigation/global-navigation.test.js b/test/blocks/global-navigation/global-navigation.test.js index 4af0799b83..987150a309 100644 --- a/test/blocks/global-navigation/global-navigation.test.js +++ b/test/blocks/global-navigation/global-navigation.test.js @@ -620,4 +620,21 @@ describe('global navigation', () => { expect(document.querySelector(`${selectors.brandImage} img`).getAttribute('src')).to.equal('http://localhost:2000/test/blocks/global-navigation/mocks/adobe-dark-logo.svg'); }); }); + + describe('decorateClientSearch', () => { + let gnav; + beforeEach(async () => { + gnav = await createFullGlobalNavigation(); + }); + + it('should return the custom search element', async () => { + const customSearchElement = gnav.decorateClientSearch(); + expect(customSearchElement).to.exist; + expect(customSearchElement.classList.contains('feds-client-search')).to.be.true; + }); + + afterEach(() => { + sinon.restore(); + }); + }); }); From 22ec3627411209bd23838556b90e8017242514fb Mon Sep 17 00:00:00 2001 From: Snehal Sonawane Date: Thu, 5 Sep 2024 11:51:22 +0530 Subject: [PATCH 04/11] Removing space to fix eslint issue --- test/blocks/global-navigation/global-navigation.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/blocks/global-navigation/global-navigation.test.js b/test/blocks/global-navigation/global-navigation.test.js index 987150a309..578dc389c4 100644 --- a/test/blocks/global-navigation/global-navigation.test.js +++ b/test/blocks/global-navigation/global-navigation.test.js @@ -626,7 +626,7 @@ describe('global navigation', () => { beforeEach(async () => { gnav = await createFullGlobalNavigation(); }); - + it('should return the custom search element', async () => { const customSearchElement = gnav.decorateClientSearch(); expect(customSearchElement).to.exist; From afa37010c6ee03e3356c98b3caec82c25c51cb36 Mon Sep 17 00:00:00 2001 From: Snehal Sonawane Date: Thu, 5 Sep 2024 12:10:53 +0530 Subject: [PATCH 05/11] Updating unit test --- test/blocks/global-navigation/global-navigation.test.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/blocks/global-navigation/global-navigation.test.js b/test/blocks/global-navigation/global-navigation.test.js index 578dc389c4..05956ca92f 100644 --- a/test/blocks/global-navigation/global-navigation.test.js +++ b/test/blocks/global-navigation/global-navigation.test.js @@ -632,9 +632,5 @@ describe('global navigation', () => { expect(customSearchElement).to.exist; expect(customSearchElement.classList.contains('feds-client-search')).to.be.true; }); - - afterEach(() => { - sinon.restore(); - }); }); }); From b60201c470e565f67b6a4d1266591ecad7a58c33 Mon Sep 17 00:00:00 2001 From: Snehal Sonawane Date: Thu, 5 Sep 2024 15:38:34 +0530 Subject: [PATCH 06/11] Updating unit test --- test/blocks/global-navigation/global-navigation.test.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/test/blocks/global-navigation/global-navigation.test.js b/test/blocks/global-navigation/global-navigation.test.js index 05956ca92f..aefc75efd8 100644 --- a/test/blocks/global-navigation/global-navigation.test.js +++ b/test/blocks/global-navigation/global-navigation.test.js @@ -622,12 +622,8 @@ describe('global navigation', () => { }); describe('decorateClientSearch', () => { - let gnav; - beforeEach(async () => { - gnav = await createFullGlobalNavigation(); - }); - it('should return the custom search element', async () => { + const gnav = await createFullGlobalNavigation(); const customSearchElement = gnav.decorateClientSearch(); expect(customSearchElement).to.exist; expect(customSearchElement.classList.contains('feds-client-search')).to.be.true; From 98cf57eb50a80848ebca988d2284f9361672da4b Mon Sep 17 00:00:00 2001 From: Snehal Sonawane Date: Mon, 9 Sep 2024 09:14:09 +0530 Subject: [PATCH 07/11] Accommodating review comments --- libs/blocks/global-navigation/global-navigation.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libs/blocks/global-navigation/global-navigation.js b/libs/blocks/global-navigation/global-navigation.js index 1a66a84e91..060f474365 100644 --- a/libs/blocks/global-navigation/global-navigation.js +++ b/libs/blocks/global-navigation/global-navigation.js @@ -814,8 +814,7 @@ class Gnav { }); decorateClientSearch = () => { - this.elements.customSearch = toFragment``; - return this.elements.customSearch; + return toFragment``; }; decorateMainNav = async () => { From 24a93a073946401803a10616db646e6651f32299 Mon Sep 17 00:00:00 2001 From: Snehal Sonawane Date: Mon, 9 Sep 2024 10:03:00 +0530 Subject: [PATCH 08/11] Fixing Eslint --- libs/blocks/global-navigation/global-navigation.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libs/blocks/global-navigation/global-navigation.js b/libs/blocks/global-navigation/global-navigation.js index 060f474365..16016f4fc0 100644 --- a/libs/blocks/global-navigation/global-navigation.js +++ b/libs/blocks/global-navigation/global-navigation.js @@ -813,9 +813,7 @@ class Gnav { analyticsValue: 'Logo', }); - decorateClientSearch = () => { - return toFragment``; - }; + decorateClientSearch = () => toFragment``; decorateMainNav = async () => { const breadcrumbs = isDesktop.matches ? '' : await this.decorateBreadcrumbs(); From 3494fbdb8b51f45b12484ef103798adaddfb9a38 Mon Sep 17 00:00:00 2001 From: Snehal Sonawane Date: Mon, 9 Sep 2024 13:35:08 +0530 Subject: [PATCH 09/11] Accommodating review comments --- libs/blocks/global-navigation/global-navigation.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libs/blocks/global-navigation/global-navigation.js b/libs/blocks/global-navigation/global-navigation.js index 16016f4fc0..27e2895e59 100644 --- a/libs/blocks/global-navigation/global-navigation.js +++ b/libs/blocks/global-navigation/global-navigation.js @@ -813,7 +813,10 @@ class Gnav { analyticsValue: 'Logo', }); - decorateClientSearch = () => toFragment``; + // eslint-disable-next-line class-methods-use-this + decorateClientSearch() { + return toFragment``; + } decorateMainNav = async () => { const breadcrumbs = isDesktop.matches ? '' : await this.decorateBreadcrumbs(); @@ -824,7 +827,7 @@ class Gnav { ${isDesktop.matches ? '' : this.decorateSearch()} ${this.elements.mainNav} ${isDesktop.matches ? this.decorateSearch() : ''} - ${getConfig().searchEnabled === 'on' ? this.decorateClientSearch() : ''} + ${this.decorateClientSearch()} `; From 3f52b22c82b6325c4460c854aadef89530938970 Mon Sep 17 00:00:00 2001 From: Snehal Sonawane Date: Mon, 9 Sep 2024 14:38:00 +0530 Subject: [PATCH 10/11] Updating client search --- libs/blocks/global-navigation/global-navigation.js | 7 +------ .../blocks/global-navigation/global-navigation.test.js | 10 ++++------ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/libs/blocks/global-navigation/global-navigation.js b/libs/blocks/global-navigation/global-navigation.js index 27e2895e59..5722a778c9 100644 --- a/libs/blocks/global-navigation/global-navigation.js +++ b/libs/blocks/global-navigation/global-navigation.js @@ -813,11 +813,6 @@ class Gnav { analyticsValue: 'Logo', }); - // eslint-disable-next-line class-methods-use-this - decorateClientSearch() { - return toFragment``; - } - decorateMainNav = async () => { const breadcrumbs = isDesktop.matches ? '' : await this.decorateBreadcrumbs(); this.elements.mainNav = toFragment`
`; @@ -827,7 +822,7 @@ class Gnav { ${isDesktop.matches ? '' : this.decorateSearch()} ${this.elements.mainNav} ${isDesktop.matches ? this.decorateSearch() : ''} - ${this.decorateClientSearch()} + ${getConfig().searchEnabled === 'on' ? toFragment`` : ''} `; diff --git a/test/blocks/global-navigation/global-navigation.test.js b/test/blocks/global-navigation/global-navigation.test.js index aefc75efd8..c8e4bc197d 100644 --- a/test/blocks/global-navigation/global-navigation.test.js +++ b/test/blocks/global-navigation/global-navigation.test.js @@ -621,12 +621,10 @@ describe('global navigation', () => { }); }); - describe('decorateClientSearch', () => { - it('should return the custom search element', async () => { - const gnav = await createFullGlobalNavigation(); - const customSearchElement = gnav.decorateClientSearch(); - expect(customSearchElement).to.exist; - expect(customSearchElement.classList.contains('feds-client-search')).to.be.true; + describe('Client search earch feature in global navigation', () => { + it('should append the feds-client-search div when search is enabled', async () => { + await createFullGlobalNavigation({ customConfig: { searchEnabled: 'on' } }); + expect(document.querySelector(selectors.topNavWrapper).classList.contains('feds-client-search')).to.exist; }); }); }); From 5b9e6f1804314d93924d6a8622a9a14a21cf5605 Mon Sep 17 00:00:00 2001 From: Snehal Sonawane Date: Mon, 9 Sep 2024 14:39:17 +0530 Subject: [PATCH 11/11] Updating client search --- test/blocks/global-navigation/global-navigation.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/blocks/global-navigation/global-navigation.test.js b/test/blocks/global-navigation/global-navigation.test.js index c8e4bc197d..945328606d 100644 --- a/test/blocks/global-navigation/global-navigation.test.js +++ b/test/blocks/global-navigation/global-navigation.test.js @@ -621,7 +621,7 @@ describe('global navigation', () => { }); }); - describe('Client search earch feature in global navigation', () => { + describe('Client search feature in global navigation', () => { it('should append the feds-client-search div when search is enabled', async () => { await createFullGlobalNavigation({ customConfig: { searchEnabled: 'on' } }); expect(document.querySelector(selectors.topNavWrapper).classList.contains('feds-client-search')).to.exist;