Spaces:
Paused
Paused
File size: 1,486 Bytes
bcf46c3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | /**
* 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();
|