Skip to content

Commit

Permalink
Merge pull request DSpace#3012 from alexandrevryghem/advanced-search_…
Browse files Browse the repository at this point in the history
…contribute-main

Refactored advanced search to rely on available filters
  • Loading branch information
tdonohue authored May 8, 2024
2 parents ceca3bf + fd6d470 commit 6c4ff40
Show file tree
Hide file tree
Showing 76 changed files with 1,185 additions and 1,388 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ import {
} from '@angular/router';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { provideMockStore } from '@ngrx/store/testing';
import {
TranslateLoader,
TranslateModule,
} from '@ngx-translate/core';
import { TranslateModule } from '@ngx-translate/core';
import {
Observable,
of as observableOf,
Expand Down Expand Up @@ -59,6 +56,7 @@ import {
} from '../../shared/mocks/dso-name.service.mock';
import { RouterMock } from '../../shared/mocks/router.mock';
import { NotificationsService } from '../../shared/notifications/notifications.service';
import { PaginationComponent } from '../../shared/pagination/pagination.component';
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
import { ActivatedRouteStub } from '../../shared/testing/active-router.stub';
import {
Expand All @@ -72,7 +70,6 @@ import {
import { NotificationsServiceStub } from '../../shared/testing/notifications-service.stub';
import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub';
import { routeServiceStub } from '../../shared/testing/route-service.stub';
import { TranslateLoaderMock } from '../../shared/testing/translate-loader.mock';
import { GroupsRegistryComponent } from './groups-registry.component';

describe('GroupsRegistryComponent', () => {
Expand Down Expand Up @@ -209,12 +206,9 @@ describe('GroupsRegistryComponent', () => {
paginationService = new PaginationServiceStub();
return TestBed.configureTestingModule({
imports: [CommonModule, NgbModule, FormsModule, ReactiveFormsModule, BrowserModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useClass: TranslateLoaderMock,
},
}), GroupsRegistryComponent],
TranslateModule.forRoot(),
GroupsRegistryComponent,
],
providers: [GroupsRegistryComponent,
{ provide: DSONameService, useValue: new DSONameServiceMock() },
{ provide: EPersonDataService, useValue: ePersonDataServiceStub },
Expand All @@ -232,6 +226,12 @@ describe('GroupsRegistryComponent', () => {
provideMockStore(),
],
schemas: [NO_ERRORS_SCHEMA],
}).overrideComponent(GroupsRegistryComponent, {
remove: {
imports: [
PaginationComponent,
],
},
}).compileComponents();
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ import {
ReactiveFormsModule,
UntypedFormBuilder,
} from '@angular/forms';
import {
Router,
RouterLink,
} from '@angular/router';
import { RouterLink } from '@angular/router';
import { NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap';
import {
TranslateModule,
Expand Down Expand Up @@ -149,7 +146,6 @@ export class GroupsRegistryComponent implements OnInit, OnDestroy {
private notificationsService: NotificationsService,
private formBuilder: UntypedFormBuilder,
protected routeService: RouteService,
private router: Router,
private authorizationService: AuthorizationDataService,
private paginationService: PaginationService,
public requestService: RequestService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,34 @@ import {
ComponentFixture,
TestBed,
} from '@angular/core/testing';
import { ActivatedRoute } from '@angular/router';
import { provideMockStore } from '@ngrx/store/testing';
import { RouterModule } from '@angular/router';
import { TranslateModule } from '@ngx-translate/core';

import { APP_DATA_SERVICES_MAP } from '../../../../../config/app-config.interface';
import { RemoteDataBuildService } from '../../../../core/cache/builders/remote-data-build.service';
import { RequestService } from '../../../../core/data/request.service';
import { RouteService } from '../../../../core/services/route.service';
import { HALEndpointService } from '../../../../core/shared/hal-endpoint.service';
import { SearchConfigurationService } from '../../../../core/shared/search/search-configuration.service';
import { SEARCH_CONFIG_SERVICE } from '../../../../my-dspace-page/my-dspace-configuration.service';
import { MockActivatedRoute } from '../../../../shared/mocks/active-router.mock';
import { getMockRemoteDataBuildService } from '../../../../shared/mocks/remote-data-build.service.mock';
import { routeServiceStub } from '../../../../shared/testing/route-service.stub';
import { SearchConfigurationServiceStub } from '../../../../shared/testing/search-configuration-service.stub';
import { AdminNotifyLogsResultComponent } from '../admin-notify-logs-result/admin-notify-logs-result.component';
import { AdminNotifyIncomingComponent } from './admin-notify-incoming.component';

describe('AdminNotifyIncomingComponent', () => {
let component: AdminNotifyIncomingComponent;
let fixture: ComponentFixture<AdminNotifyIncomingComponent>;
let halService: HALEndpointService;
let requestService: RequestService;
let rdbService: RemoteDataBuildService;


let searchConfigurationService: SearchConfigurationServiceStub;

beforeEach(async () => {
rdbService = getMockRemoteDataBuildService();
halService = jasmine.createSpyObj('halService', {
'getRootHref': '/api',
});
requestService = jasmine.createSpyObj('requestService', {
'generateRequestId': 'client/1234',
'send': '',
});
searchConfigurationService = new SearchConfigurationServiceStub();

await TestBed.configureTestingModule({
imports: [TranslateModule.forRoot(), AdminNotifyIncomingComponent],
providers: [
{ provide: SEARCH_CONFIG_SERVICE, useValue: SearchConfigurationService },
{ provide: RouteService, useValue: routeServiceStub },
{ provide: ActivatedRoute, useValue: new MockActivatedRoute() },
{ provide: HALEndpointService, useValue: halService },
{ provide: RequestService, useValue: requestService },
{ provide: RemoteDataBuildService, useValue: rdbService },
{ provide: APP_DATA_SERVICES_MAP, useValue: {} },
provideMockStore({}),
imports: [
AdminNotifyIncomingComponent,
RouterModule.forRoot([]),
TranslateModule.forRoot(),
],
}).overrideProvider(SEARCH_CONFIG_SERVICE, {
useValue: searchConfigurationService,
}).overrideComponent(AdminNotifyIncomingComponent, {
remove: { imports: [AdminNotifyLogsResultComponent] },
})
.compileComponents();
}).compileComponents();

fixture = TestBed.createComponent(AdminNotifyIncomingComponent);
component = fixture.componentInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,41 @@ import {
ActivatedRoute,
Router,
} from '@angular/router';
import { provideMockStore } from '@ngrx/store/testing';
import { TranslateModule } from '@ngx-translate/core';

import { APP_DATA_SERVICES_MAP } from '../../../../../config/app-config.interface';
import { RemoteDataBuildService } from '../../../../core/cache/builders/remote-data-build.service';
import { ObjectCacheService } from '../../../../core/cache/object-cache.service';
import { RequestService } from '../../../../core/data/request.service';
import { RouteService } from '../../../../core/services/route.service';
import { HALEndpointService } from '../../../../core/shared/hal-endpoint.service';
import { SEARCH_CONFIG_SERVICE } from '../../../../my-dspace-page/my-dspace-configuration.service';
import { MockActivatedRoute } from '../../../../shared/mocks/active-router.mock';
import { SearchLabelsComponent } from '../../../../shared/search/search-labels/search-labels.component';
import { ThemedSearchComponent } from '../../../../shared/search/themed-search.component';
import { routeServiceStub } from '../../../../shared/testing/route-service.stub';
import { RouterStub } from '../../../../shared/testing/router.stub';
import { SearchConfigurationServiceStub } from '../../../../shared/testing/search-configuration-service.stub';
import { AdminNotifyLogsResultComponent } from './admin-notify-logs-result.component';

describe('AdminNotifyLogsResultComponent', () => {
let component: AdminNotifyLogsResultComponent;
let fixture: ComponentFixture<AdminNotifyLogsResultComponent>;
let objectCache: ObjectCacheService;
let requestService: RequestService;
let halService: HALEndpointService;
let rdbService: RemoteDataBuildService;

let searchConfigurationService: SearchConfigurationServiceStub;

beforeEach(async () => {
searchConfigurationService = new SearchConfigurationServiceStub();

await TestBed.configureTestingModule({
imports: [TranslateModule.forRoot(), AdminNotifyLogsResultComponent],
providers: [
{ provide: RouteService, useValue: routeServiceStub },
{ provide: Router, useValue: new RouterStub() },
{ provide: ActivatedRoute, useValue: new MockActivatedRoute() },
{ provide: HALEndpointService, useValue: halService },
{ provide: ObjectCacheService, useValue: objectCache },
{ provide: RequestService, useValue: requestService },
{ provide: APP_DATA_SERVICES_MAP, useValue: {} },
{ provide: RemoteDataBuildService, useValue: rdbService },
provideMockStore({}),
],
})
.overrideComponent(AdminNotifyLogsResultComponent, {
remove: {
imports: [
SearchLabelsComponent,
ThemedSearchComponent,
],
},
})
.compileComponents();
}).overrideProvider(SEARCH_CONFIG_SERVICE, {
useValue: searchConfigurationService,
}).overrideComponent(AdminNotifyLogsResultComponent, {
remove: {
imports: [
SearchLabelsComponent,
ThemedSearchComponent,
],
},
}).compileComponents();

fixture = TestBed.createComponent(AdminNotifyLogsResultComponent);
component = fixture.componentInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
NgIf,
} from '@angular/common';
import {
ChangeDetectorRef,
Component,
Inject,
Input,
Expand Down Expand Up @@ -59,10 +58,11 @@ export class AdminNotifyLogsResultComponent implements OnInit {

protected readonly context = Context.CoarNotify;

constructor(@Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService,
private router: Router,
private route: ActivatedRoute,
protected cdRef: ChangeDetectorRef) {
constructor(
@Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService,
protected router: Router,
protected route: ActivatedRoute,
) {
}

ngOnInit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,34 @@ import {
ComponentFixture,
TestBed,
} from '@angular/core/testing';
import { ActivatedRoute } from '@angular/router';
import { provideMockStore } from '@ngrx/store/testing';
import { RouterModule } from '@angular/router';
import { TranslateModule } from '@ngx-translate/core';

import { APP_DATA_SERVICES_MAP } from '../../../../../config/app-config.interface';
import { RemoteDataBuildService } from '../../../../core/cache/builders/remote-data-build.service';
import { RequestService } from '../../../../core/data/request.service';
import { RouteService } from '../../../../core/services/route.service';
import { HALEndpointService } from '../../../../core/shared/hal-endpoint.service';
import { SearchConfigurationService } from '../../../../core/shared/search/search-configuration.service';
import { SEARCH_CONFIG_SERVICE } from '../../../../my-dspace-page/my-dspace-configuration.service';
import { MockActivatedRoute } from '../../../../shared/mocks/active-router.mock';
import { getMockRemoteDataBuildService } from '../../../../shared/mocks/remote-data-build.service.mock';
import { routeServiceStub } from '../../../../shared/testing/route-service.stub';
import { SearchConfigurationServiceStub } from '../../../../shared/testing/search-configuration-service.stub';
import { AdminNotifyLogsResultComponent } from '../admin-notify-logs-result/admin-notify-logs-result.component';
import { AdminNotifyOutgoingComponent } from './admin-notify-outgoing.component';

describe('AdminNotifyOutgoingComponent', () => {
let component: AdminNotifyOutgoingComponent;
let fixture: ComponentFixture<AdminNotifyOutgoingComponent>;
let halService: HALEndpointService;
let requestService: RequestService;
let rdbService: RemoteDataBuildService;

let searchConfigurationService: SearchConfigurationServiceStub;

beforeEach(async () => {
rdbService = getMockRemoteDataBuildService();
requestService = jasmine.createSpyObj('requestService', {
'generateRequestId': 'client/1234',
'send': '',
});
halService = jasmine.createSpyObj('halService', {
'getRootHref': '/api',
});
searchConfigurationService = new SearchConfigurationServiceStub();

await TestBed.configureTestingModule({
imports: [TranslateModule.forRoot()],
providers: [
{ provide: SEARCH_CONFIG_SERVICE, useValue: SearchConfigurationService },
{ provide: APP_DATA_SERVICES_MAP, useValue: {} },
{ provide: RouteService, useValue: routeServiceStub },
{ provide: ActivatedRoute, useValue: new MockActivatedRoute() },
{ provide: HALEndpointService, useValue: halService },
{ provide: RequestService, useValue: requestService },
{ provide: RemoteDataBuildService, useValue: rdbService },
provideMockStore({}),
imports: [
AdminNotifyOutgoingComponent,
RouterModule.forRoot([]),
TranslateModule.forRoot(),
],
})
.overrideComponent(AdminNotifyOutgoingComponent, {
remove: { imports: [AdminNotifyLogsResultComponent] },
})
.compileComponents();
}).overrideProvider(SEARCH_CONFIG_SERVICE, {
useValue: searchConfigurationService,
}).overrideComponent(AdminNotifyOutgoingComponent, {
remove: { imports: [AdminNotifyLogsResultComponent] },
}).compileComponents();

fixture = TestBed.createComponent(AdminNotifyOutgoingComponent);
component = fixture.componentInstance;
Expand Down
Loading

0 comments on commit 6c4ff40

Please sign in to comment.