fix(account): show source metadata on empty account and income (WealthLedger/frontend#55) (#133)
This commit was merged in pull request #133.
This commit is contained in:
@@ -18,6 +18,7 @@ import type { BrokerageEvent } from "@/entities/brokerage-event";
|
||||
|
||||
import { type Portfolio, portfolioQueryOptions } from "@/entities/portfolio";
|
||||
import { configureAuthClient } from "@/shared/api";
|
||||
import { formatSnapshotTime } from "@/shared/lib";
|
||||
import { createTestQueryClient } from "@/test/query";
|
||||
import { resource } from "@/test/resource";
|
||||
import { server } from "@/test/server";
|
||||
@@ -231,6 +232,37 @@ describe("AccountPage states", () => {
|
||||
.toHaveAccessibleDescription(/Акция: 100 ₽, 100 %/);
|
||||
});
|
||||
|
||||
it("shows server source time and attempt for an empty account", async () => {
|
||||
server.use(
|
||||
http.get("*/api/v1/brokerage-accounts/:accountId/portfolio", () =>
|
||||
HttpResponse.json(resource(
|
||||
{
|
||||
...portfolio,
|
||||
cashBalances: [],
|
||||
isStale: false,
|
||||
positions: [],
|
||||
totalsByCurrency: [],
|
||||
},
|
||||
{
|
||||
lastAttempt: {
|
||||
finishedAt: "2026-08-14T01:00:00Z",
|
||||
problems: [],
|
||||
startedAt: "2026-08-14T00:59:00Z",
|
||||
state: "failed",
|
||||
},
|
||||
lastSuccessfulAt: "2026-08-13T12:00:00Z",
|
||||
},
|
||||
)),
|
||||
),
|
||||
);
|
||||
renderAccountRoute(createTestQueryClient());
|
||||
expect(await screen.findByText(/^Данные на /)).toHaveTextContent(
|
||||
formatSnapshotTime("2026-08-13T12:00:00Z"),
|
||||
);
|
||||
expect(screen.getByText("Обновление не удалось")).toBeInTheDocument();
|
||||
expect(screen.queryByRole("button", { name: "Повторить" })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("expands and resets other when switching slice", () => {
|
||||
const positions = [400, 250, 150, 100, 50, 30, 20].map(
|
||||
(value, index) => position({
|
||||
@@ -874,7 +906,6 @@ describe("AccountPage states", () => {
|
||||
).toBeInTheDocument();
|
||||
expect(screen.queryByText(/T-Bank временно недоступен/))
|
||||
.not.toBeInTheDocument();
|
||||
expect(screen.queryByText(/Данные получены/)).not.toBeInTheDocument();
|
||||
expect(screen.getByRole("radio", { name: "Акции" })).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByRole("radio", { name: "Облигации" }),
|
||||
@@ -1276,7 +1307,7 @@ describe("AccountPage states", () => {
|
||||
});
|
||||
|
||||
expect(structure).toHaveTextContent("10 ₽");
|
||||
expect(screen.queryByText(/Данные получены/)).not.toBeInTheDocument();
|
||||
expect(screen.getByText(/^Данные на /)).toBeInTheDocument();
|
||||
void queryClient.invalidateQueries({
|
||||
queryKey: portfolioQueryOptions("account-1").queryKey,
|
||||
});
|
||||
@@ -1320,7 +1351,7 @@ describe("AccountPage states", () => {
|
||||
screen.getAllByRole("definition").map(node => node.textContent),
|
||||
).toEqual(["-0,5 $"]),
|
||||
);
|
||||
expect(screen.queryByText(/Данные получены/)).not.toBeInTheDocument();
|
||||
expect(screen.getByText(/^Данные на /)).toHaveTextContent("Данные на");
|
||||
expect(structure).not.toHaveTextContent("10 ₽");
|
||||
expect(structure).toHaveTextContent("Нет положительной стоимости");
|
||||
expect(
|
||||
@@ -1361,7 +1392,7 @@ describe("AccountPage states", () => {
|
||||
expect(
|
||||
screen.getAllByRole("definition").map(node => node.textContent),
|
||||
).toEqual(["1 234,5 ₽"]);
|
||||
expect(screen.queryByText(/Данные получены/)).not.toBeInTheDocument();
|
||||
expect(screen.getByText(/^Данные на /)).toBeInTheDocument();
|
||||
expect(
|
||||
screen.queryByRole("status", { name: "Загрузка" }),
|
||||
).not.toBeInTheDocument();
|
||||
|
||||
Reference in New Issue
Block a user