import { http } from 'msw'
import { jsonResponse } from '../helpers'

// OpenWeatherMap stand-in for the fast profile. The e2e profile uses
// `e2e/stubs/owm/` (Docker). Both must return the same shape so tests
// targeting the wind-compute path (E10) behave identically.

export const owmHandlers = [
  // The production code is expected to call OWM through a configurable base URL
  // (default = api.openweathermap.org); the route-abort guard in the e2e
  // profile blocks that host, but tests under fast hit the path-only form so
  // MSW intercepts.
  http.get('https://api.openweathermap.org/data/2.5/weather', () =>
    jsonResponse({ wind: { speed: 5.0, deg: 270 }, name: 'TestCity' }),
  ),

  http.get('http://owm-stub:8081/data/2.5/weather', () =>
    jsonResponse({ wind: { speed: 5.0, deg: 270 }, name: 'TestCity' }),
  ),

  http.get('/owm/data/2.5/weather', () =>
    jsonResponse({ wind: { speed: 5.0, deg: 270 }, name: 'TestCity' }),
  ),
]
