feat(series): choose open series or club members only for series points
Who scores is now an explicit per-series choice: every driver (default) or club members only, with the club field shown only for the latter. Series saved with a club keep members-only scoring. README updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -30,6 +30,7 @@ export async function runSeriesSmoke({ evaluate, navigate, savedState, waitFor,
|
||||
await evaluate(`(() => {
|
||||
const form = document.getElementById("seriesForm");
|
||||
form.elements.name.value = "SR Winter Cup";
|
||||
form.elements.scoring.value = "club";
|
||||
form.elements.club.value = "Östersunds RC";
|
||||
form.querySelectorAll('input[name="classIds"]').forEach((box) => { box.checked = box.value === "sr_2wd"; });
|
||||
form.elements.countMode.value = "drop";
|
||||
@@ -40,6 +41,7 @@ export async function runSeriesSmoke({ evaluate, navigate, savedState, waitFor,
|
||||
const saved = (await savedState()).series.find((series) => series.name === "SR Winter Cup");
|
||||
assert.deepEqual(saved.classIds, ["sr_2wd"]);
|
||||
assert.equal(saved.club, "Östersunds RC");
|
||||
assert.equal(saved.scoring, "club");
|
||||
assert.deepEqual(saved.pointsTable.slice(0, 3), [100, 90, 82], "the ÖRC table is the default");
|
||||
|
||||
await evaluate(`(() => { const form = document.getElementById("seriesCreateEvents"); form.elements.dates.value = "2026-11-15\\n2026-11-01"; form.requestSubmit(); })()`);
|
||||
@@ -67,6 +69,15 @@ 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");
|
||||
|
||||
// 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");
|
||||
await waitFor(async () => (await evaluate(`[...document.querySelectorAll('[data-series-class="sr_2wd"] tbody tr')].map((tr) => tr.children[1].textContent.trim()).join(",")`)) === "SR Guest,SR Anna,SR Bo", "everyone scores in an open series");
|
||||
assert.equal(await evaluate(`document.querySelector("[data-series-club]").hidden`), true, "the club field is hidden for an open series");
|
||||
await evaluate(`(() => { const form = document.getElementById("seriesForm"); form.elements.scoring.value = "club"; form.requestSubmit(); })()`);
|
||||
await waitFor(async () => (await savedState()).series.find((series) => series.id === saved.id)?.scoring === "club", "back to members only");
|
||||
console.log("PASS who scores is a choice: every driver, or club members only");
|
||||
|
||||
// The PDF export carries the same table (request captured in the page, not downloaded).
|
||||
const payload = await evaluate(`(async () => {
|
||||
const realFetch = window.fetch;
|
||||
|
||||
@@ -25,6 +25,18 @@ test("only club members score; they are re-ranked without guests; no lap means 0
|
||||
assert.equal(scoreSeriesEvent(open, [{ driverId: "guest", hasLap: true }]).get("guest").points, 100, "no club set: everyone scores");
|
||||
});
|
||||
|
||||
test("who scores is an explicit choice: an open series counts every driver even with a club filled in", () => {
|
||||
const clubs = { member: "Östersunds RC", guest: "Other RC" };
|
||||
const day = [{ driverId: "guest", hasLap: true }, { driverId: "member", hasLap: true }];
|
||||
const open = normalizeSeries({ club: "Östersunds RC", scoring: "all" });
|
||||
assert.equal(open.scoring, "all");
|
||||
assert.equal(scoreSeriesEvent(open, day, { getDriverClub: (id) => clubs[id] }).get("guest").points, 100);
|
||||
const members = normalizeSeries({ club: "Östersunds RC", scoring: "club" });
|
||||
assert.equal(scoreSeriesEvent(members, day, { getDriverClub: (id) => clubs[id] }).get("member").points, 100);
|
||||
assert.equal(normalizeSeries({}).scoring, "all", "new series are open by default");
|
||||
assert.equal(normalizeSeries({ club: "Östersunds RC" }).scoring, "club", "a series saved with a club before the choice existed stays members-only");
|
||||
});
|
||||
|
||||
test("best N, or completed minus X (so a cancelled event lowers the count)", () => {
|
||||
assert.equal(getCountedResultsCount(orc, 12), 9);
|
||||
assert.equal(getCountedResultsCount(orc, 4), 4);
|
||||
|
||||
Reference in New Issue
Block a user