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({
accessToken: () => "token",
refresh: async () => true,
@@ -112,11 +112,7 @@ function renderPage() {
return render(
<MantineProvider>
<QueryWrapper>
<MemoryRouter
initialEntries={[
"/accounts/account-1/income?from=2026-08-01&to=2026-08-27",
]}
>
<MemoryRouter initialEntries={[`/accounts/account-1/income?${search}`]}>
<Routes>
<Route
path="/accounts/:accountId/income"
@@ -134,6 +130,23 @@ function renderPage() {
}
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 () => {
const first = { ...entry(), id: "same-id", description: "Выплата A" };
const second = {
@@ -138,8 +138,7 @@ function validPeriod(period: IncomePeriod): period is IncomePeriod {
from.toISOString().slice(0, 10) === period.from &&
to.toISOString().slice(0, 10) === period.to &&
from <= to &&
to <= today &&
(to.valueOf() - from.valueOf()) / 86_400_000 + 1 <= 366
to <= today
);
}