feat(houseofrc): send heats automatically after every heat, show send status, warn before sending (1.85.0)
This commit is contained in:
1 parent
38cfa7ff2d
commit
3870510d8c
15 files changed
+189
-18
No files matched your search
@@ -70,7 +70,7 @@ export async function runHouseOfRcSmoke({ evaluate, navigate, savedState, waitFo
|
||||
export async function runHouseOfRcEventSmoke({ evaluate, navigate, savedState, waitFor, base }) {
|
||||
try {
|
||||
await navigate("race_setup", "raceWizardStepForm");
|
||||
await evaluate(`(() => {
|
||||
const installMock = `(() => {
|
||||
const realFetch = window.fetch;
|
||||
window.fetch = async (url, options) => {
|
||||
const json = (data) => new Response(JSON.stringify(data), { status: 200, headers: { "Content-Type": "application/json" } });
|
||||
@@ -89,7 +89,8 @@ export async function runHouseOfRcEventSmoke({ evaluate, navigate, savedState, w
|
||||
}
|
||||
return realFetch(url, options);
|
||||
};
|
||||
})()`);
|
||||
})()`;
|
||||
await evaluate(installMock);
|
||||
await evaluate(`document.getElementById("raceWizardHouseOfRc").click()`);
|
||||
await waitFor(async () => evaluate(`Boolean(document.querySelector("[data-hor-event]"))`), "the event list");
|
||||
await evaluate(`document.querySelector('[data-hor-event="2251"]').click()`);
|
||||
@@ -154,9 +155,26 @@ export async function runHouseOfRcEventSmoke({ evaluate, navigate, savedState, w
|
||||
assert.equal(posted.eventId, 2251);
|
||||
assert.deepEqual(posted.entries.map((entry) => entry.id).sort(), [11, 16]);
|
||||
assert.ok(posted.entries.every((entry) => !("ranking" in entry)), "no placing sent before the finals");
|
||||
await waitFor(async () => Boolean((await savedState()).events.find((item) => item.houseOfRc?.eventId === 2251)?.houseOfRc.resultsSentAt), "when it was sent is saved");
|
||||
await waitFor(async () => Boolean((await savedState()).events.find((item) => item.houseOfRc?.eventId === 2251)?.houseOfRc.lastSend?.ok), "how it was sent is saved");
|
||||
await evaluate(`document.getElementById("houseOfRcResultsOverlay")?.remove()`);
|
||||
console.log("PASS House of RC results: preview in Manage, heats sent to the race's entries without placings");
|
||||
|
||||
// "Send heats automatically": a qualifying heat finishes, the race controller sends it.
|
||||
await evaluate(`document.getElementById("houseOfRcAutoSend").click()`);
|
||||
await waitFor(async () => (await savedState()).events.find((item) => item.houseOfRc?.eventId === 2251)?.houseOfRc.autoSend === true, "auto-send saved");
|
||||
{
|
||||
const saved = await savedState();
|
||||
const race = saved.events.find((item) => item.houseOfRc?.eventId === 2251);
|
||||
const heat = saved.sessions.find((session) => session.eventId === race.id && session.type === "qualification");
|
||||
Object.assign(heat, { status: "finished", startedAt: Date.now() - 400000, endedAt: Date.now() - 100000 });
|
||||
await fetch(base + "/api/state", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(saved) });
|
||||
}
|
||||
await navigate("race_day", "raceDaySessionSelect");
|
||||
await evaluate(installMock);
|
||||
await waitFor(async () => evaluate(`Boolean(window.__horPosted)`), "sent by itself after the heat", 30000);
|
||||
assert.ok((await evaluate(`window.__horPosted.entries`)).every((entry) => !("ranking" in entry)), "automatic sending never sends placings");
|
||||
await waitFor(async () => (await savedState()).events.find((item) => item.houseOfRc?.eventId === 2251)?.houseOfRc.lastSend?.signature, "the send is remembered");
|
||||
console.log("PASS House of RC auto-send: a finished heat is sent by the race controller without placings");
|
||||
} finally {
|
||||
await evaluate(`document.getElementById("houseOfRcEventOverlay")?.remove()`).catch(() => {});
|
||||
const current = await savedState();
|
||||
|
||||
Reference in new issue
Block a user