feat(ui): F8-05 — game-mode chrome cleanup + inspector compact rows (#48)
Drains six F8 polish items (parent #43) in one feature: а) Chrome cleanup - п.6 — remove the AccountMenu (settings/sessions/theme/language/logout ∼ rudimentary in-game) and replace it with a single icon-button light/dark theme toggle. The toggle flips an in-memory `theme.override`; game-shell unmount calls `theme.clearOverride()` so the lobby (and any re-entry) re-projects the persisted lobby choice. - п.8 — remove the wrap-scrolling radio from the map gear popover. The per-game `wrapMode` store and the renderer's no-wrap path stay in place for a future engine-side topology feature; only the UI surface is dropped (wrap is a server-side concept, not a per-session UI affordance). б) Inspector compact rows (single idiom: select + ✓ apply / ✗ cancel, or contextual edit/remove/add) - п.13 — planet name is now click-to-edit: clicking the name opens an inline `<input>` + ✓ confirm icon; Escape cancels; the explicit Rename action button and Cancel button are gone. - п.14 — production becomes one row: primary `<select>` picks industry/materials/research/ship, conditional secondary `<select>` picks the target (tech / science / ship class) for research and ship contexts. Apply is gated until row state differs from the planet's current effective production; auto-submit-on-click is replaced by the apply-gate. - п.16 — cargo routes collapse to one row: a single dropdown (COL/CAP/MAT/EMP plus a placeholder that absorbs the old section title) and contextual action buttons (add / edit + remove) to the right. After a successful pick or remove the dropdown stays on the type the user just acted on. - п.32 — stationed ship groups hoist the race column into a dropdown above the table. The dropdown seeds with the player's own race when local groups are stationed here, otherwise the first race alphabetically; rendered only when more than one race is in orbit. The race column is dropped in both single- and multi-race modes — the dropdown's value already names the active race. Tests: unit and Playwright e2e updated for every changed test-id and flow; new coverage added for `theme.override`, the in-game toggle, the apply-gate behaviour, and the stationed-race dropdown. i18n keys for the removed menu items, the wrap radios, the cargo title, and the explicit `rename.cancel` are dropped from both locales; new `game.shell.theme_toggle.*`, `production.main/target.*`, `production.apply/cancel`, `cargo.placeholder`, and `ship_groups.race_filter.aria` keys land. Docs synced: `docs/FUNCTIONAL.md` §6.7 + `docs/FUNCTIONAL_ru.md` mirror drop the torus / no-wrap radio mention; `ui/docs/design-system.md` documents the lobby-owned persisted picker + the in-game ephemeral override channel. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,11 +1,17 @@
|
||||
// Vitest coverage for the Phase 19 follow-up "stationed ship groups"
|
||||
// subsection of the planet inspector. Phase 19 originally rendered
|
||||
// every in-orbit group as a small offset point on the map; the
|
||||
// resulting visual noise pushed the listing into this subsection
|
||||
// (`lib/inspectors/planet/ship-groups.svelte`) instead.
|
||||
// Vitest coverage for the "stationed ship groups" subsection of the
|
||||
// planet inspector. The map deliberately hides on-planet groups; this
|
||||
// subsection is the player's view of the fleets in orbit.
|
||||
//
|
||||
// F8-05 (issue #48 п.32) moved the race column from the row into a
|
||||
// dropdown above the table. The dropdown only renders when more than
|
||||
// one race is stationed; it seeds with the player's own race when
|
||||
// local groups are stationed here, otherwise with the first race
|
||||
// alphabetically. Single-race cases skip the dropdown and render
|
||||
// straight through. The race column is dropped in both modes — the
|
||||
// dropdown's value already names the active race.
|
||||
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { render } from "@testing-library/svelte";
|
||||
import { fireEvent, render } from "@testing-library/svelte";
|
||||
import { beforeEach, describe, expect, test } from "vitest";
|
||||
|
||||
import { i18n } from "../src/lib/i18n/index.svelte";
|
||||
@@ -86,7 +92,7 @@ function otherGroup(
|
||||
}
|
||||
|
||||
describe("planet inspector — stationed ship groups", () => {
|
||||
test("renders one row per in-orbit local group with the player's race", () => {
|
||||
test("renders one row per in-orbit local group; the dropdown is hidden with a single race", () => {
|
||||
const ui = render(ShipGroups, {
|
||||
props: {
|
||||
planet: HOME_PLANET,
|
||||
@@ -100,7 +106,13 @@ describe("planet inspector — stationed ship groups", () => {
|
||||
});
|
||||
const rows = ui.getAllByTestId("inspector-planet-ship-groups-row");
|
||||
expect(rows.length).toBe(2);
|
||||
expect(rows[0]).toHaveTextContent("Earthlings");
|
||||
// Race no longer appears in the row (it is hoisted to the
|
||||
// dropdown — and the dropdown itself is hidden when only one
|
||||
// race is present).
|
||||
expect(
|
||||
ui.queryByTestId("inspector-planet-ship-groups-race-filter"),
|
||||
).toBeNull();
|
||||
expect(rows[0]).not.toHaveTextContent("Earthlings");
|
||||
expect(rows[0]).toHaveTextContent("Frontier");
|
||||
expect(rows[0]).toHaveTextContent("2");
|
||||
expect(rows[0]).toHaveTextContent("24");
|
||||
@@ -108,6 +120,66 @@ describe("planet inspector — stationed ship groups", () => {
|
||||
expect(rows[1]).toHaveTextContent("173.25");
|
||||
});
|
||||
|
||||
test("multiple races surface a dropdown that filters the table", async () => {
|
||||
const ui = render(ShipGroups, {
|
||||
props: {
|
||||
planet: FOREIGN_PLANET,
|
||||
localShipGroups: [
|
||||
localGroup({ id: "own-1", destination: 99, class: "Frontier" }),
|
||||
],
|
||||
otherShipGroups: [
|
||||
otherGroup({ class: "Bird-of-Prey", destination: 99 }),
|
||||
],
|
||||
localRace: "Earthlings",
|
||||
},
|
||||
});
|
||||
const select = ui.getByTestId(
|
||||
"inspector-planet-ship-groups-race-filter",
|
||||
) as HTMLSelectElement;
|
||||
// Own ships are stationed → own race wins as the default;
|
||||
// alphabetical ordering puts the foreign one second.
|
||||
expect(select.value).toBe("Earthlings");
|
||||
expect(Array.from(select.options).map((o) => o.value)).toEqual([
|
||||
"Earthlings",
|
||||
"Klingons",
|
||||
]);
|
||||
expect(
|
||||
ui.getAllByTestId("inspector-planet-ship-groups-row").length,
|
||||
).toBe(1);
|
||||
expect(
|
||||
ui.getByTestId("inspector-planet-ship-groups-row"),
|
||||
).toHaveTextContent("Frontier");
|
||||
|
||||
await fireEvent.change(select, { target: { value: "Klingons" } });
|
||||
const rows = ui.getAllByTestId("inspector-planet-ship-groups-row");
|
||||
expect(rows.length).toBe(1);
|
||||
expect(rows[0]).toHaveTextContent("Bird-of-Prey");
|
||||
});
|
||||
|
||||
test("with no own ships the dropdown collapses to the single foreign race", () => {
|
||||
const ui = render(ShipGroups, {
|
||||
props: {
|
||||
planet: {
|
||||
...HOME_PLANET,
|
||||
owner: "Andorians",
|
||||
kind: "other",
|
||||
},
|
||||
localShipGroups: [],
|
||||
otherShipGroups: [
|
||||
otherGroup({ class: "Bird-of-Prey", destination: 17 }),
|
||||
],
|
||||
localRace: "Earthlings",
|
||||
},
|
||||
});
|
||||
// Single foreign race → no dropdown.
|
||||
expect(
|
||||
ui.queryByTestId("inspector-planet-ship-groups-race-filter"),
|
||||
).toBeNull();
|
||||
expect(
|
||||
ui.getAllByTestId("inspector-planet-ship-groups-row").length,
|
||||
).toBe(1);
|
||||
});
|
||||
|
||||
test("filters out groups stationed on a different planet", () => {
|
||||
const ui = render(ShipGroups, {
|
||||
props: {
|
||||
@@ -147,20 +219,6 @@ describe("planet inspector — stationed ship groups", () => {
|
||||
);
|
||||
});
|
||||
|
||||
test("foreign-planet visitors fall back to the planet owner's race", () => {
|
||||
const ui = render(ShipGroups, {
|
||||
props: {
|
||||
planet: FOREIGN_PLANET,
|
||||
localShipGroups: [],
|
||||
otherShipGroups: [otherGroup({ destination: 99 })],
|
||||
localRace: "Earthlings",
|
||||
},
|
||||
});
|
||||
const row = ui.getByTestId("inspector-planet-ship-groups-row");
|
||||
expect(row).toHaveTextContent("Klingons");
|
||||
expect(row).toHaveTextContent("Bird-of-Prey");
|
||||
});
|
||||
|
||||
test("subsection collapses entirely when nothing is stationed", () => {
|
||||
const ui = render(ShipGroups, {
|
||||
props: {
|
||||
|
||||
Reference in New Issue
Block a user