Spaces:
Paused
Paused
| /** | |
| * 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(); | |