feat: show persisted investment data and sync state
Consume the provided resource-envelope API snapshot. Preserve financial snapshots during refresh, observe synchronization without importing, and fence late responses across account and connection changes.
This commit is contained in:
@@ -2,6 +2,7 @@ import { MantineProvider } from "@mantine/core";
|
||||
import { render, screen, within } from "@testing-library/react";
|
||||
import { MemoryRouter } from "react-router";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { resource } from "@/test/resource";
|
||||
import { brokerageAccountCards } from "../../model/display";
|
||||
import { BrokerageAccountList } from "./BrokerageAccountList";
|
||||
|
||||
@@ -84,3 +85,42 @@ describe("BrokerageAccountList", () => {
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("shows portfolio summary freshness independently for each account", () => {
|
||||
const accounts = brokerageAccountCards(
|
||||
["fresh", "stale"].map((id) => ({
|
||||
id,
|
||||
name: id,
|
||||
type: "BROKERAGE" as const,
|
||||
openedOn: null,
|
||||
portfolioSummary: {
|
||||
stockPositionCount: 1,
|
||||
bondPositionCount: 0,
|
||||
totalsByCurrency: [{ currency: "RUB", value: "10" }],
|
||||
},
|
||||
})),
|
||||
[
|
||||
resource(null, { resourceKey: "portfolio/fresh", freshness: "fresh" })
|
||||
.meta,
|
||||
resource(null, { resourceKey: "portfolio/stale", freshness: "stale" })
|
||||
.meta,
|
||||
],
|
||||
);
|
||||
render(
|
||||
<MantineProvider>
|
||||
<MemoryRouter>
|
||||
<BrokerageAccountList accounts={accounts} />
|
||||
</MemoryRouter>
|
||||
</MantineProvider>,
|
||||
);
|
||||
expect(
|
||||
within(screen.getByRole("link", { name: /stale/ })).getByText(
|
||||
"Данные требуют обновления",
|
||||
),
|
||||
).toBeVisible();
|
||||
expect(
|
||||
within(screen.getByRole("link", { name: /fresh/ })).queryByText(
|
||||
"Данные требуют обновления",
|
||||
),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user