feat(portfolio): extend instrument logo rendering to bonds

- Rename presentation prop stock→wide; BOND section passes wide alongside STOCK
- Add bond test cases: CDN logo, fallback, signed return, single-column grid
- Add other-type regression test (no logo, labeled return preserved)
- Update bundle baseline (+4 bytes)
This commit is contained in:
2026-08-25 09:25:29 +03:00
parent a6d3051270
commit c04025a392
3 changed files with 104 additions and 12 deletions
+92 -1
View File
@@ -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(
<AccountPageLoaded
portfolio={{
...portfolio,
positions: [
{
figi: "FIGI-C",
displayName: "Долг",
type: "BOND",
quantity: "5",
currentValue: { currency: "RUB", value: "50" },
averagePurchasePrice: null,
absoluteReturn: { currency: "RUB", value: "2" },
isin: "RU000C0XY1Z3",
logoName: "dolg.png",
},
{
figi: "FIGI-D",
displayName: "Купон",
type: "BOND",
quantity: "1",
currentValue: null,
averagePurchasePrice: null,
absoluteReturn: { currency: "RUB", value: "0" },
isin: null,
logoName: null,
},
],
}}
/>,
);
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(
<AccountPageLoaded
portfolio={{
...portfolio,
positions: [portfolio.positions[1]],
}}
/>,
);
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(
<AccountPageLoaded
portfolio={{
...portfolio,
positions: [
{
figi: "FIGI-E",
displayName: "Фонд",
type: "FUND",
quantity: "3",
currentValue: { currency: "RUB", value: "30" },
averagePurchasePrice: null,
absoluteReturn: { currency: "RUB", value: "-5" },
isin: null,
logoName: "fond.png",
},
],
}}
/>,
);
expect(screen.getByText("Доход: -5 ₽")).toBeInTheDocument();
expect(screen.queryByRole("img", { name: "Фонд" })).not.toBeInTheDocument();
});
it("uses the cached account title when available", () => {
renderPage(
<AccountPageLoaded