swarm-ui: start page setup assistant offers to create ruth
This commit is contained in:
parent
89efda5ea2
commit
8bf53f7ed9
7 changed files with 208 additions and 15 deletions
37
frontend/packages/swarm-ui/test/ruth-missing.test.mjs
Normal file
37
frontend/packages/swarm-ui/test/ruth-missing.test.mjs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
// The setup assistant's "is ruth missing" check. Run by `npm test`.
|
||||
import assert from "node:assert/strict";
|
||||
import { test } from "node:test";
|
||||
import { ruthIsMissing } from "../src/shell/ruth-missing.ts";
|
||||
|
||||
const answering =
|
||||
(body, ok = true) =>
|
||||
async () => ({
|
||||
ok,
|
||||
json: async () => body,
|
||||
});
|
||||
|
||||
test("a roster without ruth means ruth is missing", async () => {
|
||||
assert.equal(
|
||||
await ruthIsMissing(answering([{ name: "atlas" }, { name: "argus" }])),
|
||||
true,
|
||||
);
|
||||
assert.equal(await ruthIsMissing(answering([])), true);
|
||||
});
|
||||
|
||||
test("a roster with ruth means she is not missing", async () => {
|
||||
assert.equal(
|
||||
await ruthIsMissing(answering([{ name: "atlas" }, { name: "ruth" }])),
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
test("anything but a clear answer is not missing", async () => {
|
||||
assert.equal(await ruthIsMissing(answering([], false)), false);
|
||||
assert.equal(await ruthIsMissing(answering({ not: "a list" })), false);
|
||||
assert.equal(
|
||||
await ruthIsMissing(async () => {
|
||||
throw new Error("offline");
|
||||
}),
|
||||
false,
|
||||
);
|
||||
});
|
||||
Loading…
Reference in a new issue