Skip to content

Commit

Permalink
refactor(data.service): adapt tests to refactoring
Browse files Browse the repository at this point in the history
also add fixture to test that erroneous OGC API does not break download list
and seperate generic OGC API error message from WFS messages
  • Loading branch information
tkohr committed May 17, 2024
1 parent 62c6e68 commit 53b7078
Show file tree
Hide file tree
Showing 11 changed files with 95 additions and 141 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ class DataServiceMock {
])
getDownloadLinksFromOgcApiFeatures = jest.fn((link) =>
link.url.toString().indexOf('error') > -1
? throwError(() => new Error('would not fetch links'))
: of([
? Promise.reject(new Error('ogc.unreachable.unknown'))
: Promise.resolve([
{
...link,
mimeType: 'application/geo+json',
Expand Down Expand Up @@ -233,6 +233,13 @@ describe('DataDownloadsComponent', () => {
type: 'service',
accessServiceProtocol: 'ogcFeatures',
},
{
name: 'Some erroneous OGC API service',
description: 'OGC API service',
url: newUrl('https://error.org/collections/airports/items'),
type: 'service',
accessServiceProtocol: 'ogcFeatures',
},
])
fixture.detectChanges()
})
Expand Down
21 changes: 12 additions & 9 deletions libs/feature/dataviz/src/lib/service/data.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -492,15 +492,18 @@ describe('DataService', () => {
})
})
describe('calling getDownloadLinksFromOgcApiFeatures() with a erroneous URL', () => {
it('returns empty list of links', async () => {
const url = new URL('http://error.http/ogcapi')
const links = await service.getDownloadLinksFromOgcApiFeatures({
name: 'mycollection',
url,
type: 'service',
accessServiceProtocol: 'ogcFeatures',
})
expect(links).toEqual([])
it('returns an error', async () => {
try {
const url = new URL('http://error.http/ogcapi')
await service.getDownloadLinksFromOgcApiFeatures({
name: 'mycollection',
url,
type: 'service',
accessServiceProtocol: 'ogcFeatures',
})
} catch (e) {
expect(e.message).toBe('ogc.unreachable.unknown')
}
})
})
})
Expand Down
20 changes: 2 additions & 18 deletions libs/feature/dataviz/src/lib/service/data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ marker('wfs.unreachable.http')
marker('wfs.unreachable.unknown')
marker('wfs.featuretype.notfound')
marker('wfs.geojsongml.notsupported')
marker('ogc.unreachable.unknown')
marker('dataset.error.network')
marker('dataset.error.http')
marker('dataset.error.parse')
Expand Down Expand Up @@ -178,24 +179,7 @@ export class DataService {
return endpoint.getCollectionInfo(collections[0])
})
.catch((error) => {
if (error instanceof Error) {
throw new Error(`wfs.unreachable.unknown`)
} else {
if (error.type === 'network') {
throw new Error(`wfs.unreachable.cors`)
}
if (error.type === 'http') {
throw new Error(`wfs.unreachable.http`)
}
if (error.type === 'parse') {
throw new Error(`wfs.unreachable.parse`)
}
if (error.type === 'unsupportedType') {
throw new Error(`wfs.unreachable.unsupportedType`)
} else {
throw new Error(`wfs.unreachable.unknown`)
}
}
throw new Error(`ogc.unreachable.unknown`)
})
}

