Choose even the first region in the browser; update Docker and Nix
A node now starts without any region (it only helps others connect, and prints a hint). The owner's sign-in link leads straight to the Regions page when none is followed, visitors get a notice instead of an empty search, and status always lists regions as an array. The Docker image no longer pins Bonn, the NixOS module no longer requires regions, and the VM test now starts without any, chooses the first region over the API and checks it survives a restart. README and the init hint follow. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AeFqV96dVeBX94inzcgZKw
This commit is contained in:
Vendored
+51
-27
@@ -110,6 +110,9 @@ function sendOnCtrlEnter(area) {
|
||||
var de = {
|
||||
"app.tagline": "Wohnungen und H\xE4user, getragen von allen. Kostenlos, ohne Konzern.",
|
||||
"status.line": "{listings} Anzeigen \xB7 {peers} verbundene Knoten \xB7 Regionen: {regions}",
|
||||
"status.noRegions": "noch keine",
|
||||
"search.noRegions": "Dieser Knoten folgt noch keiner Region und hat deshalb keine Anzeigen. Wer ihn betreibt, w\xE4hlt Regionen unter \u201EMeine Anzeigen\u201C > \u201ERegionen\u201C.",
|
||||
"search.chooseRegions": "Regionen w\xE4hlen",
|
||||
"status.unreachable": "Dieser Knoten ist nicht erreichbar.",
|
||||
"filter.kind": "Angebot",
|
||||
"filter.category": "Art",
|
||||
@@ -359,6 +362,9 @@ var de = {
|
||||
var en = {
|
||||
"app.tagline": "Homes to rent and buy, run by everyone. Free, with no company behind it.",
|
||||
"status.line": "{listings} listings \xB7 {peers} connected nodes \xB7 regions: {regions}",
|
||||
"status.noRegions": "none yet",
|
||||
"search.noRegions": "This node follows no region yet, so it has no listings. Whoever runs it chooses regions under \u201CMy listings\u201D > \u201CRegions\u201D.",
|
||||
"search.chooseRegions": "Choose regions",
|
||||
"status.unreachable": "This node is not reachable.",
|
||||
"filter.kind": "Offer",
|
||||
"filter.category": "Type",
|
||||
@@ -617,6 +623,13 @@ function t(key, vars = {}) {
|
||||
}
|
||||
|
||||
// src/format.ts
|
||||
function statusLine(n) {
|
||||
return t("status.line", {
|
||||
listings: n.listings,
|
||||
peers: n.peers,
|
||||
regions: n.regions.length ? n.regions.join(", ") : t("status.noRegions")
|
||||
});
|
||||
}
|
||||
function money(cents) {
|
||||
return new Intl.NumberFormat(lang, { style: "currency", currency: "EUR" }).format(cents / 100);
|
||||
}
|
||||
@@ -761,7 +774,7 @@ function keepFresh(alive, run, ms = FOREGROUND_MS, doc = document) {
|
||||
schedule();
|
||||
}
|
||||
|
||||
// ../../web/node_modules/@noble/ciphers/utils.js
|
||||
// node_modules/@noble/ciphers/utils.js
|
||||
/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */
|
||||
function isBytes(a) {
|
||||
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
|
||||
@@ -940,7 +953,7 @@ function copyBytes(bytes2) {
|
||||
return Uint8Array.from(abytes(bytes2));
|
||||
}
|
||||
|
||||
// ../../web/node_modules/@noble/ciphers/_arx.js
|
||||
// node_modules/@noble/ciphers/_arx.js
|
||||
var encodeStr = (str) => Uint8Array.from(str.split(""), (c) => c.charCodeAt(0));
|
||||
var sigma16_32 = /* @__PURE__ */ (() => swap32IfBE(u32(encodeStr("expand 16-byte k"))))();
|
||||
var sigma32_32 = /* @__PURE__ */ (() => swap32IfBE(u32(encodeStr("expand 32-byte k"))))();
|
||||
@@ -1070,7 +1083,7 @@ function createCipher(core, opts) {
|
||||
};
|
||||
}
|
||||
|
||||
// ../../web/node_modules/@noble/ciphers/_poly1305.js
|
||||
// node_modules/@noble/ciphers/_poly1305.js
|
||||
function u8to16(a, i) {
|
||||
return a[i++] & 255 | (a[i++] & 255) << 8;
|
||||
}
|
||||
@@ -1321,7 +1334,7 @@ var Poly1305 = class {
|
||||
};
|
||||
var poly1305 = /* @__PURE__ */ wrapMacConstructor(32, (key) => new Poly1305(key));
|
||||
|
||||
// ../../web/node_modules/@noble/ciphers/chacha.js
|
||||
// node_modules/@noble/ciphers/chacha.js
|
||||
function chachaCore(s, k, n, out, cnt, rounds = 20) {
|
||||
let y00 = s[0], y01 = s[1], y02 = s[2], y03 = s[3], y04 = k[0], y05 = k[1], y06 = k[2], y07 = k[3], y08 = k[4], y09 = k[5], y10 = k[6], y11 = k[7], y12 = cnt, y13 = n[0], y14 = n[1], y15 = n[2];
|
||||
let x00 = y00, x01 = y01, x02 = y02, x03 = y03, x04 = y04, x05 = y05, x06 = y06, x07 = y07, x08 = y08, x09 = y09, x10 = y10, x11 = y11, x12 = y12, x13 = y13, x14 = y14, x15 = y15;
|
||||
@@ -1471,7 +1484,7 @@ var chacha20poly1305 = /* @__PURE__ */ wrapCipher(
|
||||
/* @__PURE__ */ _poly1305_aead(chacha20)
|
||||
);
|
||||
|
||||
// ../../web/node_modules/@noble/hashes/_u64.js
|
||||
// node_modules/@noble/hashes/_u64.js
|
||||
var U32_MASK64 = /* @__PURE__ */ (() => BigInt(2 ** 32 - 1))();
|
||||
var _32n = /* @__PURE__ */ BigInt(32);
|
||||
function fromBig(n, le = false) {
|
||||
@@ -1514,7 +1527,7 @@ var add4H = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0
|
||||
var add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
|
||||
var add5H = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;
|
||||
|
||||
// ../../web/node_modules/@noble/hashes/utils.js
|
||||
// node_modules/@noble/hashes/utils.js
|
||||
function isBytes2(a) {
|
||||
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
|
||||
}
|
||||
@@ -1679,7 +1692,7 @@ var oidNist = (suffix) => ({
|
||||
oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, suffix])
|
||||
});
|
||||
|
||||
// ../../web/node_modules/@noble/hashes/_md.js
|
||||
// node_modules/@noble/hashes/_md.js
|
||||
function Chi(a, b, c) {
|
||||
return a & b ^ ~a & c;
|
||||
}
|
||||
@@ -1810,7 +1823,7 @@ var SHA512_IV = /* @__PURE__ */ Uint32Array.from([
|
||||
327033209
|
||||
]);
|
||||
|
||||
// ../../web/node_modules/@noble/hashes/sha2.js
|
||||
// node_modules/@noble/hashes/sha2.js
|
||||
var SHA256_K = /* @__PURE__ */ Uint32Array.from([
|
||||
1116352408,
|
||||
1899447441,
|
||||
@@ -2207,7 +2220,7 @@ var sha512 = /* @__PURE__ */ createHasher(
|
||||
/* @__PURE__ */ oidNist(3)
|
||||
);
|
||||
|
||||
// ../../web/node_modules/@noble/curves/utils.js
|
||||
// node_modules/@noble/curves/utils.js
|
||||
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
||||
function aarray(item, title, inner = () => {
|
||||
}) {
|
||||
@@ -2328,7 +2341,7 @@ function validateObject(object, fields = {}, optFields = {}, title = "object") {
|
||||
iter(optFields, true);
|
||||
}
|
||||
|
||||
// ../../web/node_modules/@noble/curves/abstract/modular.js
|
||||
// node_modules/@noble/curves/abstract/modular.js
|
||||
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
||||
var _0n2 = /* @__PURE__ */ BigInt(0);
|
||||
var _1n2 = /* @__PURE__ */ BigInt(1);
|
||||
@@ -2758,7 +2771,7 @@ function Field(ORDER, opts = {}) {
|
||||
return new _Field(ORDER, opts);
|
||||
}
|
||||
|
||||
// ../../web/node_modules/@noble/curves/abstract/curve.js
|
||||
// node_modules/@noble/curves/abstract/curve.js
|
||||
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
||||
var _0n3 = /* @__PURE__ */ BigInt(0);
|
||||
var _1n3 = /* @__PURE__ */ BigInt(1);
|
||||
@@ -3146,7 +3159,7 @@ function createKeygen(randomSecretKey, getPublicKey) {
|
||||
};
|
||||
}
|
||||
|
||||
// ../../web/node_modules/@noble/curves/abstract/edwards.js
|
||||
// node_modules/@noble/curves/abstract/edwards.js
|
||||
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
||||
var _0n4 = /* @__PURE__ */ BigInt(0);
|
||||
var _1n4 = /* @__PURE__ */ BigInt(1);
|
||||
@@ -3598,7 +3611,7 @@ function eddsa(Point, cHash, eddsaOpts = {}) {
|
||||
});
|
||||
}
|
||||
|
||||
// ../../web/node_modules/@noble/curves/abstract/montgomery.js
|
||||
// node_modules/@noble/curves/abstract/montgomery.js
|
||||
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
||||
var _0n5 = /* @__PURE__ */ BigInt(0);
|
||||
var _1n5 = /* @__PURE__ */ BigInt(1);
|
||||
@@ -3746,7 +3759,7 @@ function montgomery(curveDef) {
|
||||
});
|
||||
}
|
||||
|
||||
// ../../web/node_modules/@noble/curves/ed25519.js
|
||||
// node_modules/@noble/curves/ed25519.js
|
||||
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
||||
var _0n6 = /* @__PURE__ */ BigInt(0);
|
||||
var _1n6 = /* @__PURE__ */ BigInt(1);
|
||||
@@ -3847,7 +3860,7 @@ var x25519 = /* @__PURE__ */ (() => {
|
||||
});
|
||||
})();
|
||||
|
||||
// ../../web/node_modules/@noble/hashes/hmac.js
|
||||
// node_modules/@noble/hashes/hmac.js
|
||||
var _HMAC = class {
|
||||
oHash;
|
||||
iHash;
|
||||
@@ -3924,7 +3937,7 @@ var hmac = /* @__PURE__ */ (() => {
|
||||
return hmac_;
|
||||
})();
|
||||
|
||||
// ../../web/node_modules/@noble/hashes/hkdf.js
|
||||
// node_modules/@noble/hashes/hkdf.js
|
||||
var HKDF_COUNTER = /* @__PURE__ */ Uint8Array.of(0);
|
||||
var EMPTY_BUFFER = /* @__PURE__ */ Uint8Array.of();
|
||||
function expand(hash, prk, info, length = 32, _recycled) {
|
||||
@@ -6022,9 +6035,7 @@ function showRegions(message = "") {
|
||||
const now = await setRegions(regions);
|
||||
if (state.node) state.node.regions = now;
|
||||
const statusEl2 = document.getElementById("status");
|
||||
if (statusEl2 && state.node) {
|
||||
statusEl2.textContent = t("status.line", { listings: state.node.listings, peers: state.node.peers, regions: now.join(", ") });
|
||||
}
|
||||
if (statusEl2 && state.node) statusEl2.textContent = statusLine(state.node);
|
||||
showRegions(t("reg.saved"));
|
||||
}
|
||||
});
|
||||
@@ -6200,7 +6211,19 @@ function showSearch(params) {
|
||||
const gen = state.generation;
|
||||
clear(app4);
|
||||
const results = h("div", { class: "results", "aria-live": "polite" });
|
||||
app4.append(h("p", { class: "tagline" }, t("app.tagline")), searchForm(params), results);
|
||||
app4.append(h("p", { class: "tagline" }, t("app.tagline")));
|
||||
if (state.node && state.node.regions.length === 0) {
|
||||
app4.append(
|
||||
h(
|
||||
"p",
|
||||
{ class: "notice", role: "status" },
|
||||
t("search.noRegions"),
|
||||
" ",
|
||||
getToken() ? h("a", { href: "#/mine/regions" }, t("search.chooseRegions")) : null
|
||||
)
|
||||
);
|
||||
}
|
||||
app4.append(searchForm(params), results);
|
||||
const prefix = params.get("geohash")?.trim().toLowerCase();
|
||||
if (prefix && !GEOHASH_PREFIX.test(prefix)) {
|
||||
results.append(h("p", { class: "error" }, t("filter.regionHint")));
|
||||
@@ -6336,8 +6359,13 @@ function route() {
|
||||
document.body.classList.remove("wide");
|
||||
if (login) {
|
||||
setToken(login[1]);
|
||||
history.replaceState(null, "", location.pathname + location.search + "#/mine");
|
||||
void showOwner();
|
||||
if (state.node && state.node.regions.length === 0) {
|
||||
history.replaceState(null, "", location.pathname + location.search + "#/mine/regions");
|
||||
showRegions();
|
||||
} else {
|
||||
history.replaceState(null, "", location.pathname + location.search + "#/mine");
|
||||
void showOwner();
|
||||
}
|
||||
} else if (m) void showDetail(m[1], m[2]);
|
||||
else if (c) void showConversation(c[1], c[2], c[3]);
|
||||
else if (path === "/messages") showInbox();
|
||||
@@ -6354,11 +6382,7 @@ async function boot() {
|
||||
document.getElementById("foot").textContent = t("footer.text");
|
||||
try {
|
||||
state.node = await getStatus();
|
||||
statusEl.textContent = t("status.line", {
|
||||
listings: state.node.listings,
|
||||
peers: state.node.peers,
|
||||
regions: state.node.regions.join(", ")
|
||||
});
|
||||
statusEl.textContent = statusLine(state.node);
|
||||
} catch {
|
||||
statusEl.textContent = t("status.unreachable");
|
||||
}
|
||||
|
||||
Vendored
+1
@@ -75,6 +75,7 @@ a { color: var(--accent); }
|
||||
.status, .muted, .hint { color: var(--muted); font-size: 0.9rem; }
|
||||
.info { margin-left: 0.5rem; }
|
||||
.tagline { color: var(--muted); margin: 4px 0 20px; }
|
||||
.notice { margin: 0 0 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
|
||||
.pad { padding: 16px; }
|
||||
|
||||
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0; }
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
import { lang, t } from "./i18n.ts";
|
||||
import type { Listing } from "./verify.ts";
|
||||
|
||||
/** The line under the title: what the node holds and follows. */
|
||||
export function statusLine(n: { listings: number; peers: number; regions: string[] }): string {
|
||||
return t("status.line", {
|
||||
listings: n.listings,
|
||||
peers: n.peers,
|
||||
regions: n.regions.length ? n.regions.join(", ") : t("status.noRegions"),
|
||||
});
|
||||
}
|
||||
|
||||
export function money(cents: number): string {
|
||||
return new Intl.NumberFormat(lang, { style: "currency", currency: "EUR" }).format(cents / 100);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
const de = {
|
||||
"app.tagline": "Wohnungen und Häuser, getragen von allen. Kostenlos, ohne Konzern.",
|
||||
"status.line": "{listings} Anzeigen · {peers} verbundene Knoten · Regionen: {regions}",
|
||||
"status.noRegions": "noch keine",
|
||||
"search.noRegions": "Dieser Knoten folgt noch keiner Region und hat deshalb keine Anzeigen. Wer ihn betreibt, wählt Regionen unter „Meine Anzeigen“ > „Regionen“.",
|
||||
"search.chooseRegions": "Regionen wählen",
|
||||
"status.unreachable": "Dieser Knoten ist nicht erreichbar.",
|
||||
"filter.kind": "Angebot",
|
||||
"filter.category": "Art",
|
||||
@@ -277,6 +280,9 @@ const de = {
|
||||
const en: Record<keyof typeof de, string> = {
|
||||
"app.tagline": "Homes to rent and buy, run by everyone. Free, with no company behind it.",
|
||||
"status.line": "{listings} listings · {peers} connected nodes · regions: {regions}",
|
||||
"status.noRegions": "none yet",
|
||||
"search.noRegions": "This node follows no region yet, so it has no listings. Whoever runs it chooses regions under “My listings” > “Regions”.",
|
||||
"search.chooseRegions": "Choose regions",
|
||||
"status.unreachable": "This node is not reachable.",
|
||||
"filter.kind": "Offer",
|
||||
"filter.category": "Type",
|
||||
|
||||
+23
-9
@@ -1,6 +1,6 @@
|
||||
import { getListing, getStatus, search } from "./api.ts";
|
||||
import { append, clear, h } from "./dom.ts";
|
||||
import { date, price, rooms, shortKey } from "./format.ts";
|
||||
import { date, price, rooms, shortKey, statusLine } from "./format.ts";
|
||||
import { decodeGeohash } from "./geohash.ts";
|
||||
import { lang, t, type Key } from "./i18n.ts";
|
||||
import { contactPanel, showConversation, showInbox } from "./chat.ts";
|
||||
@@ -191,7 +191,19 @@ function showSearch(params: URLSearchParams): void {
|
||||
const gen = state.generation;
|
||||
clear(app);
|
||||
const results = h("div", { class: "results", "aria-live": "polite" });
|
||||
app.append(h("p", { class: "tagline" }, t("app.tagline")), searchForm(params), results);
|
||||
app.append(h("p", { class: "tagline" }, t("app.tagline")));
|
||||
if (state.node && state.node.regions.length === 0) {
|
||||
app.append(
|
||||
h(
|
||||
"p",
|
||||
{ class: "notice", role: "status" },
|
||||
t("search.noRegions"),
|
||||
" ",
|
||||
getToken() ? h("a", { href: "#/mine/regions" }, t("search.chooseRegions")) : null,
|
||||
),
|
||||
);
|
||||
}
|
||||
app.append(searchForm(params), results);
|
||||
|
||||
const prefix = params.get("geohash")?.trim().toLowerCase();
|
||||
if (prefix && !GEOHASH_PREFIX.test(prefix)) {
|
||||
@@ -353,8 +365,14 @@ function route(): void {
|
||||
if (login) {
|
||||
// The token came in the URL fragment: keep it for this tab and take it out of the address bar.
|
||||
setToken(login[1]!);
|
||||
history.replaceState(null, "", location.pathname + location.search + "#/mine");
|
||||
void showOwner();
|
||||
if (state.node && state.node.regions.length === 0) {
|
||||
// A node that follows nothing has nothing to show: the first thing to do is choose.
|
||||
history.replaceState(null, "", location.pathname + location.search + "#/mine/regions");
|
||||
showRegions();
|
||||
} else {
|
||||
history.replaceState(null, "", location.pathname + location.search + "#/mine");
|
||||
void showOwner();
|
||||
}
|
||||
} else if (m) void showDetail(m[1]!, m[2]!);
|
||||
else if (c) void showConversation(c[1]!, c[2]!, c[3]!);
|
||||
else if (path === "/messages") showInbox();
|
||||
@@ -372,11 +390,7 @@ async function boot(): Promise<void> {
|
||||
document.getElementById("foot")!.textContent = t("footer.text");
|
||||
try {
|
||||
state.node = await getStatus();
|
||||
statusEl.textContent = t("status.line", {
|
||||
listings: state.node.listings,
|
||||
peers: state.node.peers,
|
||||
regions: state.node.regions.join(", "),
|
||||
});
|
||||
statusEl.textContent = statusLine(state.node);
|
||||
} catch {
|
||||
statusEl.textContent = t("status.unreachable");
|
||||
}
|
||||
|
||||
+2
-3
@@ -6,6 +6,7 @@
|
||||
// typed for those who know them. Saving changes what the node follows at once.
|
||||
|
||||
import { append, clear, h } from "./dom.ts";
|
||||
import { statusLine } from "./format.ts";
|
||||
import { lang, t } from "./i18n.ts";
|
||||
import { Unauthorized, getToken, setRegions } from "./ownerApi.ts";
|
||||
import { biggestPlaceByCell, cellsNear, loadPlaces, searchPlaces, type Match, type Place } from "./places.ts";
|
||||
@@ -239,9 +240,7 @@ export function showRegions(message = ""): void {
|
||||
const now = await setRegions(regions);
|
||||
if (state.node) state.node.regions = now;
|
||||
const statusEl = document.getElementById("status");
|
||||
if (statusEl && state.node) {
|
||||
statusEl.textContent = t("status.line", { listings: state.node.listings, peers: state.node.peers, regions: now.join(", ") });
|
||||
}
|
||||
if (statusEl && state.node) statusEl.textContent = statusLine(state.node);
|
||||
showRegions(t("reg.saved")); // the page again, showing what is followed now
|
||||
},
|
||||
});
|
||||
|
||||
@@ -75,6 +75,7 @@ a { color: var(--accent); }
|
||||
.status, .muted, .hint { color: var(--muted); font-size: 0.9rem; }
|
||||
.info { margin-left: 0.5rem; }
|
||||
.tagline { color: var(--muted); margin: 4px 0 20px; }
|
||||
.notice { margin: 0 0 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
|
||||
.pad { padding: 16px; }
|
||||
|
||||
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0; }
|
||||
|
||||
+3
-1
@@ -192,6 +192,8 @@ export interface GatewayOptions {
|
||||
/** For a requested listing id, answer with this other listing instead. */
|
||||
swap?: unknown;
|
||||
statusFails?: boolean;
|
||||
/** The regions the node reports; default ["u1x"]. */
|
||||
regions?: string[];
|
||||
}
|
||||
|
||||
export async function startGateway(opts: GatewayOptions): Promise<Gateway> {
|
||||
@@ -252,7 +254,7 @@ export async function startGateway(opts: GatewayOptions): Promise<Gateway> {
|
||||
peer_id: "12D3KooWTest",
|
||||
author: "a".repeat(64),
|
||||
device: "b".repeat(64),
|
||||
regions: ["u1x"],
|
||||
regions: opts.regions ?? ["u1x"],
|
||||
peers: 2,
|
||||
listings: opts.listings.length,
|
||||
difficulty: DIFFICULTY,
|
||||
|
||||
+25
-1
@@ -392,7 +392,7 @@ test("signing out forgets the token", async () => {
|
||||
test("the owner picks regions by place name and the node follows them at once", async () => {
|
||||
open(`#/login/${TOKEN}`);
|
||||
await page!.waitFor(() => qa(".pane-listings .ocard").length === 2, "the listings");
|
||||
qa(".pane-listings a").find((a) => a.textContent === "Regions")!.click();
|
||||
(qa(".pane-listings a").find((a) => a.textContent === "Regions") as HTMLElement).click();
|
||||
await page!.waitFor(() => q('[name="place"]') !== null, "the regions page");
|
||||
assert.ok(q(".rp-chips")!.textContent!.includes("u1x"), "what the node follows now");
|
||||
const search = q<HTMLInputElement>('[name="place"]')!;
|
||||
@@ -437,3 +437,27 @@ test("without signing in the regions page leads to the sign-in", async () => {
|
||||
function location_(hash: string): void {
|
||||
page!.window.location.hash = hash;
|
||||
}
|
||||
|
||||
test("a node without regions: visitors are told, and the owner's login leads to choosing the first region", async () => {
|
||||
await gw.close();
|
||||
gw = await startGateway({ listings: [], regions: [] });
|
||||
gw.owner = node.handler;
|
||||
|
||||
open("#/");
|
||||
await page!.waitFor(() => /follows no region yet/.test(text()), "the notice for visitors");
|
||||
assert.ok(text().includes("regions: none yet"), "the status line says so");
|
||||
assert.equal(q(".notice a"), null, "no link for someone who is not signed in");
|
||||
page!.close();
|
||||
|
||||
open(`#/login/${TOKEN}`);
|
||||
await page!.waitFor(() => q('[name="place"]') !== null, "the regions page, straight after login");
|
||||
assert.equal(page!.window.location.hash, "#/mine/regions");
|
||||
assert.ok(q(".rp-chips")!.textContent!.includes("No region chosen yet"));
|
||||
|
||||
q<HTMLInputElement>('[name="regions"]')!.value = "u1j";
|
||||
submit(q("form")!);
|
||||
await page!.waitFor(() => /Saved/.test(text()), "saved");
|
||||
assert.ok(text().includes("regions: u1j"), "the status line shows the first region");
|
||||
const put = node.s.calls.find((c) => c.method === "PUT" && c.path === "/api/v1/regions")!;
|
||||
assert.equal(put.body, '{"regions":["u1j"]}');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user