Skip to content

Commit

Permalink
Add node-red e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
timokoessler committed Dec 2, 2024
1 parent 7b86177 commit 4536137
Show file tree
Hide file tree
Showing 3 changed files with 3,943 additions and 0 deletions.
55 changes: 55 additions & 0 deletions end2end/tests/node-red.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const t = require("tap");
const { spawn } = require("child_process");
const { resolve } = require("path");
const timeout = require("../timeout");

const pathToApp = resolve(__dirname, "../../sample-apps/node-red");

t.test("it serves debug script", (t) => {
const server = spawn(`node_modules/.bin/node-red`, {
env: {
...process.env,
AIKIDO_DEBUG: "true",
AIKIDO_BLOCK: "true",
NODE_OPTIONS: "-r @aikidosec/firewall",
},
cwd: pathToApp,
});

server.on("close", () => {
t.end();
});

server.on("error", (err) => {
t.fail(err.message);
});

let stdout = "";
server.stdout.on("data", (data) => {
stdout += data.toString();
});

let stderr = "";
server.stderr.on("data", (data) => {
stderr += data.toString();
});

// Wait for the server to start
timeout(5000)
.then(() => {
return Promise.all([
fetch(`http://127.0.0.1:1880/debug/view/debug-utils.js`, {
signal: AbortSignal.timeout(5000),
}),
]);
})
.then(([script]) => {
t.equal(script.status, 200);
})
.catch((error) => {
t.fail(error.message);
})
.finally(() => {
server.kill();
});
});
Loading

0 comments on commit 4536137

Please sign in to comment.