refactor: encapsulate instrument chart data
This commit is contained in:
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user