mirror of
https://github.com/Zproger/Aurum.git
synced 2026-10-12 18:46:40 +07:00
backend/tests/: 33 pytest tests against a real Postgres database (aurum_test, created/migrated/dropped per run) exercised through the actual HTTP API — not sqlite, not mocks, and the real `aurum` database is never opened (app lifespan is skipped, get_session is overridden per test). Covers transaction category-kind validation, year/month/date-range filtering and pagination, dashboard summary arithmetic, budget status, cash flow, and the /transactions/years picker. e2e/: 6 Playwright specs driving a real browser against a fully separate throwaway docker-compose stack (run.sh: separate project name, database, port, and volume, torn down with `down -v` on exit) — regression coverage for the Recent Transactions month bug, the Card grid-overflow bug, the frozen-year bug, the Net Worth default range, and the Dashboard-> Transactions deep link, all fixed earlier this session. Also synced the backend's APP_VERSION constant (stale at 0.15.2, embedded in exported backups) with the frontend version.
35 lines
1.5 KiB
TypeScript
35 lines
1.5 KiB
TypeScript
import { test, expect } from "@playwright/test";
|
|
import { createTransaction, getCategoryId, getDefaultAccountId } from "./helpers";
|
|
|
|
// Regression for v0.16.0/v0.16.1: `year` on Dashboard/Transactions/Budget
|
|
// used to be `const [year] = useState(...)` — no setter, so no UI could
|
|
// ever change it and every page was stuck on the current year forever.
|
|
// This asserts switching the year picker actually changes the numbers
|
|
// shown, not just that the picker's own visual state updates.
|
|
//
|
|
// Uses a sub-1000 amount so the assertion doesn't have to guess at
|
|
// locale-specific thousands-separator formatting (space vs comma vs none).
|
|
test("switching the Dashboard year picker changes the displayed income", async ({ page, request }) => {
|
|
const accountId = await getDefaultAccountId(request);
|
|
const salaryId = await getCategoryId(request, "Salary");
|
|
await createTransaction(request, {
|
|
account_id: accountId,
|
|
category_id: salaryId,
|
|
type: "income",
|
|
amount: "999.00",
|
|
description: "2017 august salary",
|
|
date: "2017-08-01",
|
|
});
|
|
|
|
await page.goto("/");
|
|
await page.getByRole("button", { name: "Авг", exact: true }).click();
|
|
|
|
const realIncomeValue = page.locator('xpath=//p[text()="Реальный доход"]/following-sibling::p[1]');
|
|
await expect(realIncomeValue).not.toContainText("999"); // fresh stack: nothing in the current year yet
|
|
|
|
await page.getByRole("button", { name: /^\d{4}$/ }).first().click();
|
|
await page.getByRole("option", { name: "2017" }).click();
|
|
|
|
await expect(realIncomeValue).toContainText("999");
|
|
});
|