test: keep portfolio metadata authoritative in cards

This commit is contained in:
2026-09-12 15:38:04 +03:00
parent a42f104bed
commit 427ca23a43
+29 -6
View File
@@ -123,11 +123,13 @@ function emptyProps() {
describe("AccountPage states", () => {
it.each(
["account-1", "all"].flatMap((accountId) =>
["STOCK", "BOND"].map((type) => ({ accountId, type })),
["STOCK", "BOND"].flatMap((type) =>
[true, false].map((hasMetadata) => ({ accountId, type, hasMetadata })),
),
),
)(
"links name and logo to the exact issue in $accountId for $type",
async ({ accountId, type }) => {
"keeps portfolio metadata authoritative and links the exact issue in $accountId for $type (metadata: $hasMetadata)",
async ({ accountId, type, hasMetadata }) => {
const collection = type === "STOCK" ? "stocks" : "bonds";
const slug = type === "STOCK" ? "SBERP" : "SU26238RMFS4";
const uid = "c190ff1f-1447-4227-b543-316332699ca5";
@@ -136,8 +138,9 @@ describe("AccountPage states", () => {
...portfolio.positions[0],
type,
instrumentUid: uid,
ticker: slug,
displayName: "Сбербанк привилегированные",
ticker: hasMetadata ? slug : null,
displayName: hasMetadata ? "Сбербанк привилегированные" : "FIGI-2",
logoName: hasMetadata ? "vtoraya.png" : null,
};
server.use(
http.get("*/api/v1/brokerage-accounts/:accountId/portfolio", () =>
@@ -154,7 +157,14 @@ describe("AccountPage states", () => {
),
http.get(`*/api/v1/${collection}/:uid`, () => {
requests();
return HttpResponse.json({ instrumentUid: uid, slug });
return HttpResponse.json({
instrumentUid: uid,
slug,
name: "Название из карточки инструмента",
ticker: "OTHER-TICKER",
isin: "OTHER-ISIN",
logoName: "other.png",
});
}),
);
configureTestAuth();
@@ -171,6 +181,19 @@ describe("AccountPage states", () => {
);
});
expect(requests).toHaveBeenCalledTimes(type === "STOCK" ? 1 : 0);
expect(
screen.queryByText("Название из карточки инструмента"),
).not.toBeInTheDocument();
expect(
screen.queryByText(/OTHER-TICKER|OTHER-ISIN/),
).not.toBeInTheDocument();
const logo = screen.queryByRole("img", { name: position.displayName });
if (hasMetadata)
expect(logo).toHaveAttribute(
"src",
"https://invest-brands.cdn-tinkoff.ru/vtorayax160.png",
);
else expect(logo).not.toBeInTheDocument();
},
);