feat(team-race): one team race setup panel with auto split, car per team and start checks (1.67.0)
This commit is contained in:
1 parent
69a65748ce
commit
37076b8490
13 files changed
+344
-309
No files matched your search
@@ -1,8 +1,7 @@
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
// Regression coverage for a real bug the user reported: moving a driver from one team to
|
||||
// another (by ticking them on the new team's edit form - there is no separate "move"
|
||||
// action) used to only ever ADD the driver to the new team, never remove them from the
|
||||
// another (by picking them in the new team's "add driver" list in the team race setup) used to only ever ADD the driver to the new team, never remove them from the
|
||||
// old one, so the same driver ended up listed on two teams at once. Also covers the two
|
||||
// related findings from the same investigation: getTeamDriverPool used to ignore the
|
||||
// event's class/participant scoping entirely (showing every driver in the club), and
|
||||
@@ -39,28 +38,29 @@ export async function runTeamMembershipSmoke({ evaluate, navigate, savedState, w
|
||||
|
||||
await navigate("race_setup", "raceWizardStepForm");
|
||||
await click("event-manage-" + raceEvent.id);
|
||||
await waitFor(async () => await evaluate(`Boolean(document.getElementById("teamForm"))`), "teams section visible for a race-mode event with a team_race session");
|
||||
await waitFor(async () => await evaluate(`Boolean(document.getElementById("teamSetupAdd"))`), "team race setup visible for a race-mode event with a team_race session");
|
||||
const setValue = (selector, value) => evaluate(`(() => { const node = document.querySelector(${JSON.stringify(selector)}); node.value = ${JSON.stringify(value)}; node.dispatchEvent(new Event("change", { bubbles: true })); })()`);
|
||||
const teamsNow = async () => (await findEvent(raceEvent.id)).raceConfig.teams || [];
|
||||
|
||||
await evaluate(`(() => { const form = document.getElementById("teamForm"); form.elements.namedItem("teamName").value = "Membership Team A"; })()`);
|
||||
await evaluate(`document.querySelector('[form="teamForm"][name="teamDriverIds"][value="${driverA.id}"]').checked = true`);
|
||||
await submit("teamForm");
|
||||
await waitFor(async () => (await findEvent(raceEvent.id)).raceConfig.teams.some((team) => team.name === "Membership Team A"), "team A created");
|
||||
await click("teamSetupAdd");
|
||||
await waitFor(async () => (await teamsNow()).length === 1, "first team added");
|
||||
await click("teamSetupAdd");
|
||||
await waitFor(async () => (await teamsNow()).length === 2, "second team added");
|
||||
const [first, second] = await teamsNow();
|
||||
await setValue(`[data-team-name="${first.id}"]`, "Membership Team A");
|
||||
await waitFor(async () => (await teamsNow()).some((team) => team.name === "Membership Team A"), "team A renamed");
|
||||
await setValue(`[data-team-name="${second.id}"]`, "Membership Team B");
|
||||
await waitFor(async () => (await teamsNow()).some((team) => team.name === "Membership Team B"), "team B renamed");
|
||||
await setValue(`[data-team-add="${first.id}"]`, driverA.id);
|
||||
await waitFor(async () => (await teamsNow())[0].driverIds.includes(driverA.id), "driver A on team A");
|
||||
await setValue(`[data-team-add="${second.id}"]`, driverB.id);
|
||||
await waitFor(async () => (await teamsNow())[1].driverIds.includes(driverB.id), "driver B on team B");
|
||||
|
||||
await evaluate(`(() => { const form = document.getElementById("teamForm"); form.elements.namedItem("teamName").value = "Membership Team B"; })()`);
|
||||
await evaluate(`document.querySelector('[form="teamForm"][name="teamDriverIds"][value="${driverB.id}"]').checked = true`);
|
||||
await submit("teamForm");
|
||||
await waitFor(async () => (await findEvent(raceEvent.id)).raceConfig.teams.some((team) => team.name === "Membership Team B"), "team B created");
|
||||
const teamB = (await findEvent(raceEvent.id)).raceConfig.teams.find((team) => team.name === "Membership Team B");
|
||||
const hintText = await evaluate(`document.querySelector('[data-team-add="${second.id}"] option[value="${driverA.id}"]')?.textContent || ""`);
|
||||
assert.match(hintText, /Membership Team A/, "the add list names the other team a driver is currently on, before the move happens");
|
||||
|
||||
await click("team-edit-" + teamB.id);
|
||||
await waitFor(async () => await evaluate(`Boolean(document.getElementById("teamEditForm"))`), "team B edit form open");
|
||||
const hintText = await evaluate(`document.querySelector('#teamEditForm [name="teamDriverIds"][value="${driverA.id}"]')?.closest("label")?.textContent || ""`);
|
||||
assert.match(hintText, /Membership Team A/, "the edit form names the other team a driver is currently on, before the move happens");
|
||||
|
||||
await evaluate(`document.querySelector('#teamEditForm [name="teamDriverIds"][value="${driverA.id}"]').checked = true`);
|
||||
await pause(5500); // outlast the periodic version poll, matching the existing team-edit browser coverage
|
||||
await click("teamEditSave");
|
||||
await waitFor(async () => (await findEvent(raceEvent.id)).raceConfig.teams.find((team) => team.name === "Membership Team B").driverIds.includes(driverA.id), "driver A saved onto team B");
|
||||
await setValue(`[data-team-add="${second.id}"]`, driverA.id);
|
||||
await waitFor(async () => (await teamsNow()).find((team) => team.name === "Membership Team B").driverIds.includes(driverA.id), "driver A saved onto team B");
|
||||
|
||||
const afterMove = await findEvent(raceEvent.id);
|
||||
const teamA = afterMove.raceConfig.teams.find((team) => team.name === "Membership Team A");
|
||||
|
||||
Reference in new issue
Block a user