Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
Romuald Caplier committed Sep 20, 2024
1 parent a9f0fae commit 0772493
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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(() => {
Expand All @@ -70,7 +53,6 @@ describe('AllRecordsComponent', () => {
ActivatedRoute,
SearchService
),
MockProvider(Overlay, overlayMock, 'useValue'),
],
}).overrideComponent(AllRecordsComponent, {
set: {
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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',
Expand Down Expand Up @@ -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<any>
private overlayRef!: OverlayRef

searchText$: Observable<string | null> =
this.searchFacade.searchFilters$.pipe(
map((filters) => ('any' in filters ? (filters['any'] as string) : null))
)
searchText$: Observable<string | null> = of(null)

isImportMenuOpen = false

Expand All @@ -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'] ?? ''
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 0772493

Please sign in to comment.