Expand Down
23 changes: 9 additions & 14 deletions translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
"multiselect.filter.placeholder": "Suche",
"nav.back": "Zurück",
"next": "weiter",
"ogc.unreachable.unknown": "Der Dienst konnte nicht erreicht werden",
"organisation.filter.placeholder": "Ergebnisse filtern",
"organisation.sort.sortBy": "Sortieren nach:",
"organisations.hits.found": "{hits, plural, =0{Keine Organisation gefunden} other{{hits} von {total} Organisationen angezeigt}}",
Expand Down Expand Up @@ -290,14 +291,6 @@
"record.metadata.quality.updateFrequency.failed": "Aktualisierungsfrequenz nicht angegeben",
"record.metadata.quality.updateFrequency.success": "Aktualisierungsfrequenz angegeben",
"record.metadata.related": "Ähnliche Datensätze",
"record.metadata.userFeedbacks": "",
"record.metadata.userFeedbacks.anonymousUser": "",
"record.metadata.userFeedbacks.sortSelector.label": "",
"record.metadata.userFeedbacks.sortSelector.choices.newestFirst": "",
"record.metadata.userFeedbacks.sortSelector.choices.oldestFirst": "",
"record.metadata.userFeedbacks.newComment.placeholder": "",
"record.metadata.userFeedbacks.newAnswer.placeholder": "",
"record.metadata.userFeedbacks.newAnswer.buttonTitle": "",
"record.metadata.sheet": "Weitere Informationen verfügbar unter:",
"record.metadata.status": "Status",
"record.metadata.technical": "Technische Informationen",
Expand All @@ -312,6 +305,14 @@
"record.metadata.updateFrequency": "Aktualisierungsfrequenz der Daten",
"record.metadata.updatedOn": "Letzte Aktualisierung der Dateninformationen",
"record.metadata.usage": "Nutzung und Einschränkungen",
"record.metadata.userFeedbacks": "",
"record.metadata.userFeedbacks.anonymousUser": "",
"record.metadata.userFeedbacks.newAnswer.buttonTitle": "",
"record.metadata.userFeedbacks.newAnswer.placeholder": "",
"record.metadata.userFeedbacks.newComment.placeholder": "",
"record.metadata.userFeedbacks.sortSelector.choices.newestFirst": "",
"record.metadata.userFeedbacks.sortSelector.choices.oldestFirst": "",
"record.metadata.userFeedbacks.sortSelector.label": "",
"record.more.details": "Weitere Details",
"record.tab.chart": "Diagramm",
"record.tab.data": "Tabelle",
Expand Down Expand Up @@ -371,12 +372,6 @@
"table.loading.data": "Daten werden geladen...",
"table.object.count": "Objekte in diesem Datensatz",
"table.select.data": "Datenquelle",
"timeSincePipe.lessThanAMinute": "",
"timeSincePipe.minutesAgo": "",
"timeSincePipe.hoursAgo": "",
"timeSincePipe.daysAgo": "",
"timeSincePipe.monthsAgo": "",
"timeSincePipe.yearsAgo": "",
"tooltip.html.copy": "HTML kopieren",
"tooltip.id.copy": "Eindeutige Kennung kopieren",
"tooltip.url.copy": "URL kopieren",
Expand Down
23 changes: 9 additions & 14 deletions translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
"multiselect.filter.placeholder": "Search",
"nav.back": "Back",
"next": "next",
"ogc.unreachable.unknown": "The service could not be reached",
"organisation.filter.placeholder": "Filter results",
"organisation.sort.sortBy": "Sort by:",
"organisations.hits.found": "{hits, plural, =0{No organizations found} other{{hits} out of {total} organizations shown}}",
Expand Down Expand Up @@ -290,14 +291,6 @@
"record.metadata.quality.updateFrequency.failed": "Update frequency is not specified",
"record.metadata.quality.updateFrequency.success": "Update frequency is specified",
"record.metadata.related": "Related records",
"record.metadata.userFeedbacks": "Questions / Answers",
"record.metadata.userFeedbacks.anonymousUser": "In order to leave a comment, please log in.",
"record.metadata.userFeedbacks.sortSelector.label": "Sort by ...",
"record.metadata.userFeedbacks.sortSelector.choices.newestFirst": "Newest comments first",
"record.metadata.userFeedbacks.sortSelector.choices.oldestFirst": "Oldest comments first",
"record.metadata.userFeedbacks.newComment.placeholder": "Write your comment here...",
"record.metadata.userFeedbacks.newAnswer.placeholder": "Answer...",
"record.metadata.userFeedbacks.newAnswer.buttonTitle": "Publish",
"record.metadata.sheet": "Original metadata",
"record.metadata.status": "Status",
"record.metadata.technical": "Technical information",
Expand All @@ -312,6 +305,14 @@
"record.metadata.updateFrequency": "Data Update Frequency",
"record.metadata.updatedOn": "Last Data Information Update",
"record.metadata.usage": "License and Conditions",
"record.metadata.userFeedbacks": "Questions / Answers",
"record.metadata.userFeedbacks.anonymousUser": "In order to leave a comment, please log in.",
"record.metadata.userFeedbacks.newAnswer.buttonTitle": "Publish",
"record.metadata.userFeedbacks.newAnswer.placeholder": "Answer...",
"record.metadata.userFeedbacks.newComment.placeholder": "Write your comment here...",
"record.metadata.userFeedbacks.sortSelector.choices.newestFirst": "Newest comments first",
"record.metadata.userFeedbacks.sortSelector.choices.oldestFirst": "Oldest comments first",
"record.metadata.userFeedbacks.sortSelector.label": "Sort by ...",
"record.more.details": "Read more",
"record.tab.chart": "Chart",
"record.tab.data": "Table",
Expand Down Expand Up @@ -371,12 +372,6 @@
"table.loading.data": "Loading data...",
"table.object.count": "objects in this dataset",
"table.select.data": "Data source",
"timeSincePipe.lessThanAMinute": "Less than a minute ago",
"timeSincePipe.minutesAgo": "{value} minute{s} ago",
"timeSincePipe.hoursAgo": "{value} hour{s} ago",
"timeSincePipe.daysAgo": "{value} day{s} ago",
"timeSincePipe.monthsAgo": "{value} month{s} ago",
"timeSincePipe.yearsAgo": "{value} year{s} ago",
"tooltip.html.copy": "Copy HTML",
"tooltip.id.copy": "Copy unique identifier",
"tooltip.url.copy": "Copy URL",
Expand Down
23 changes: 9 additions & 14 deletions translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
"multiselect.filter.placeholder": "",
"nav.back": "",
"next": "",
"ogc.unreachable.unknown": "",
"organisation.filter.placeholder": "",
"organisation.sort.sortBy": "",
"organisations.hits.found": "",
Expand Down Expand Up @@ -290,14 +291,6 @@
"record.metadata.quality.updateFrequency.failed": "",
"record.metadata.quality.updateFrequency.success": "",
"record.metadata.related": "",
"record.metadata.userFeedbacks": "",
"record.metadata.userFeedbacks.anonymousUser": "",
"record.metadata.userFeedbacks.sortSelector.label": "",
"record.metadata.userFeedbacks.sortSelector.choices.newestFirst": "",
"record.metadata.userFeedbacks.sortSelector.choices.oldestFirst": "",
"record.metadata.userFeedbacks.newComment.placeholder": "",
"record.metadata.userFeedbacks.newAnswer.placeholder": "",
"record.metadata.userFeedbacks.newAnswer.buttonTitle": "",
"record.metadata.sheet": "",
"record.metadata.status": "",
"record.metadata.technical": "",
Expand All @@ -312,6 +305,14 @@
"record.metadata.updateFrequency": "",
"record.metadata.updatedOn": "",
"record.metadata.usage": "",
"record.metadata.userFeedbacks": "",
"record.metadata.userFeedbacks.anonymousUser": "",
"record.metadata.userFeedbacks.newAnswer.buttonTitle": "",
"record.metadata.userFeedbacks.newAnswer.placeholder": "",
"record.metadata.userFeedbacks.newComment.placeholder": "",
"record.metadata.userFeedbacks.sortSelector.choices.newestFirst": "",
"record.metadata.userFeedbacks.sortSelector.choices.oldestFirst": "",
"record.metadata.userFeedbacks.sortSelector.label": "",
"record.more.details": "",
"record.tab.chart": "",
"record.tab.data": "",
Expand Down Expand Up @@ -371,12 +372,6 @@
"table.loading.data": "",
"table.object.count": "",
"table.select.data": "",
"timeSincePipe.lessThanAMinute": "",
"timeSincePipe.minutesAgo": "",
"timeSincePipe.hoursAgo": "",
"timeSincePipe.daysAgo": "",
"timeSincePipe.monthsAgo": "",
"timeSincePipe.yearsAgo": "",
"tooltip.html.copy": "",
"tooltip.id.copy": "",
"tooltip.url.copy": "",
Expand Down
23 changes: 9 additions & 14 deletions translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
"multiselect.filter.placeholder": "Rechercher",
"nav.back": "Retour",
"next": "suivant",
"ogc.unreachable.unknown": "Le service n'est pas accessible",
"organisation.filter.placeholder": "Filtrer les résultats",
"organisation.sort.sortBy": "Trier par :",
"organisations.hits.found": "{hits, plural, =0{Aucune organisation trouvé} one{1 organisation sur {total} affichée} other{{hits} organisations sur {total} affichées}}",
Expand Down Expand Up @@ -290,14 +291,6 @@
"record.metadata.quality.updateFrequency.failed": "Fréquence de mise à jour n'est pas renseignée",
"record.metadata.quality.updateFrequency.success": "Fréquence de mise à jour est renseignée",
"record.metadata.related": "Voir aussi",
"record.metadata.userFeedbacks": "Questions / Réponses",
"record.metadata.userFeedbacks.anonymousUser": "Pour rédiger un commentaire, veuillez vous identifier.",
"record.metadata.userFeedbacks.sortSelector.label": "Trier par ...",
"record.metadata.userFeedbacks.sortSelector.choices.newestFirst": "Les plus récents en premier",
"record.metadata.userFeedbacks.sortSelector.choices.oldestFirst": "Les plus anciens en premier",
"record.metadata.userFeedbacks.newComment.placeholder": "Rédiger votre commentaire ici...",
"record.metadata.userFeedbacks.newAnswer.placeholder": "Répondre...",
"record.metadata.userFeedbacks.newAnswer.buttonTitle": "Publier",
"record.metadata.sheet": "Fiche de métadonnées d'origine",
"record.metadata.status": "Statut",
"record.metadata.technical": "Informations techniques",
Expand All @@ -312,6 +305,14 @@
"record.metadata.updateFrequency": "Fréquence de mise à jour des données",
"record.metadata.updatedOn": "Dernière mise à jour des informations sur les données",
"record.metadata.usage": "Licences et conditions d'utilisation",
"record.metadata.userFeedbacks": "Questions / Réponses",
"record.metadata.userFeedbacks.anonymousUser": "Pour rédiger un commentaire, veuillez vous identifier.",
"record.metadata.userFeedbacks.newAnswer.buttonTitle": "Publier",
"record.metadata.userFeedbacks.newAnswer.placeholder": "Répondre...",
"record.metadata.userFeedbacks.newComment.placeholder": "Rédiger votre commentaire ici...",
"record.metadata.userFeedbacks.sortSelector.choices.newestFirst": "Les plus récents en premier",
"record.metadata.userFeedbacks.sortSelector.choices.oldestFirst": "Les plus anciens en premier",
"record.metadata.userFeedbacks.sortSelector.label": "Trier par ...",
"record.more.details": "Détails",
"record.tab.chart": "Graphique",
"record.tab.data": "Tableau",
Expand Down Expand Up @@ -371,12 +372,6 @@
"table.loading.data": "Chargement des données...",
"table.object.count": "enregistrements dans ces données",
"table.select.data": "Source de données",
"timeSincePipe.lessThanAMinute": "Il y a moins d'une minute",
"timeSincePipe.minutesAgo": "Il y a {value} minute{s}",
"timeSincePipe.hoursAgo": "Il y a {value} heure{s}",
"timeSincePipe.daysAgo": "Il y a {value} jour{s}",
"timeSincePipe.monthsAgo": "Il y a {value} mois",
"timeSincePipe.yearsAgo": "Il y a {value} an{s}",
"tooltip.html.copy": "Copier le HTML",
"tooltip.id.copy": "Copier l'identifiant unique",
"tooltip.url.copy": "Copier l'URL",
Expand Down
23 changes: 9 additions & 14 deletions translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
"multiselect.filter.placeholder": "Cerca",
"nav.back": "Indietro",
"next": "successivo",
"ogc.unreachable.unknown": "Il servizio non è accessibile",
"organisation.filter.placeholder": "Filtra i risultati",
"organisation.sort.sortBy": "Ordina per:",
"organisations.hits.found": "{hits, plural, =0{Nessuna organizzazione trovata} one{1 organizzazione su {total} visualizzata} other{{hits} organizzazioni su {total} visualizzate}}",
Expand Down Expand Up @@ -290,14 +291,6 @@
"record.metadata.quality.updateFrequency.failed": "La frequenza di aggiornamento non è specificata",
"record.metadata.quality.updateFrequency.success": "La frequenza di aggiornamento è specificata",
"record.metadata.related": "Vedi anche",
"record.metadata.userFeedbacks": "",
"record.metadata.userFeedbacks.anonymousUser": "",
"record.metadata.userFeedbacks.sortSelector.label": "",
"record.metadata.userFeedbacks.sortSelector.choices.newestFirst": "",
"record.metadata.userFeedbacks.sortSelector.choices.oldestFirst": "",
"record.metadata.userFeedbacks.newComment.placeholder": "",
"record.metadata.userFeedbacks.newAnswer.placeholder": "",
"record.metadata.userFeedbacks.newAnswer.buttonTitle": "",
"record.metadata.sheet": "Origine del metadata",
"record.metadata.status": "Stato",
"record.metadata.technical": "Informazioni tecniche",
Expand All @@ -312,6 +305,14 @@
"record.metadata.updateFrequency": "Frequenza di aggiornamento dei dati",
"record.metadata.updatedOn": "Ultimo aggiornamento delle informazioni sui dati",
"record.metadata.usage": "Licenze e limiti di utilizzo",
"record.metadata.userFeedbacks": "",
"record.metadata.userFeedbacks.anonymousUser": "",
"record.metadata.userFeedbacks.newAnswer.buttonTitle": "",
"record.metadata.userFeedbacks.newAnswer.placeholder": "",
"record.metadata.userFeedbacks.newComment.placeholder": "",
"record.metadata.userFeedbacks.sortSelector.choices.newestFirst": "",
"record.metadata.userFeedbacks.sortSelector.choices.oldestFirst": "",
"record.metadata.userFeedbacks.sortSelector.label": "",
"record.more.details": "Dettagli",
"record.tab.chart": "Grafico",
"record.tab.data": "Tabella",
Expand Down Expand Up @@ -371,12 +372,6 @@
"table.loading.data": "Caricamento dei dati...",
"table.object.count": "record in questi dati",
"table.select.data": "Sorgente dati",
"timeSincePipe.lessThanAMinute": "",
"timeSincePipe.minutesAgo": "",
"timeSincePipe.hoursAgo": "",
"timeSincePipe.daysAgo": "",
"timeSincePipe.monthsAgo": "",
"timeSincePipe.yearsAgo": "",
"tooltip.html.copy": "Copiare il HTML",
"tooltip.id.copy": "Copiare l'identificatore unico",
"tooltip.url.copy": "Copiare l'URL",
Expand Down
23 changes: 9 additions & 14 deletions translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
"multiselect.filter.placeholder": "",
"nav.back": "",
"next": "",
"ogc.unreachable.unknown": "",
"organisation.filter.placeholder": "",
"organisation.sort.sortBy": "",
"organisations.hits.found": "",
Expand Down Expand Up @@ -290,14 +291,6 @@
"record.metadata.quality.updateFrequency.failed": "",
"record.metadata.quality.updateFrequency.success": "",
"record.metadata.related": "",
"record.metadata.userFeedbacks": "",
"record.metadata.userFeedbacks.anonymousUser": "",
"record.metadata.userFeedbacks.sortSelector.label": "",
"record.metadata.userFeedbacks.sortSelector.choices.newestFirst": "",
"record.metadata.userFeedbacks.sortSelector.choices.oldestFirst": "",
"record.metadata.userFeedbacks.newComment.placeholder": "",
"record.metadata.userFeedbacks.newAnswer.placeholder": "",
"record.metadata.userFeedbacks.newAnswer.buttonTitle": "",
"record.metadata.sheet": "",
"record.metadata.status": "",
"record.metadata.technical": "",
Expand All @@ -312,6 +305,14 @@
"record.metadata.updateFrequency": "",
"record.metadata.updatedOn": "",
"record.metadata.usage": "",
"record.metadata.userFeedbacks": "",
"record.metadata.userFeedbacks.anonymousUser": "",
"record.metadata.userFeedbacks.newAnswer.buttonTitle": "",
"record.metadata.userFeedbacks.newAnswer.placeholder": "",
"record.metadata.userFeedbacks.newComment.placeholder": "",
"record.metadata.userFeedbacks.sortSelector.choices.newestFirst": "",
"record.metadata.userFeedbacks.sortSelector.choices.oldestFirst": "",
"record.metadata.userFeedbacks.sortSelector.label": "",
"record.more.details": "",
"record.tab.chart": "",
"record.tab.data": "",
Expand Down Expand Up @@ -371,12 +372,6 @@
"table.loading.data": "",
"table.object.count": "",
"table.select.data": "",
"timeSincePipe.lessThanAMinute": "",
"timeSincePipe.minutesAgo": "",
"timeSincePipe.hoursAgo": "",
"timeSincePipe.daysAgo": "",
"timeSincePipe.monthsAgo": "",
"timeSincePipe.yearsAgo": "",
"tooltip.html.copy": "",
"tooltip.id.copy": "",
"tooltip.url.copy": "",
Expand Down
Loading

0 comments on commit 53b7078

Please sign in to comment.