fix: remove income analytics period limit

This commit is contained in:
2026-09-09 11:10:10 +03:00
parent 47fbc21283
commit ab1b53680d
3 changed files with 22 additions and 9 deletions
@@ -102,7 +102,7 @@ function entry(): IncomeAnalytics["entries"][number] {
}; };
} }
function renderPage() { function renderPage(search = "from=2026-08-01&to=2026-08-27") {
configureAuthClient({ configureAuthClient({
accessToken: () => "token", accessToken: () => "token",
refresh: async () => true, refresh: async () => true,
@@ -112,11 +112,7 @@ function renderPage() {
return render( return render(
<MantineProvider> <MantineProvider>
<QueryWrapper> <QueryWrapper>
<MemoryRouter <MemoryRouter initialEntries={[`/accounts/account-1/income?${search}`]}>
initialEntries={[
"/accounts/account-1/income?from=2026-08-01&to=2026-08-27",
]}
>
<Routes> <Routes>
<Route <Route
path="/accounts/:accountId/income" path="/accounts/:accountId/income"
@@ -134,6 +130,23 @@ function renderPage() {
} }
describe("AccountIncomePage", () => { describe("AccountIncomePage", () => {
it("requests a multi-year period from the URL without resetting it", async () => {
const requested: string[] = [];
server.use(
http.get(
"*/api/v1/brokerage-accounts/:accountId/income-analytics",
({ request }) => {
requested.push(new URL(request.url).search);
return HttpResponse.json(analytics);
},
),
);
renderPage("from=2020-01-01&to=2025-12-31");
await waitFor(() =>
expect(requested).toContain("?from=2020-01-01&to=2025-12-31"),
);
});
it("preserves every repeated-ID payment when an open drill-down updates", async () => { it("preserves every repeated-ID payment when an open drill-down updates", async () => {
const first = { ...entry(), id: "same-id", description: "Выплата A" }; const first = { ...entry(), id: "same-id", description: "Выплата A" };
const second = { const second = {
@@ -138,8 +138,7 @@ function validPeriod(period: IncomePeriod): period is IncomePeriod {
from.toISOString().slice(0, 10) === period.from && from.toISOString().slice(0, 10) === period.from &&
to.toISOString().slice(0, 10) === period.to && to.toISOString().slice(0, 10) === period.to &&
from <= to && from <= to &&
to <= today && to <= today
(to.valueOf() - from.valueOf()) / 86_400_000 + 1 <= 366
); );
} }
+2 -1
View File
@@ -191,7 +191,8 @@ const ru = {
"Это известный прогноз, а не гарантированное поступление.", "Это известный прогноз, а не гарантированное поступление.",
validation: { validation: {
date: "Введите существующую дату.", date: "Введите существующую дату.",
period: "Укажите период до 366 дней без будущих дат.", period:
"Укажите корректный период без будущих дат: начало не позже окончания.",
}, },
}, },
settings: { title: "Настройки" }, settings: { title: "Настройки" },