Skip to content

Commit

Permalink
feat: add UT and map loading while dropdown options load
Browse files Browse the repository at this point in the history
  • Loading branch information
cmoinier authored and tkohr committed Jun 25, 2024
1 parent 7eea169 commit 22bcf5f
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
8 changes: 8 additions & 0 deletions libs/common/fixtures/src/lib/records.fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,14 @@ Malgré l'attention portée à la création de ces données, il est rappelé que
description: 'Téléchargement du fichier',
mimeType: 'x-gis/x-shapefile',
},
{
type: 'service',
url: new URL('https://my-org.net/ogc'),
accessServiceProtocol: 'ogcFeatures',
name: 'ogcFeaturesSecondRecord',
description: 'This OGC service is the second part of the download',
identifierInService: 'my:featuretype',
},
],
lineage: `Document d’urbanisme numérisé conformément aux prescriptions nationales du CNIG par le Service d'Information Géographique de l'Agglomération de la Région de Compiègne.
Ce lot de données produit en 2019, a été numérisé à partir du PCI Vecteur de 2019 et contrôlé par le Service d'Information Géographique de l'Agglomération de la Région de Compiègne.`,
Expand Down
4 changes: 3 additions & 1 deletion libs/feature/record/src/lib/map-view/map-view.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,16 @@ export class MapViewComponent implements OnInit, OnDestroy {
)

dropdownChoices$ = this.compatibleMapLinks$.pipe(
tap(() => (this.loading = true)),
map((links) =>
links.length
? links.map((link, index) => ({
label: getLinkLabel(link),
value: index,
}))
: [{ label: 'No preview layer', value: 0 }]
)
),
finalize(() => (this.loading = false))
)
selectedLinkIndex$ = new BehaviorSubject(0)

Expand Down
40 changes: 40 additions & 0 deletions libs/feature/record/src/lib/state/mdview.facade.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,5 +328,45 @@ describe('MdViewFacade', () => {
tick()
expect(result).toEqual(values.a)
}))
describe('When the user switches datasets and allLinks emits again', () => {
beforeEach(() => {
store.setState({
[METADATA_VIEW_FEATURE_STATE_KEY]: {
...initialMetadataViewState,
metadata: DATASET_RECORDS[1],
},
})
})
it('should return only the last links from allLinks', fakeAsync(() => {
const values = {
a: [
{
type: 'service',
url: new URL('https://my-org.net/ogc'),
accessServiceProtocol: 'ogcFeatures',
name: 'ogcFeaturesSecondRecord',
description:
'This OGC service is the second part of the download',
identifierInService: 'my:featuretype',
},
],
}
jest.spyOn(facade.dataService, 'getItemsFromOgcApi').mockResolvedValue({
id: '123',
type: 'Feature',
time: null,
properties: {
type: '',
title: '',
},
links: [],
geometry: { type: 'MultiPolygon', coordinates: [] },
})
let result
facade.geoDataLinksWithGeometry$.subscribe((v) => (result = v))
tick()
expect(result).toEqual(values.a)
}))
})
})
})

0 comments on commit 22bcf5f

Please sign in to comment.