/** * Smoke test for PhishVision /api/phish-detect * Tests the Playwright pipeline ONLY (skips AI call by checking early output). * Run with: node test-phish.js */ const http = require("http"); const payload = JSON.stringify({ url: "https://example.com" }); const options = { hostname: "127.0.0.1", port: 3001, path: "/api/phish-detect", method: "POST", headers: { "Content-Type": "application/json", "Content-Length": Buffer.byteLength(payload), }, // 45 second timeout — Playwright needs time to launch + screenshot timeout: 45000, }; console.log("šŸ” Sending POST /api/phish-detect with url: https://example.com ..."); console.log("ā³ (Playwright will launch headless Chromium — allow ~10s)\n"); const req = http.request(options, (res) => { let data = ""; res.on("data", (chunk) => (data += chunk)); res.on("end", () => { console.log("HTTP Status:", res.statusCode); try { const parsed = JSON.parse(data); console.log("\nāœ… Response JSON:\n", JSON.stringify(parsed, null, 2)); } catch { // If AI key is invalid, we'll get an error — but Playwright worked if we got here console.log("\nšŸ“¦ Raw response (AI step may have failed — expected without valid key):\n", data); } }); }); req.on("timeout", () => { console.error("āŒ Request timed out after 45s"); req.destroy(); }); req.on("error", (e) => { console.error("āŒ Request error:", e.message); }); req.write(payload); req.end();