Skip to content

Commit

Permalink
fix(api-form): only compute url if the endpoint is ready
Browse files Browse the repository at this point in the history
  • Loading branch information
jahow authored and cmoinier committed May 31, 2024
1 parent de6c18f commit 0681561
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TestBed, ComponentFixture } from '@angular/core/testing'
import { ComponentFixture, TestBed } from '@angular/core/testing'
import { RecordApiFormComponent } from './record-api-form.component'
import { DatasetServiceDistribution } from '@geonetwork-ui/common/domain/model/record'
import { firstValueFrom } from 'rxjs'
Expand All @@ -15,8 +15,8 @@ const mockDatasetServiceDistribution: DatasetServiceDistribution = {
jest.mock('@camptocamp/ogc-client', () => ({
OgcApiEndpoint: class {
constructor(private url) {}
get featureCollections() {
return Promise.resolve(['feature1'])
get allCollections() {
return Promise.resolve([{ name: 'feature1' }])
}
getCollectionInfo(collectionId) {
return Promise.resolve({
Expand Down Expand Up @@ -66,7 +66,7 @@ jest.mock('@camptocamp/ogc-client', () => ({
},
}))

describe('RecordApFormComponent', () => {
describe('RecordApiFormComponent', () => {
let component: RecordApiFormComponent
let fixture: ComponentFixture<RecordApiFormComponent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
ServiceProtocol,
} from '@geonetwork-ui/common/domain/model/record'
import { mimeTypeToFormat } from '@geonetwork-ui/util/shared'
import { BehaviorSubject, combineLatest, map, switchMap } from 'rxjs'
import { BehaviorSubject, combineLatest, filter, map, switchMap } from 'rxjs'

const DEFAULT_PARAMS = {
OFFSET: '',
Expand Down Expand Up @@ -54,7 +54,8 @@ export class RecordApiFormComponent {
this.offset$,
this.limit$,
this.format$,
this.endpoint$,
// only compute the url if the endpoint was created
this.endpoint$.pipe(filter((endpoint) => !!endpoint)),
]).pipe(
switchMap(([offset, limit, format]) =>
this.generateApiQueryUrl(offset, limit, format)
Expand Down

0 comments on commit 0681561

Please sign in to comment.