web: 'Invite someone' page with the command to join through this node

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AeFqV96dVeBX94inzcgZKw
This commit is contained in:
2026-11-19 10:43:46 +01:00
co-authored by Claude Sonnet 5.5
parent f83a305ee5
commit 85c26addf7
9 changed files with 220 additions and 3 deletions
+42
View File
@@ -194,3 +194,45 @@ test("the difficulty reported by the node is enforced as a minimum", async () =>
await g.close();
}
});
const SHARE = "/ip4/8.8.8.8/tcp/4001/p2p/12D3KooWTest";
test("the invite page shows the command to join through this node", async () => {
const g = await startGateway({ listings: [], share: [SHARE, "/ip4/1.1.1.1/tcp/4001/p2p/12D3KooWRelay/p2p-circuit/p2p/12D3KooWTest"] });
try {
const page = openPage(g.url, "#/invite");
await page.waitFor(() => page.document.querySelector(".invite-command") !== null, "the command");
assert.equal(page.document.querySelector(".invite-command")!.textContent, `allmende run --bootstrap ${SHARE}`);
assert.match(page.document.querySelector("ul")!.textContent!, /p2p-circuit/, "the second address is listed");
page.close();
} finally {
await g.close();
}
});
test("the invite page says so when the node has no address to share, and for an older node", async () => {
for (const share of [[], undefined]) {
const g = await startGateway({ listings: [], ...(share ? { share } : {}) });
try {
const page = openPage(g.url, "#/invite", "de");
await page.waitFor(() => /noch keine Adresse/.test(page.document.body.textContent!), "the explanation");
assert.equal(page.document.querySelector(".invite-command"), null);
page.close();
} finally {
await g.close();
}
}
});
test("an address in the invite page is shown as text, never as HTML", async () => {
const g = await startGateway({ listings: [], share: [SHARE, `<img src=x onerror="window.__pwned=3">`] });
try {
const page = openPage(g.url, "#/invite");
await page.waitFor(() => page.document.querySelector("ul code") !== null, "the list");
assert.equal(page.document.querySelector("ul img"), null);
assert.equal((page.window as unknown as { __pwned?: number }).__pwned, undefined);
page.close();
} finally {
await g.close();
}
});