Nanny7's picture
initial deploy
bcf46c3
Raw
History Blame Contribute Delete
1.49 kB
/**
* 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();