Files
frontend/src/shared/ui/SourceSyncStatus/SourceSyncStatus.test.tsx
T
ksv741 3c226f8c29
Frontend verify / commits (push) Skipped
Frontend verify / security (push) Successful in 12s
Frontend verify / verify (push) Successful in 7m41s
feat: render hourly investment states
2026-10-09 21:13:34 +03:00

62 lines
1.9 KiB
TypeScript

import { MantineProvider } from "@mantine/core";
import { render, screen } from "@testing-library/react";
import { describe, expect, it } from "vitest";
import { SourceSyncStatus, type SourceSyncStatusProps } from "./SourceSyncStatus";
function renderStatus(props: SourceSyncStatusProps) {
render(
<MantineProvider>
<SourceSyncStatus {...props} />
</MantineProvider>,
);
}
describe("SourceSyncStatus", () => {
it("renders nothing without source data", () => {
renderStatus({});
expect(screen.queryByRole("status")).not.toBeInTheDocument();
expect(screen.queryByText(/Данные/)).not.toBeInTheDocument();
});
it("renders the source timestamp", () => {
renderStatus({ lastSuccessfulAt: "2026-02-03T10:15:00.000Z" });
expect(screen.getByText(/Данные на/)).toBeInTheDocument();
});
it("announces the caller-provided error text as a status", () => {
renderStatus({ errorText: "Обновление не удалось" });
expect(screen.getByRole("status")).toHaveTextContent("Обновление не удалось");
});
it("announces an active or failed source attempt with text", () => {
renderStatus({
lastAttempt: {
finishedAt: null,
problems: [],
startedAt: "2026-02-03T10:15:00.000Z",
state: "running",
},
});
expect(screen.getByRole("status")).toHaveTextContent(
"Обновление выполняется",
);
});
it("keeps the notices next to the timestamp they belong to", () => {
renderStatus({
errorText: "Обновление не удалось",
lastSuccessfulAt: "2026-02-03T10:15:00.000Z",
stale: true,
});
expect(screen.getByText(/Данные на/)).toBeInTheDocument();
expect(screen.getByText("Данные требуют обновления")).toBeInTheDocument();
expect(screen.getByRole("status")).toHaveTextContent("Обновление не удалось");
});
});