// Upsert a customer row with TEST_PHONE + DISPLAY_NAME via the dev-only
// /internal/_test/seed-customer endpoint. Used by TS-07 to set up the
// "returning user already has a name" precondition, so the OTP sign-in
// path can verify the set-name screen is skipped for existing identified
// customers.
const phone = TEST_PHONE
const displayName = DISPLAY_NAME
const url = BACKEND_INTERNAL_URL || 'http://localhost:3001'
if (!phone) throw new Error('TEST_PHONE env not set')
if (!displayName) throw new Error('DISPLAY_NAME env not set')
const resp = http.post(`${url}/internal/_test/seed-customer`, {
  body: JSON.stringify({ phone, display_name: displayName }),
  headers: { 'Content-Type': 'application/json' },
})
if (resp.status !== 200) {
  throw new Error(`seed-customer failed (${resp.status}): ${resp.body}`)
}
const data = json(resp.body)
output.CUSTOMER_ID = data.id
output.CUSTOMER_DISPLAY_NAME = data.display_name
