diff --git a/apps/metadata-editor/src/app/records/all-records/all-records.component.spec.ts b/apps/metadata-editor/src/app/records/all-records/all-records.component.spec.ts index 2b6145eae5..a1bc98c57d 100644 --- a/apps/metadata-editor/src/app/records/all-records/all-records.component.spec.ts +++ b/apps/metadata-editor/src/app/records/all-records/all-records.component.spec.ts @@ -14,8 +14,8 @@ import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform. import { MockBuilder, MockInstance, - MockProvider, MockProviders, + NG_MOCKS_ROOT_PROVIDERS, } from 'ng-mocks' import { EditorRouterService } from '../../router.service' import { Overlay } from '@angular/cdk/overlay' @@ -35,27 +35,10 @@ describe('AllRecordsComponent', () => { let platformService: PlatformServiceInterface let fieldsService: FieldsService - const overlayRefMock = { - attach: jest.fn(), - backdropClick: jest.fn().mockReturnValue(of()), - dispose: jest.fn(), - } - - const positionStrategyMock = { - flexibleConnectedTo: jest.fn().mockReturnThis(), - withPositions: jest.fn().mockReturnThis(), - } - - const overlayMock = { - position: jest.fn().mockReturnValue(positionStrategyMock), - create: jest.fn().mockReturnValue(overlayRefMock), - scrollStrategies: { - reposition: jest.fn(), - }, - } - beforeEach(() => { return MockBuilder(AllRecordsComponent) + .keep(Overlay) + .keep(NG_MOCKS_ROOT_PROVIDERS) }) beforeEach(() => { @@ -70,7 +53,6 @@ describe('AllRecordsComponent', () => { ActivatedRoute, SearchService ), - MockProvider(Overlay, overlayMock, 'useValue'), ], }).overrideComponent(AllRecordsComponent, { set: { @@ -114,7 +96,6 @@ describe('AllRecordsComponent', () => { ) ) - // searchFacade.searchFilters$ = new BehaviorSubject({ any: 'scot' }) searchFacade.resetSearch = jest.fn(() => this) searchFacade.updateFilters = jest.fn(() => this) searchFacade.setFilters = jest.fn(() => this) diff --git a/apps/metadata-editor/src/app/records/all-records/all-records.component.ts b/apps/metadata-editor/src/app/records/all-records/all-records.component.ts index f015834cbd..cd1412b1e2 100644 --- a/apps/metadata-editor/src/app/records/all-records/all-records.component.ts +++ b/apps/metadata-editor/src/app/records/all-records/all-records.component.ts @@ -14,10 +14,9 @@ import { SearchService, } from '@geonetwork-ui/feature/search' import { TranslateModule } from '@ngx-translate/core' -import { map } from 'rxjs/operators' import { ActivatedRoute, Router } from '@angular/router' import { RecordsCountComponent } from '../records-count/records-count.component' -import { Observable } from 'rxjs' +import { Observable, of } from 'rxjs' import { UiElementsModule } from '@geonetwork-ui/ui/elements' import { UiInputsModule } from '@geonetwork-ui/ui/inputs' import { MatIconModule } from '@angular/material/icon' @@ -30,6 +29,7 @@ import { import { TemplatePortal } from '@angular/cdk/portal' import { ImportRecordComponent } from '@geonetwork-ui/feature/editor' import { RecordsListComponent } from '../records-list.component' +import { map } from 'rxjs/operators' export const allSearchFields = [ 'uuid', @@ -64,14 +64,11 @@ export const allSearchFields = [ }) export class AllRecordsComponent implements OnInit { @ViewChild('importRecordButton', { read: ElementRef }) - private importRecordButton!: ElementRef + importRecordButton!: ElementRef @ViewChild('template') template!: TemplateRef private overlayRef!: OverlayRef - searchText$: Observable = - this.searchFacade.searchFilters$.pipe( - map((filters) => ('any' in filters ? (filters['any'] as string) : null)) - ) + searchText$: Observable = of(null) isImportMenuOpen = false @@ -86,6 +83,10 @@ export class AllRecordsComponent implements OnInit { ) {} ngOnInit(): void { + this.searchText$ = this.searchFacade.searchFilters$.pipe( + map((filters) => ('any' in filters ? (filters['any'] as string) : null)) + ) + this.searchFacade.resetSearch() const searchTerms = this.activedRoute.snapshot.queryParams['q'] ?? '' @@ -119,8 +120,6 @@ export class AllRecordsComponent implements OnInit { duplicateExternalRecord() { this.isImportMenuOpen = true - console.log(this.overlay) - const positionStrategy = this.overlay .position() .flexibleConnectedTo(this.importRecordButton)