diff --git a/src/app/shared/search-form/search-form.component.spec.ts b/src/app/shared/search-form/search-form.component.spec.ts index 584b7c5584c..1fe1ea83160 100644 --- a/src/app/shared/search-form/search-form.component.spec.ts +++ b/src/app/shared/search-form/search-form.component.spec.ts @@ -28,6 +28,7 @@ describe('SearchFormComponent', () => { const searchService = new SearchServiceStub(); const paginationService = new PaginationServiceStub(); const searchConfigService = { paginationID: 'test-id' }; + const firstPage = { 'spc.page': 1 }; const dspaceObjectService = { findById: () => createSuccessfulRemoteDataObject$(undefined), }; @@ -104,16 +105,16 @@ describe('SearchFormComponent', () => { const scope = 'MCU'; let searchQuery = {}; - it('should navigate to the search page even when no parameters are provided', () => { + it('should navigate to the search first page even when no parameters are provided', () => { comp.updateSearch(searchQuery); expect(router.navigate).toHaveBeenCalledWith(comp.getSearchLinkParts(), { - queryParams: searchQuery, + queryParams: { ...searchQuery, ...firstPage }, queryParamsHandling: 'merge' }); }); - it('should navigate to the search page with parameters only query if only query is provided', () => { + it('should navigate to the search first page with parameters only query if only query is provided', () => { searchQuery = { query: query }; @@ -121,12 +122,12 @@ describe('SearchFormComponent', () => { comp.updateSearch(searchQuery); expect(router.navigate).toHaveBeenCalledWith(comp.getSearchLinkParts(), { - queryParams: searchQuery, + queryParams: { ...searchQuery, ...firstPage }, queryParamsHandling: 'merge' }); }); - it('should navigate to the search page with parameters only query if only scope is provided', () => { + it('should navigate to the search first page with parameters only query if only scope is provided', () => { searchQuery = { scope: scope }; @@ -134,7 +135,7 @@ describe('SearchFormComponent', () => { comp.updateSearch(searchQuery); expect(router.navigate).toHaveBeenCalledWith(comp.getSearchLinkParts(), { - queryParams: searchQuery, + queryParams: {...searchQuery, ...firstPage}, queryParamsHandling: 'merge' }); }); diff --git a/src/app/shared/search-form/search-form.component.ts b/src/app/shared/search-form/search-form.component.ts index 151ded6f9e9..95a063bdd67 100644 --- a/src/app/shared/search-form/search-form.component.ts +++ b/src/app/shared/search-form/search-form.component.ts @@ -114,7 +114,14 @@ export class SearchFormComponent implements OnChanges { * @param data Updated parameters */ updateSearch(data: any) { - const queryParams = Object.assign({}, data); + const goToFirstPage = { 'spc.page': 1 }; + + const queryParams = Object.assign( + { + ...goToFirstPage + }, + data + ); void this.router.navigate(this.getSearchLinkParts(), { queryParams: queryParams,