// Force a specific mitra ONLINE in mitra_online_status.
// Used by scenario flows that need to simulate "mitra was ONLINE before
// they last logged out" so the next login lands on BestieHome (online variant).
//
// Required env: MITRA_ID  (typically from output.MITRA_ID after seed_mitra)
// Optional env: BACKEND_INTERNAL_URL  (defaults to localhost:3001)

const url = (BACKEND_INTERNAL_URL || 'http://localhost:3001') + '/internal/_test/force-mitra-online'
const resp = http.post(url, {
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ mitra_id: MITRA_ID }),
})
if (resp.status !== 200) {
  throw new Error(`force-mitra-online failed (${resp.status}): ${resp.body}`)
}
const data = json(resp.body)
console.log('force_mitra_online:', JSON.stringify(data))
