/** * Automation reachability probe (test artifact only, NOT committed logic). * No-login smoke against the authorized intranet target. * Verifies /admin and /frontend serve HTTP<500 and render a document. * Does NOT require credentials; logged-in flows are deferred (待核实登录态). */ const { chromium } = require('@playwright/test'); const BASE = process.env.PW_BASE_URL || 'http://cfc.iwintrue.com'; async function probePath(browser, path) { const ctx = await browser.newContext(); const page = await ctx.newPage(); const out = { path, base: BASE }; try { const resp = await page.goto(BASE + path, { waitUntil: 'domcontentloaded', timeout: 30000 }); await page.waitForTimeout(2000); out.status = resp ? resp.status() : null; out.ok = resp ? resp.status() < 500 : false; out.title = String(await page.title()).slice(0, 80); out.url = page.url().slice(0, 120); out.bodyLen = (await page.content()).length; out.hasDocument = out.bodyLen > 0; } catch (e) { out.fatal = String(e && e.message ? e.message : e).slice(0, 200); out.ok = false; } finally { await ctx.close(); } return out; } (async () => { const summary = { base: BASE, ts: new Date().toISOString(), steps: {} }; const browser = await chromium.launch({ headless: true, args: ['--no-sandbox'] }); try { summary.steps.admin = await probePath(browser, '/admin'); summary.steps.frontend = await probePath(browser, '/frontend'); } catch (e) { summary.fatal = String(e && e.message ? e.message : e).slice(0, 300); } finally { await browser.close(); } const fs = require('fs'); fs.writeFileSync(__dirname + '/_automation_reachability_result.json', JSON.stringify(summary, null, 2)); console.log(JSON.stringify(summary, null, 2)); })();