diff --git a/src/search-backend/base-search-backend.ts b/src/search-backend/base-search-backend.ts index 5114c44..be8a929 100644 --- a/src/search-backend/base-search-backend.ts +++ b/src/search-backend/base-search-backend.ts @@ -187,7 +187,9 @@ export abstract class BaseSearchBackend implements SearchBackendInterface { } console.log(`\n\n***** RESPONSE RECEIVED *****`); + console.groupCollapsed('Response'); console.log(JSON.stringify(clonedResponse, null, 2)); + console.groupEnd(); } catch (err) { console.error('Error printing search response:', err); } diff --git a/test/search-backend/fulltext-search-backend.test.ts b/test/search-backend/fulltext-search-backend.test.ts index 06bd0de..e4b8e07 100644 --- a/test/search-backend/fulltext-search-backend.test.ts +++ b/test/search-backend/fulltext-search-backend.test.ts @@ -76,13 +76,18 @@ describe('FulltextSearchBackend', () => { }); it('includes scope param from URL if not provided', async () => { - window.location.search = `?scope=boop`; + const url = new URL(window.location.href); + url.searchParams.set('scope', 'boop'); + window.history.replaceState({}, '', url.toString()); const backend = new FulltextSearchBackend(); await backend.performSearch({ query: 'foo' }); const queryParams = new URL(urlCalled!.toString()).searchParams; expect(queryParams.get('scope')).to.equal('boop'); + + url.searchParams.delete('scope'); + window.history.replaceState({}, '', url.toString()); }); it('includes caching param if provided', async () => { @@ -98,13 +103,19 @@ describe('FulltextSearchBackend', () => { it('includes caching param from URL if not provided', async () => { const cachingParam = JSON.stringify({ bypass: true }); - window.location.search = `?caching=${cachingParam}`; + + const url = new URL(window.location.href); + url.searchParams.set('caching', cachingParam); + window.history.replaceState({}, '', url.toString()); const backend = new FulltextSearchBackend(); await backend.performSearch({ query: 'foo' }); const queryParams = new URL(urlCalled!.toString()).searchParams; expect(queryParams.get('caching')).to.equal(cachingParam); + + url.searchParams.delete('caching'); + window.history.replaceState({}, '', url.toString()); }); it('can enable debugging by default on all searches', async () => { @@ -262,7 +273,9 @@ describe('FulltextSearchBackend', () => { }); it('includes verbose param from URL if not provided', async () => { - window.location.search = `?verbose=1`; + const url = new URL(window.location.href); + url.searchParams.set('verbose', '1'); + window.history.replaceState({}, '', url.toString()); const logBackup = console.log; const logSpy = Sinon.spy(); @@ -275,5 +288,7 @@ describe('FulltextSearchBackend', () => { expect(logSpy.args[0][0]).to.equal('\n\n***** RESPONSE RECEIVED *****'); console.log = logBackup; + url.searchParams.delete('verbose'); + window.history.replaceState({}, '', url.toString()); }); }); diff --git a/test/search-backend/metadata-search-backend.test.ts b/test/search-backend/metadata-search-backend.test.ts index 8a468fe..7811979 100644 --- a/test/search-backend/metadata-search-backend.test.ts +++ b/test/search-backend/metadata-search-backend.test.ts @@ -76,13 +76,18 @@ describe('MetadataSearchBackend', () => { }); it('includes scope param from URL if not provided', async () => { - window.location.search = `?scope=boop`; + const url = new URL(window.location.href); + url.searchParams.set('scope', 'boop'); + window.history.replaceState({}, '', url.toString()); const backend = new MetadataSearchBackend(); await backend.performSearch({ query: 'foo' }); const queryParams = new URL(urlCalled!.toString()).searchParams; expect(queryParams.get('scope')).to.equal('boop'); + + url.searchParams.delete('scope'); + window.history.replaceState({}, '', url.toString()); }); it('includes caching param if provided', async () => { @@ -98,13 +103,19 @@ describe('MetadataSearchBackend', () => { it('includes caching param from URL if not provided', async () => { const cachingParam = JSON.stringify({ bypass: true }); - window.location.search = `?caching=${cachingParam}`; + + const url = new URL(window.location.href); + url.searchParams.set('caching', cachingParam); + window.history.replaceState({}, '', url.toString()); const backend = new MetadataSearchBackend(); await backend.performSearch({ query: 'foo' }); const queryParams = new URL(urlCalled!.toString()).searchParams; expect(queryParams.get('caching')).to.equal(cachingParam); + + url.searchParams.delete('caching'); + window.history.replaceState({}, '', url.toString()); }); it('can enable debugging by default on all searches', async () => { @@ -262,7 +273,9 @@ describe('MetadataSearchBackend', () => { }); it('includes verbose param from URL if not provided', async () => { - window.location.search = `?verbose=1`; + const url = new URL(window.location.href); + url.searchParams.set('verbose', '1'); + window.history.replaceState({}, '', url.toString()); const logBackup = console.log; const logSpy = Sinon.spy(); @@ -275,5 +288,7 @@ describe('MetadataSearchBackend', () => { expect(logSpy.args[0][0]).to.equal('\n\n***** RESPONSE RECEIVED *****'); console.log = logBackup; + url.searchParams.delete('verbose'); + window.history.replaceState({}, '', url.toString()); }); });