refactor!: support RUB only (WealthLedger/main#55) (#168)
Frontend verify / commits (push) Skipped
Frontend verify / security (push) Successful in 11s
Frontend verify / verify (push) Failing after 9m0s

This commit was merged in pull request #168.
This commit is contained in:
2026-11-11 09:36:29 +03:00
parent e2062ce837
commit 2b94a16ae5
55 changed files with 540 additions and 1153 deletions
@@ -31,16 +31,26 @@ function configureTestAuth() {
});
}
function portfolioSummary(totals: { currency: string; value: string }[]) {
function portfolioSummary(totals: { currency: string; value: string }) {
return {
bondPositionCount: 1,
cashBalances: [],
cash: { currency: "RUB", value: "0" },
fundPositionCount: 0,
stockPositionCount: 0,
structure: { currencies: [], unvaluedCategories: [] },
structure: {
categories: [],
hasNegativeValues: false,
totalValue: "0",
unvaluedCategories: [],
},
totalPositionCount: 1,
totalsByCurrency: totals,
unrealizedReturnByCurrency: [],
totals,
unrealizedReturn: {
absolute: "0",
costBasis: "0",
partial: false,
percent: null,
},
};
}
@@ -59,23 +69,18 @@ function renderPage(queryClient: QueryClient) {
}
describe("AccountsPage", () => {
it("summarizes currencies separately and reports excluded accounts", async () => {
it("summarizes account totals and reports excluded accounts", async () => {
server.use(http.get("*/api/v1/brokerage-accounts", () =>
HttpResponse.json(resource([
{
...account,
portfolioSummary: portfolioSummary([
{ currency: "RUB", value: "100.10" },
{ currency: "USD", value: "20" },
]),
portfolioSummary: portfolioSummary({ currency: "RUB", value: "100.10" }),
},
{
...account,
id: "account-2",
name: "Второй",
portfolioSummary: portfolioSummary([
{ currency: "RUB", value: "50.20" },
]),
portfolioSummary: portfolioSummary({ currency: "RUB", value: "50.20" }),
},
{
...account,
@@ -88,9 +93,9 @@ describe("AccountsPage", () => {
id: "account-4",
name: "Только деньги",
portfolioSummary: {
...portfolioSummary([{ currency: "RUB", value: "25" }]),
...portfolioSummary({ currency: "RUB", value: "25" }),
bondPositionCount: 0,
cashBalances: [{ currency: "RUB", value: "25" }],
cash: { currency: "RUB", value: "25" },
totalPositionCount: 0,
},
},
@@ -99,7 +104,7 @@ describe("AccountsPage", () => {
id: "account-5",
name: "Без сумм",
portfolioSummary: {
...portfolioSummary([]),
...portfolioSummary({ currency: "RUB", value: "0" }),
totalPositionCount: 0,
},
},
@@ -110,7 +115,6 @@ describe("AccountsPage", () => {
renderPage(client);
expect(await screen.findByText("175,30 ₽")).toBeInTheDocument();
expect(screen.getAllByText("20,00 $")).not.toHaveLength(0);
expect(screen.queryByText("Ваши инвестиции по счетам"))
.not.toBeInTheDocument();
expect(screen.getByText("5 счетов")).toBeInTheDocument();