- The detail card now rides beside the clicked agent (flipping and clamping at viewport edges via a pure cardPositionFor helper) instead of pinning to the top-right corner; it follows a walking agent - Every agent - the CEO and busy agents included - periodically visits the coffee machine, snack bar, and restroom; work status no longer recalls a walker mid-break - The office convenes meetings around the meeting table every few minutes: at least two settled attendees walk over, dwell together on distinct table spots, and head back; a solo office never meets - Meeting spots ship as lane-wired amenities so pathing stays correct by construction; floor-plan invariants (collider-free, reachable) cover them automatically - e2e asserts the card opens beside the sprite, not in a corner
33 lines
1.5 KiB
TypeScript
33 lines
1.5 KiB
TypeScript
import { describe, expect, test } from "vitest";
|
|
import { cardPositionFor, CARD_W } from "../../src/renderer/src/pages/office/agent-card-position";
|
|
|
|
describe("agent detail card placement", () => {
|
|
test("sits to the right of the sprite, vertically centered on it", () => {
|
|
const position = cardPositionFor({ x: 400, y: 300 }, { x: 0, y: 0 }, 1200, 800, 170);
|
|
expect(position.left).toBe(418);
|
|
expect(position.top).toBe(300 - 16 - 85);
|
|
});
|
|
|
|
test("flips to the left when the right edge would leave the viewport", () => {
|
|
const position = cardPositionFor({ x: 1100, y: 300 }, { x: 0, y: 0 }, 1200, 800, 170);
|
|
expect(position.left).toBe(1100 - CARD_W - 18);
|
|
expect(position.left + CARD_W).toBeLessThanOrEqual(1200 - 8);
|
|
});
|
|
|
|
test("clamps fully on screen near every edge", () => {
|
|
for (const agent of [{ x: 5, y: 5 }, { x: 5, y: 795 }, { x: 1195, y: 5 }, { x: 1195, y: 795 }]) {
|
|
const position = cardPositionFor(agent, { x: 0, y: 0 }, 1200, 800, 170);
|
|
expect(position.left).toBeGreaterThanOrEqual(8);
|
|
expect(position.left + CARD_W).toBeLessThanOrEqual(1192);
|
|
expect(position.top).toBeGreaterThanOrEqual(8);
|
|
expect(position.top + 170).toBeLessThanOrEqual(792);
|
|
}
|
|
});
|
|
|
|
test("accounts for the camera offset", () => {
|
|
const onScreen = cardPositionFor({ x: 700, y: 500 }, { x: 300, y: 200 }, 1200, 800, 170);
|
|
const noCamera = cardPositionFor({ x: 400, y: 300 }, { x: 0, y: 0 }, 1200, 800, 170);
|
|
expect(onScreen).toEqual(noCamera);
|
|
});
|
|
});
|