diff --git a/scripts/lazy-route-bundle-baseline.json b/scripts/lazy-route-bundle-baseline.json index 967e7eb..f8254bd 100644 --- a/scripts/lazy-route-bundle-baseline.json +++ b/scripts/lazy-route-bundle-baseline.json @@ -2,7 +2,7 @@ "src/app/routes/ProtectedLayout.tsx": 3137, "src/pages/account-events/index.ts": 4468, "src/pages/account-operations/index.ts": 13861, - "src/pages/account/index.ts": 21868, + "src/pages/account/index.ts": 21872, "src/pages/accounts/index.ts": 6174, "src/pages/login/index.ts": 669, "src/pages/not-found/index.ts": 850, diff --git a/src/pages/account/ui/AccountPage.test.tsx b/src/pages/account/ui/AccountPage.test.tsx index 67c0122..eb5104c 100644 --- a/src/pages/account/ui/AccountPage.test.tsx +++ b/src/pages/account/ui/AccountPage.test.tsx @@ -123,7 +123,8 @@ describe("AccountPage states", () => { .map((element) => element.textContent); expect(positions).toEqual(["Вторая", "Первая"]); expect(screen.getByText("10 ₽")).toBeInTheDocument(); - expect(screen.getByText("Доход: -1 ₽")).toBeInTheDocument(); + expect(screen.getByText("-1 ₽")).toBeInTheDocument(); + expect(screen.queryByText(/Доход:/)).not.toBeInTheDocument(); expect(screen.getByText("Средняя цена: 11 ₽")).toBeInTheDocument(); expect(screen.getByText("Доля: 100 %")).toBeInTheDocument(); expect(screen.getByText("RU000A0JX0J2")).toBeInTheDocument(); @@ -173,6 +174,96 @@ describe("AccountPage states", () => { expect(screen.queryByRole("img", { name: "Абра" })).not.toBeInTheDocument(); }); + it("renders bond cards with logo, fallback, and signed unlabeled return like stocks", () => { + renderPage( + , + ); + expect(screen.getByRole("img", { name: "Долг" })).toHaveAttribute( + "src", + "https://invest-brands.cdn-tinkoff.ru/dolgx160.png", + ); + expect(screen.getByText("К")).toBeInTheDocument(); + expect( + screen.queryByRole("img", { name: "Купон" }), + ).not.toBeInTheDocument(); + expect(screen.getByText("+2 ₽")).toBeInTheDocument(); + expect(screen.getByText("0 ₽")).toBeInTheDocument(); + expect(screen.queryByText(/Доход:/)).not.toBeInTheDocument(); + }); + + it("renders the bonds section as a single-column grid on any screen width", () => { + renderPage( + , + ); + const singleColumnGrids = Array.from(document.querySelectorAll("style")) + .map((style) => (style.textContent ?? "").replace(/\s/g, "")) + .filter( + (css) => + css.includes("--sg-cols:1") && + !css.includes("@media") && + !/--sg-cols:[23]/.test(css), + ); + expect(singleColumnGrids).toHaveLength(1); + }); + + it("keeps other-position cards compact with labeled return and no logo", () => { + renderPage( + , + ); + expect(screen.getByText("Доход: -5 ₽")).toBeInTheDocument(); + expect(screen.queryByRole("img", { name: "Фонд" })).not.toBeInTheDocument(); + }); + it("uses the cached account title when available", () => { renderPage( ) : null} {bonds.length ? ( @@ -199,6 +199,7 @@ export function AccountPageLoaded({ title={t("portfolio.bonds")} positions={bonds} denominators={denominators} + wide /> ) : null} {other.length ? ( @@ -353,22 +354,22 @@ function PositionSection({ title, positions, denominators, - stock = false, + wide = false, }: { title: string; positions: Portfolio["positions"]; denominators: Map; - stock?: boolean; + wide?: boolean; }) { return (
- + {positions.map((position) => ( ))} @@ -378,11 +379,11 @@ function PositionSection({ function PositionCard({ position, denominators, - stock = false, + wide = false, }: { position: Portfolio["positions"][number]; denominators: Map; - stock?: boolean; + wide?: boolean; }) { const { t } = useTranslation(); const share = position.currentValue?.currency @@ -399,17 +400,17 @@ function PositionCard({ : undefined : undefined; const returnText = position.absoluteReturn - ? stock + ? wide ? `${Number(position.absoluteReturn.value) > 0 ? "+" : ""}${formatMoney(position.absoluteReturn)}` : t("portfolio.return", { value: formatMoney(position.absoluteReturn), }) : null; - const logoSrc = stock ? instrumentLogoUrl(position.logoName) : null; + const logoSrc = wide ? instrumentLogoUrl(position.logoName) : null; return ( - {stock ? ( + {wide ? (