admin/scripts/smoke-test.mjs
alisaza e1eaf5eff5 feat: initial ghabilee-admin backoffice app
Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js
app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
2026-09-05 13:12:59 +03:30

23 lines
923 B
JavaScript

const baseUrl = (process.env.SMOKE_BASE_URL || 'http://127.0.0.1:3000').replace(/\/$/, '')
const checks = [
{ path: '/robots.txt', status: 200 },
{ path: '/auth', status: 200, contains: '<html' },
{ path: '/manifest.webmanifest', status: 200 },
{ path: '/offline.html', status: 200, contains: 'اتصال اینترنت برقرار نیست' },
{ path: '/health', status: 200 },
{ path: '/api/v1/events?page=1&pageSize=5', status: 200, contains: '"' },
]
for (const check of checks) {
const response = await fetch(`${baseUrl}${check.path}`, { redirect: 'manual', signal: AbortSignal.timeout(15_000) })
const body = await response.text()
if (response.status !== check.status || (check.contains && !body.includes(check.contains))) {
throw new Error(`Smoke check failed: ${check.path} returned ${response.status}`)
}
console.log(`${check.path}`)
}
console.log(`Smoke OK against ${baseUrl}`)