refactor: encapsulate instrument chart data
Frontend verify / commits (pull_request) Successful in 27s
Frontend verify / security (pull_request) Successful in 10s
Frontend verify / verify (pull_request) Successful in 8m45s

This commit is contained in:
2026-09-28 20:46:06 +03:00
parent fb3a5a6eaa
commit 64fe902192
7 changed files with 50 additions and 65 deletions
@@ -1,6 +1,6 @@
import { MantineProvider } from "@mantine/core";
import { QueryClientProvider } from "@tanstack/react-query";
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
import { fireEvent, render, screen, waitFor, within } from "@testing-library/react";
import { http, HttpResponse } from "msw";
import { MemoryRouter, Route, Routes, useLocation } from "react-router";
import { describe, expect, it, vi } from "vitest";
@@ -78,6 +78,7 @@ const quote = {
function setup(
options: {
ambiguousTicker?: boolean;
candles?: NonNullable<StockPageVm["candles"]>["candles"];
cursorError?: string;
failCompany?: boolean;
failStock?: boolean;
@@ -124,7 +125,7 @@ function setup(
resource(
{
candles: [],
candles: options.candles ?? [],
currency: "RUB",
historyFrom: null,
observedAt: quote.observedAt,
@@ -352,7 +353,10 @@ describe("stock page", () => {
).toBe(false);
});
it("opens by UID, displays server calculations and distinguishes company and personal dividends", async () => {
setup();
setup({ candles: [
{ close: "300.125", isComplete: true, time: "2026-09-09T00:00:00Z" },
{ close: "301.123456789", isComplete: false, time: "2026-09-10T00:00:00Z" },
] });
expect(
await screen.findByRole("heading", { name: "Тестовая акция" }),
).toBeVisible();
@@ -376,6 +380,14 @@ describe("stock page", () => {
screen.getByRole("button", { name: "История дивидендов компании" }),
);
await waitFor(() => expect(screen.getByText("13.10.2025")).toBeVisible());
expect(screen.getByText("Текущая средняя покупка: 200 ₽")).toBeVisible();
fireEvent.click(screen.getByRole("button", { name: /Цены в таблице/ }));
const rows = within(await screen.findByRole("table")).getAllByRole("row");
expect(rows[1]).toHaveTextContent("10.09.2026");
expect(rows[1]).toHaveTextContent("301,123456789 ₽");
expect(rows[1]).toHaveTextContent("Формируется");
expect(rows[2]).toHaveTextContent("09.09.2026");
await waitFor(() => expect(screen.getByText("300,125 ₽")).toBeVisible());
});
it("keeps sold-position history and market content when company data fails", async () => {
setup({ failCompany: true, noPosition: true });