feat: group all-account rows by instrument and day (WealthLedger/main#47) (#126)
This commit was merged in pull request #126.
This commit is contained in:
@@ -11,6 +11,7 @@ import { http, HttpResponse } from "msw";
|
||||
import { MemoryRouter, Route, Routes } from "react-router";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import type { BrokerageOperation } from "@/entities/broker-operation";
|
||||
import type { BrokerageEvent } from "@/entities/brokerage-event";
|
||||
|
||||
import { type Portfolio, portfolioQueryOptions } from "@/entities/portfolio";
|
||||
@@ -1084,4 +1085,72 @@ describe("AccountPage states", () => {
|
||||
expect(screen.queryByRole("region", { name: "Нереализованный результат" }))
|
||||
.not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("groups overview items only after the existing five-item limits", async () => {
|
||||
const operations = Array.from({ length: 6 }, (_, index) => ({
|
||||
account: { id: `account-${index}`, name: `Счёт ${index + 1}` },
|
||||
accruedInterest: null,
|
||||
category: "income",
|
||||
commission: null,
|
||||
description: "Купон",
|
||||
figi: "FIGI",
|
||||
id: `operation-${index}`,
|
||||
instrumentType: "bond",
|
||||
instrumentUid: "UID",
|
||||
logoName: null,
|
||||
occurredAt: "2026-08-14T10:00:00Z",
|
||||
payment: { currency: "RUB", value: "100" },
|
||||
price: null,
|
||||
quantity: null,
|
||||
ticker: "BOND",
|
||||
type: "OPERATION_TYPE_COUPON",
|
||||
})) satisfies BrokerageOperation[];
|
||||
|
||||
const events = Array.from({ length: 6 }, (_, index) => ({
|
||||
account: { id: `account-${index}`, name: `Счёт ${index + 1}` },
|
||||
date: "2026-08-20",
|
||||
dateKind: "event",
|
||||
displayName: "ОФЗ 26238",
|
||||
figi: "FIGI",
|
||||
instrumentUid: "UID",
|
||||
isin: "RU000A0JX0J2",
|
||||
logoName: null,
|
||||
projectedAmount: { currency: "RUB", value: "100" },
|
||||
ticker: "OFZ",
|
||||
type: "coupon",
|
||||
})) satisfies BrokerageEvent[];
|
||||
|
||||
server.use(
|
||||
http.get("*/api/v1/brokerage-accounts/:accountId/operations", () =>
|
||||
HttpResponse.json(resource({
|
||||
accountId: "all",
|
||||
hasNext: true,
|
||||
items: operations.slice(0, 5),
|
||||
nextCursor: "next",
|
||||
}))),
|
||||
http.get("*/api/v1/brokerage-accounts/:accountId/events", () =>
|
||||
HttpResponse.json(resource({
|
||||
accountId: "all",
|
||||
calculatedAt: "2026-08-14T00:00:00Z",
|
||||
events,
|
||||
}))),
|
||||
);
|
||||
renderAccountRoute(createTestQueryClient(), "all");
|
||||
await screen.findByRole("heading", { level: 1, name: "Все счета" });
|
||||
|
||||
const operationGroup = screen.getByRole("list", {
|
||||
name: /Купон · BOND, Исполнено/,
|
||||
});
|
||||
|
||||
expect(screen.getByText("+500 ₽")).toBeInTheDocument();
|
||||
expect(within(operationGroup).getAllByRole("listitem")).toHaveLength(5);
|
||||
expect(within(operationGroup).queryByRole("link")).not.toBeInTheDocument();
|
||||
|
||||
const eventGroup = screen.getByRole("list", {
|
||||
name: /Купон · ОФЗ 26238, 20\.08\.2026, 500 ₽/,
|
||||
});
|
||||
|
||||
expect(screen.getAllByText("500 ₽").length).toBeGreaterThan(0);
|
||||
expect(within(eventGroup).getAllByRole("listitem")).toHaveLength(5);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user