// Upsert a mitra with TEST_PHONE, MITRA_DISPLAY_NAME, and IS_ACTIVE. // Idempotent — safe to run on every test pass. // // Required env: TEST_PHONE, MITRA_DISPLAY_NAME // Optional env: IS_ACTIVE (defaults to "true"; pass "false" to seed an // inactive mitra for the ACCOUNT_INACTIVE flow). const phone = TEST_PHONE const displayName = MITRA_DISPLAY_NAME const isActive = (IS_ACTIVE ?? 'true') !== 'false' const url = BACKEND_INTERNAL_URL || 'http://localhost:3001' const resp = http.post(`${url}/internal/_test/seed-mitra`, { headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ phone, display_name: displayName, is_active: isActive }), }) if (resp.status !== 200) { throw new Error(`seed-mitra failed (${resp.status}): ${resp.body}`) } // Expose the upserted mitra row id so downstream scripts that need it (e.g. // force_mitra_offline.js) can pick it up via ${output.MITRA_ID} without an // extra lookup. Older flows that don't read it are unaffected. const data = json(resp.body) output.MITRA_ID = data.id