import { describe, it, expect } from 'vitest'; import { SELF } from 'cloudflare:test'; import { healthRouter } from '../src/routes/health'; import type { Bindings, ExecutionContext } from '../src/types'; describe('GET /health — bundle_version 欄位', () => { it('無 ARCRUN_BUNDLE_VERSION 時回空字串(老實例情境)', async () => { // wrangler.test.toml 不設此 var → 走 ?? '' fallback const res = await SELF.fetch('http://localhost/health'); const data = await res.json() as { ok: boolean; bundle_version: string }; expect(res.status).toBe(200); expect(data.ok).toBe(true); expect(data.bundle_version).toBe(''); }); it('有 ARCRUN_BUNDLE_VERSION 時回其值(安裝器注入情境)', async () => { const fakeEnv = { ARCRUN_BUNDLE_VERSION: '2026-07-28/6d06162' } as unknown as Bindings; const res = await healthRouter.fetch( new Request('http://localhost/health'), fakeEnv, {} as ExecutionContext, ); const data = await res.json() as { ok: boolean; bundle_version: string }; expect(data.ok).toBe(true); expect(data.bundle_version).toBe('2026-07-28/6d06162'); }); });