ui/phase-22: skip the no-op stance click in the races table
Clicking the already-active WAR/PEACE button still appended a \`setDiplomaticStance\` whose \`relation\` matched the row's current value. The engine would accept the duplicate harmlessly, but the order tab inflates with rows that say nothing and every auto-sync re-ships the redundant payload. Compare against the overlayed stance (so a queued-but-not-applied change suppresses a re-click that matches the *intended* state, not just the server snapshot) and short-circuit when they agree. Mirrors the vote picker, which already had the same guard. vitest.config.ts: \`mergeConfig\` refuses callback-form base configs, so resolve \`vite.config.ts\`'s callback with the test context first and merge the plain object. Surfaced after the \`loadEnv\` migration switched the root config to the callback form. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -226,6 +226,18 @@ describe("races table", () => {
|
||||
expect(names).toEqual(["Beta", "Gamma", "Alpha"]);
|
||||
});
|
||||
|
||||
test("clicking the already-active stance is a no-op (no command queued)", async () => {
|
||||
const ui = mountTable(
|
||||
makeReport([race({ name: "Andori", relation: "WAR" })]),
|
||||
);
|
||||
await fireEvent.click(ui.getByTestId("races-stance-war"));
|
||||
// Give the async handler one microtask to settle, then assert
|
||||
// the draft remained empty — the click matched the current
|
||||
// stance, so nothing should land in the order queue.
|
||||
await Promise.resolve();
|
||||
expect(draft.commands).toHaveLength(0);
|
||||
});
|
||||
|
||||
test("clicking PEACE on a WAR row appends setDiplomaticStance and flips the overlay", async () => {
|
||||
const ui = mountTable(
|
||||
makeReport([race({ name: "Andori", relation: "WAR" })]),
|
||||
|
||||
Reference in New Issue
Block a user