feat(houseofrc): create a race from a House of RC event and its entries (1.80.0)
This commit is contained in:
1 parent
42df6a786f
commit
9c1f5713e6
18 files changed
+444
-21
No files matched your search
@@ -733,7 +733,19 @@ test("House of RC: the key is stored server-side only, never returned, and the t
|
||||
const mock = createServer((req, res) => {
|
||||
seen.push({ url: req.url, auth: req.headers.authorization });
|
||||
const ok = req.headers.authorization === "Bearer hrc_test_secret_key_1234";
|
||||
res.writeHead(ok ? 200 : 401, { "Content-Type": "application/json" });
|
||||
const missing = ok && req.url.startsWith("/v1/events/") && req.url !== "/v1/events/2251";
|
||||
res.writeHead(!ok ? 401 : missing ? 404 : 200, { "Content-Type": "application/json" });
|
||||
if (missing) return res.end(JSON.stringify({ message: "Not found." }));
|
||||
if (ok && req.url.startsWith("/v1/events?")) {
|
||||
return res.end(JSON.stringify({ data: [
|
||||
{ id: 2251, name: "Deltävling 2 Sundsvall", type: "race", status: "live", start: "2026-12-05T07:00:00Z", city: "Sundsvall", country: "SE", web_url: "https://houseofrc.com/events/2251" },
|
||||
{ id: 3001, name: "Winter Cup", type: "race", status: null, start: "2026-12-06T07:00:00Z", city: "Oslo", country: "NO" },
|
||||
], links: { next: null }, meta: {} }));
|
||||
}
|
||||
if (ok && req.url === "/v1/events/2251") return res.end(JSON.stringify({ data: { id: 2251, name: "Deltävling 2 Sundsvall", type: "race", start: "2026-12-05T07:00:00Z", city: "Sundsvall", country: "SE", web_url: "https://houseofrc.com/events/2251" } }));
|
||||
if (ok && req.url === "/results?event_id=2251") {
|
||||
return res.end(JSON.stringify([{ user_id: 68, name: "Anna Andersson", firstname: "Anna", lastname: "Andersson", number: 7, points: 0, club: "Östersunds RC", country: "Sweden", product: "X12", brand1: "XRAY" }]));
|
||||
}
|
||||
if (ok && req.url.startsWith("/timing/users")) {
|
||||
// Newest owner first; an unknown number is simply missing.
|
||||
return res.end(JSON.stringify([
|
||||
@@ -772,6 +784,14 @@ test("House of RC: the key is stored server-side only, never returned, and the t
|
||||
const lookup = await (await post("/api/houseofrc/transponders", { transponders: ["1234567", "7654321", "1234567", "bad value"] })).json();
|
||||
assert.equal(seen.at(-1).url, "/timing/users?transponders=1234567%2C7654321", "deduplicated, invalid numbers dropped");
|
||||
assert.deepEqual(lookup.members, { 1234567: { id: 5, name: "Bo Berg", model: "B7", brand: "Associated" } }, "the newest owner wins");
|
||||
const events = await (await post("/api/houseofrc/events", { from: "2026-12-01T00:00:00Z", to: "2026-12-31T23:59:59Z", country: "se" })).json();
|
||||
assert.deepEqual(events.events.map((event) => event.id), [2251], "filtered to the chosen country");
|
||||
assert.match(seen.at(-1).url, /^\/v1\/events\?start_from=2026-12-01.*sort=start&per_page=100&page=1$/);
|
||||
const entries = await (await post("/api/houseofrc/entries", { eventId: "https://houseofrc.com/events/2251" })).json();
|
||||
assert.equal(entries.event.name, "Deltävling 2 Sundsvall");
|
||||
assert.deepEqual(entries.entries, [{ houseOfRcId: 68, name: "Anna Andersson", number: 7, club: "Östersunds RC", country: "Sweden", car: "XRAY X12", brand: "XRAY", points: 0 }], "a pasted link works; car = make + model");
|
||||
assert.equal((await post("/api/houseofrc/entries", { eventId: "nonsense" })).status, 400);
|
||||
assert.equal((await (await post("/api/houseofrc/entries", { eventId: "999" })).json()).error, "event_not_found");
|
||||
|
||||
const keyFile = join(dataDir, "houseofrc.json");
|
||||
assert.equal(statSync(keyFile).mode & 0o777, 0o600, "only the server user can read the key file");
|
||||
|
||||
Reference in new issue
Block a user