feat(series): correct a round's result by hand (1.48.0)
This commit is contained in:
1 parent
6142bceca9
commit
e199f3aa1a
11 files changed
+178
-14
No files matched your search
@@ -140,6 +140,26 @@ export async function runSeriesSmoke({ evaluate, navigate, savedState, waitFor,
|
||||
assert.deepEqual(rows, [["1", "SR Anna", "100", "", "1", "100"], ["2", "SR Bo", "90", "", "1", "90"]], "the guest races but doesn't score; Anna is re-ranked 1st; round 2 is empty");
|
||||
console.log("PASS standings: only club drivers score, re-ranked without guests; unplayed rounds stay empty");
|
||||
|
||||
// The club corrects round 1 by hand (the qualifying went wrong): Bo is moved up to win.
|
||||
await inRound(round1.id, `row.querySelector('[data-round-action="result"]').click();`);
|
||||
await waitFor(async () => Boolean(await evaluate(`document.querySelector("[data-round-result]")`)), "result editor open");
|
||||
const editorOrder = async () => evaluate(`[...document.querySelectorAll("[data-result-driver]")].map((item) => item.dataset.resultDriver)`);
|
||||
assert.deepEqual(await editorOrder(), ["sr_guest", "sr_anna", "sr_bo"], "starts from the calculated result");
|
||||
await evaluate(`document.querySelector('[data-result-driver="sr_bo"] [data-result-move="up"]').click()`);
|
||||
await waitFor(async () => (await editorOrder()).join() === "sr_guest,sr_bo,sr_anna", "moved up");
|
||||
await evaluate(`document.querySelector('[data-result-driver="sr_bo"] [data-result-move="up"]').click()`);
|
||||
await waitFor(async () => (await editorOrder()).join() === "sr_bo,sr_guest,sr_anna", "moved to the top");
|
||||
await evaluate(`document.querySelector('[data-result-action="save"]').click()`);
|
||||
await waitFor(async () => (await savedState()).series.find((item) => item.id === saved.id)?.manualResults?.[round1.id]?.join() === "sr_bo,sr_guest,sr_anna", "saved on the series");
|
||||
await waitFor(async () => (await evaluate(`[...document.querySelectorAll('[data-series-class="sr_2wd"] tbody tr')].map((tr) => tr.children[1].textContent.trim()).join()`)) === "SR Bo,SR Anna", "the standings follow the corrected order");
|
||||
assert.ok((await inRound(round1.id, `return row.textContent;`)).includes("Corrected result"), "the round is marked as corrected");
|
||||
// Back to the calculated result.
|
||||
await inRound(round1.id, `row.querySelector('[data-round-action="result"]').click();`);
|
||||
await waitFor(async () => Boolean(await evaluate(`document.querySelector('[data-result-action="clear"]')`)), "clear offered");
|
||||
await evaluate(`document.querySelector('[data-result-action="clear"]').click()`);
|
||||
await waitFor(async () => !(await savedState()).series.find((item) => item.id === saved.id)?.manualResults?.[round1.id], "the corrected result is removed");
|
||||
console.log("PASS a round's result can be corrected by hand and the standings follow it");
|
||||
|
||||
// Switch the same series to "every driver": the guest now scores and wins round 1.
|
||||
await evaluate(`(() => { const form = document.getElementById("seriesForm"); form.elements.scoring.value = "all"; form.elements.scoring.dispatchEvent(new Event("change")); form.requestSubmit(); })()`);
|
||||
await waitFor(async () => (await savedState()).series.find((series) => series.id === saved.id)?.scoring === "all", "open series saved");
|
||||
|
||||
@@ -42,3 +42,13 @@ test("seeding groups: even split by max size, top of the standings last with fas
|
||||
const fifty = Array.from({ length: 50 }, (_, index) => `x${index}`);
|
||||
assert.deepEqual(planSeedingGroups(fifty, 6, "fastest_first").map((group) => group.length), [6, 6, 6, 6, 6, 5, 5, 5, 5]);
|
||||
});
|
||||
|
||||
test("a round's hand-set result replaces the calculated one in the standings", async () => {
|
||||
const { normalizeSeries, getSeriesDayResult } = await import("../src/series_logic.js");
|
||||
const series = normalizeSeries({ id: "s", manualResults: { e1: ["roy", "wilmer", "roy", ""], e2: [] } });
|
||||
assert.deepEqual(series.manualResults, { e1: ["roy", "wilmer"] }, "duplicates and empty lists are dropped");
|
||||
const calculated = [{ driverId: "patrik", driverName: "Patrik", hasLap: true }, { driverId: "roy", driverName: "Roy", hasLap: true }];
|
||||
const names = { roy: "Roy Gjemble", wilmer: "Wilmer Nilsson" };
|
||||
assert.deepEqual(getSeriesDayResult(series, "e1", calculated, (id) => names[id]).map((row) => row.driverName), ["Roy Gjemble", "Wilmer Nilsson"]);
|
||||
assert.equal(getSeriesDayResult(series, "e2", calculated), calculated, "no hand-set order: the calculated result");
|
||||
});
|
||||
Reference in new issue
Block a user