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
18 changes: 17 additions & 1 deletion src/components/PrintView.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,23 @@ import { addUnit, createList, toggleUnitScouting } from "../domain/lists";
import { totalScoutingPoints } from "../domain/scouting";
import { PrintList } from "./PrintView";

describe("PrintList scouting commitments", () => {
describe("PrintList", () => {
it("prints the breakpoint and unit type", () => {
const army = getArmy("warmaster-revolution", "dwarfs")!;
const list = createList("warmaster-revolution", army.version, army.army, "Dwarfs", 2000);
list.units = [
{ unitId: "dwarfs:warriors", quantity: 5, upgrades: [], magicItems: [] },
];

render(<PrintList list={list} army={army} />);

expect(screen.getByText(/Dwarfs · Warmaster Revolution/)).toHaveTextContent(
`Dwarfs · Warmaster Revolution ${army.version} · 550/2000 pts · Breakpoint: 3`,
);
expect(screen.getByRole("columnheader", { name: "Type" })).toBeInTheDocument();
expect(screen.getByText("Warriors").closest("tr")).toHaveTextContent("Infantry");
});

it("prints committed scouting units and their total", () => {
const army = getArmy("warmaster-revolution", "dwarfs")!;
let list = createList("warmaster-revolution", army.version, army.army, "Scouts", 1000);
Expand Down
6 changes: 4 additions & 2 deletions src/components/PrintView.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { CSSProperties } from "react";
import type { ArmyData, SavedCharacterEntry, SavedList, SavedUnitEntry } from "../types";
import { getUnit } from "../data/gameData";
import { entryPoints, totalPoints } from "../domain/lists";
import { breakPoint, entryPoints, totalPoints } from "../domain/lists";
import { getMagicItem } from "../domain/magicItems";
import { entryScoutingPoints, totalScoutingPoints } from "../domain/scouting";
import {
Expand Down Expand Up @@ -104,7 +104,7 @@ export function PrintList({
<h1>{list.name}</h1>
<p>
{army.name} · Warmaster Revolution {list.ruleVersion} · {totalPoints(list, army)}/
{list.pointsLimit} pts
{list.pointsLimit} pts · Breakpoint: {breakPoint(list)}
{scoutingEnabled ? ` · Scouting units: ${totalScoutingPoints(list, army)} SP` : ""}
</p>
</header>
Expand All @@ -113,6 +113,7 @@ export function PrintList({
<tr>
<th>Qty</th>
<th>Unit</th>
<th>Type</th>
<th>Melee Attacks</th>
<th>Ranged Attacks</th>
<th>Bonus Attacks</th>
Expand All @@ -131,6 +132,7 @@ export function PrintList({
<tr key={i}>
<td>{row.quantity}</td>
<td>{row.label}</td>
<td>{unit?.type ?? "-"}</td>
<td>{unit ? (meleeAttacksLabel(unit) ?? "-") : "-"}</td>
<td>{unit ? (rangedAttacksLabel(unit) ?? "-") : "-"}</td>
<td>{unit?.bonusAttacks != null ? signedLabel(unit.bonusAttacks) : "-"}</td>
Expand Down
8 changes: 7 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import { cloudflare } from "@cloudflare/vite-plugin";

export default defineConfig({
plugins: [react(), cloudflare()],
// Most of the entry chunk is static army-list data. Its current 795 kB
// minified size compresses to about 167 kB over the network, so keep a
// slightly higher warning budget while still flagging meaningful growth.
build: {
chunkSizeWarningLimit: 850,
},
// 5273 instead of Vite's default 5173, which collides with another local
// app. Overridable via PORT or --port (Playwright's web server uses 5177).
server: process.env.PORT
Expand All @@ -19,4 +25,4 @@ export default defineConfig({
// layout tests live in tests/ and run separately via `npm run test:layout`.
include: ["src/**/*.test.{ts,tsx}", "scripts/**/*.test.mjs"],
},
});
});