Wait for the events stream to connect before posting the submit it must report

AI Assisted
This commit is contained in:
jparkerweb committed 2026-11-05 15:17:00 -08:00
1 parent 8922d2e391
commit 807b6b038c
1 file changed
+6
+6
View File
@@ -343,10 +343,15 @@ test("a stale dashboard launch says the pick is saved and how to wake the agent"
// never sent. // never sent.
test("the submitted event names the items that went", async () => { test("the submitted event names the items that went", async () => {
const port = Number(new URL(baseUrl).port); const port = Number(new URL(baseUrl).port);
// Resolved once the stream is connected: a submit posted before then is
// never delivered to it, which timed out on a slow runner.
let connected;
const open = new Promise((resolve) => (connected = resolve));
const frame = new Promise((resolve, reject) => { const frame = new Promise((resolve, reject) => {
const req = http.request( const req = http.request(
{ host: "127.0.0.1", port, path: "/events", method: "GET", headers: { cookie: cookieFor(baseUrl, token) } }, { host: "127.0.0.1", port, path: "/events", method: "GET", headers: { cookie: cookieFor(baseUrl, token) } },
(res) => { (res) => {
connected();
let buf = ""; let buf = "";
res.setEncoding("utf8"); res.setEncoding("utf8");
res.on("data", (chunk) => { res.on("data", (chunk) => {
@@ -372,6 +377,7 @@ test("the submitted event names the items that went", async () => {
req.end(); req.end();
}); });
await open;
await post("/submit", { await post("/submit", {
actions: [{ i: "__brief", type: "brief", range: "today" }], actions: [{ i: "__brief", type: "brief", range: "today" }],
reply: "Write a brief for today.", reply: "Write a brief for today.",