mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Merge pull request #2465 from DSpace/backport-2463-to-dspace-7_x
[Port dspace-7_x] Fix to Pagination position is retained between searches #2159
This commit is contained in:
@@ -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'
|
||||
});
|
||||
});
|
||||
|
@@ -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,
|
||||
|
Reference in New Issue
Block a user