mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Merge pull request #1919 from atmire/w2p-95648_issue-1900_facet-prefix-values-not-escaped_latest
Search in sidebar/facet don't escape special characters
This commit is contained in:
@@ -26,6 +26,8 @@ import { SearchConfigurationService } from './search-configuration.service';
|
|||||||
import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub';
|
import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub';
|
||||||
import { RequestEntry } from '../../data/request-entry.model';
|
import { RequestEntry } from '../../data/request-entry.model';
|
||||||
import { Angulartics2 } from 'angulartics2';
|
import { Angulartics2 } from 'angulartics2';
|
||||||
|
import { SearchFilterConfig } from '../../../shared/search/models/search-filter-config.model';
|
||||||
|
import anything = jasmine.anything;
|
||||||
|
|
||||||
@Component({ template: '' })
|
@Component({ template: '' })
|
||||||
class DummyComponent {
|
class DummyComponent {
|
||||||
@@ -36,7 +38,7 @@ describe('SearchService', () => {
|
|||||||
let searchService: SearchService;
|
let searchService: SearchService;
|
||||||
const router = new RouterStub();
|
const router = new RouterStub();
|
||||||
const route = new ActivatedRouteStub();
|
const route = new ActivatedRouteStub();
|
||||||
const searchConfigService = {paginationID: 'page-id'};
|
const searchConfigService = { paginationID: 'page-id' };
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -103,7 +105,8 @@ describe('SearchService', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const paginationService = new PaginationServiceStub();
|
const paginationService = new PaginationServiceStub();
|
||||||
const searchConfigService = {paginationID: 'page-id'};
|
const searchConfigService = { paginationID: 'page-id' };
|
||||||
|
const requestService = getMockRequestService();
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
@@ -119,7 +122,7 @@ describe('SearchService', () => {
|
|||||||
providers: [
|
providers: [
|
||||||
{ provide: Router, useValue: router },
|
{ provide: Router, useValue: router },
|
||||||
{ provide: RouteService, useValue: routeServiceStub },
|
{ provide: RouteService, useValue: routeServiceStub },
|
||||||
{ provide: RequestService, useValue: getMockRequestService() },
|
{ provide: RequestService, useValue: requestService },
|
||||||
{ provide: RemoteDataBuildService, useValue: remoteDataBuildService },
|
{ provide: RemoteDataBuildService, useValue: remoteDataBuildService },
|
||||||
{ provide: HALEndpointService, useValue: halService },
|
{ provide: HALEndpointService, useValue: halService },
|
||||||
{ provide: CommunityDataService, useValue: {} },
|
{ provide: CommunityDataService, useValue: {} },
|
||||||
@@ -138,13 +141,13 @@ describe('SearchService', () => {
|
|||||||
|
|
||||||
it('should call the navigate method on the Router with view mode list parameter as a parameter when setViewMode is called', () => {
|
it('should call the navigate method on the Router with view mode list parameter as a parameter when setViewMode is called', () => {
|
||||||
searchService.setViewMode(ViewMode.ListElement);
|
searchService.setViewMode(ViewMode.ListElement);
|
||||||
expect(paginationService.updateRouteWithUrl).toHaveBeenCalledWith('page-id', ['/search'], {page: 1}, { view: ViewMode.ListElement }
|
expect(paginationService.updateRouteWithUrl).toHaveBeenCalledWith('page-id', ['/search'], { page: 1 }, { view: ViewMode.ListElement }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call the navigate method on the Router with view mode grid parameter as a parameter when setViewMode is called', () => {
|
it('should call the navigate method on the Router with view mode grid parameter as a parameter when setViewMode is called', () => {
|
||||||
searchService.setViewMode(ViewMode.GridElement);
|
searchService.setViewMode(ViewMode.GridElement);
|
||||||
expect(paginationService.updateRouteWithUrl).toHaveBeenCalledWith('page-id', ['/search'], {page: 1}, { view: ViewMode.GridElement }
|
expect(paginationService.updateRouteWithUrl).toHaveBeenCalledWith('page-id', ['/search'], { page: 1 }, { view: ViewMode.GridElement }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -191,5 +194,23 @@ describe('SearchService', () => {
|
|||||||
expect((searchService as any).rdb.buildFromHref).toHaveBeenCalledWith(endPoint);
|
expect((searchService as any).rdb.buildFromHref).toHaveBeenCalledWith(endPoint);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('when getFacetValuesFor is called with a filterQuery', () => {
|
||||||
|
it('should add the encoded filterQuery to the args list', () => {
|
||||||
|
jasmine.getEnv().allowRespy(true);
|
||||||
|
const spyRequest = spyOn((searchService as any), 'request').and.stub();
|
||||||
|
spyOn(requestService, 'send').and.returnValue(true);
|
||||||
|
const searchFilterConfig = new SearchFilterConfig();
|
||||||
|
searchFilterConfig._links = {
|
||||||
|
self: {
|
||||||
|
href: 'https://demo.dspace.org/',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
searchService.getFacetValuesFor(searchFilterConfig, 1, undefined, 'filter&Query');
|
||||||
|
|
||||||
|
expect(spyRequest).toHaveBeenCalledWith(anything(), 'https://demo.dspace.org?page=0&size=5&prefix=filter%26Query');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -271,7 +271,7 @@ export class SearchService implements OnDestroy {
|
|||||||
let href;
|
let href;
|
||||||
let args: string[] = [];
|
let args: string[] = [];
|
||||||
if (hasValue(filterQuery)) {
|
if (hasValue(filterQuery)) {
|
||||||
args.push(`prefix=${filterQuery}`);
|
args.push(`prefix=${encodeURIComponent(filterQuery)}`);
|
||||||
}
|
}
|
||||||
if (hasValue(searchOptions)) {
|
if (hasValue(searchOptions)) {
|
||||||
searchOptions = Object.assign(new PaginatedSearchOptions({}), searchOptions, {
|
searchOptions = Object.assign(new PaginatedSearchOptions({}), searchOptions, {
|
||||||
|
Reference in New Issue
Block a user