Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/client/StatsConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const COLUMN_IDS = [
export type ColumnId = (typeof COLUMN_IDS)[number];

export const DEFAULT_STATS_COLUMNS = {
player: ["clan", "tiles", "gold", "maxtroops"],
player: ["tiles", "gold", "maxtroops"],
team: ["tiles", "gold", "maxtroops"],
} as const satisfies Record<StatsTableKind, readonly ColumnId[]>;

Expand Down
19 changes: 12 additions & 7 deletions tests/PlayerStats.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ describe("PlayerStats", () => {

const content = playerStats.querySelector(".stats-table-content");
expect(content?.classList).toContain("min-w-full");
// Only selected stat tracks share definite spare space. Rank, the clan
// column, name, and picker remain fixed and never stretch.
// Only selected stat tracks share definite spare space. Rank, name, and
// picker remain fixed and never stretch.
expect(content?.getAttribute("style")).toContain(
"34px 80px 100px auto auto auto 32px",
"34px 100px auto auto auto 32px",
);

playerStats.remove();
Expand Down Expand Up @@ -108,7 +108,7 @@ describe("PlayerStats", () => {
expect(table?.querySelector(".stats-table-header")).not.toBeNull();
const goldHeader = playerStats.querySelectorAll(
'.stats-table-header > [role="columnheader"]',
)[4];
)[3];
expect(goldHeader.querySelector("img")?.getAttribute("src")).toBe(
goldCoinIcon,
);
Expand Down Expand Up @@ -191,6 +191,13 @@ describe("PlayerStats clan column", () => {
(
UserSettings as unknown as { cache: Map<string, string | null> }
).cache.clear();
// Off by default; these tests turn it on in the picker.
new UserSettings().setStatsColumns("player", [
"clan",
"tiles",
"gold",
"maxtroops",
]);
});

afterEach(() => {
Expand Down Expand Up @@ -282,10 +289,8 @@ describe("PlayerStats clan column", () => {
).toEqual(["ABCDE", ""]);
});

it("is on by default and disappears when deselected in the picker", async () => {
it("disappears when deselected in the picker", async () => {
const settings = new UserSettings();
expect(settings.statsColumns("player")).toContain("clan");

settings.setStatsColumns("player", ["tiles", "gold", "maxtroops"]);
const playerStats = await mount([player("alice", 3, "ABCDE")]);

Expand Down
2 changes: 1 addition & 1 deletion tests/StatsColumns.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe("Stats column registry", () => {
expect(columnById(id).kinds).toContain(kind);
}
}
expect(DEFAULT_STATS_COLUMNS.player).toContain("clan");
expect(DEFAULT_STATS_COLUMNS.player).not.toContain("clan");
expect(DEFAULT_STATS_COLUMNS.team).not.toContain("clan");
});

Expand Down
5 changes: 1 addition & 4 deletions tests/UserSettings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,8 @@ describe("UserSettings stats columns", () => {
beforeEach(resetUserSettingsState);

it("returns defaults when nothing is stored", () => {
// The player table opens with the clan tag shown; a team has no tag.
// The clan column is opt-in, so both tables open with the same stats.
expect(new UserSettings().statsColumns("player")).toEqual([
"clan",
"tiles",
"gold",
"maxtroops",
Expand Down Expand Up @@ -398,7 +397,6 @@ describe("UserSettings stats columns", () => {
it("falls back to defaults on corrupt JSON", () => {
localStorage.setItem(PLAYER_STATS_COLUMNS_KEY, "not json");
expect(new UserSettings().statsColumns("player")).toEqual([
"clan",
"tiles",
"gold",
"maxtroops",
Expand All @@ -408,7 +406,6 @@ describe("UserSettings stats columns", () => {
it("falls back to defaults when no valid ids remain", () => {
localStorage.setItem(PLAYER_STATS_COLUMNS_KEY, JSON.stringify(["bogus"]));
expect(new UserSettings().statsColumns("player")).toEqual([
"clan",
"tiles",
"gold",
"maxtroops",
Expand Down
Loading