hypertwist/website/scripts/runtime-readiness-cli.test.mjs
2026-06-22 03:34:04 +00:00

44 lines
1.8 KiB
JavaScript

import path from 'node:path'
import { spawnSync } from 'node:child_process'
import { fileURLToPath } from 'node:url'
import { describe, expect, it } from 'vitest'
const currentFile = fileURLToPath(import.meta.url)
const websiteRoot = path.resolve(path.dirname(currentFile), '..')
const frontendProductionEnv = path.join(websiteRoot, '.env.production.example')
const serverProductionEnv = path.join(websiteRoot, 'server', '.env.production.example')
const runtimeReadinessScript = path.join(websiteRoot, 'scripts', 'check-runtime-readiness.mjs')
describe('check-runtime-readiness CLI', () => {
it('fails the real production example env files until placeholder launch values are replaced', () => {
const result = spawnSync(
process.execPath,
[
runtimeReadinessScript,
'--frontend-env',
frontendProductionEnv,
'--server-env',
serverProductionEnv,
'--skip-live-health',
'--json',
],
{
cwd: websiteRoot,
encoding: 'utf8',
},
)
expect(result.status).toBe(1)
expect(result.stderr).toBe('')
const report = JSON.parse(result.stdout)
expect(report.ok).toBe(false)
expect(report.failures).toContain('VITE_WINDOWS_DOWNLOAD_URL still contains a placeholder value.')
expect(report.failures).toContain('VITE_PADDLE_CHECKOUT_URL_OPERATOR still contains a placeholder value.')
expect(report.failures).toContain('VITE_MPL_SOURCE_URL still contains a placeholder value.')
expect(report.failures).toContain('PADDLE_WEBHOOK_SECRET still contains a placeholder value.')
expect(report.failures).toContain('PADDLE_PRODUCT_PLAN_MAP still contains a placeholder value.')
expect(report.failures).toContain('PADDLE_PRICE_PLAN_MAP still contains a placeholder value.')
})
})