Show clear offline messages for OWM weather and AI summaries.

Users see localized feedback when OpenWeatherMap or travel-day summary
features are used without connectivity, instead of generic API errors.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-03 11:43:10 +02:00
parent 8e03563f65
commit d637fbea16
10 changed files with 79 additions and 7 deletions
+11
View File
@@ -44,6 +44,17 @@ describe('fetchOpenWeatherCurrent', () => {
})
})
it('throws OFFLINE when navigator.onLine is false', async () => {
vi.stubGlobal('navigator', { ...navigator, onLine: false })
const { fetchOpenWeatherCurrent, WeatherApiError } = await import('./weather.js')
const err = await fetchOpenWeatherCurrent({ lat: '54', lon: '10' }).catch((e) => e)
expect(err).toBeInstanceOf(WeatherApiError)
expect((err as InstanceType<typeof WeatherApiError>).code).toBe('OFFLINE')
expect(apiFetch).not.toHaveBeenCalled()
})
it('does not track when the API request fails', async () => {
apiFetch.mockResolvedValue({
ok: false,