mirror of
https://github.com/Zproger/Aurum.git
synced 2026-10-13 02:56:39 +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.
61 lines
2.6 KiB
TypeScript
61 lines
2.6 KiB
TypeScript
import { test, expect } from "@playwright/test";
|
||
import { createTransaction, getCategoryId, getDefaultAccountId } from "./helpers";
|
||
|
||
// Regression for v0.15.4: a transaction description with no spaces (so it
|
||
// can't wrap) blew out the Dashboard's CSS Grid because Card had no
|
||
// min-width: 0, growing the whole page wider than the viewport instead of
|
||
// letting `truncate` ellipsize the text. See UPDATES.md (v0.15.4) and
|
||
// frontend/src/components/ui/Card.tsx.
|
||
const LONG_DESCRIPTION =
|
||
"оченьдлинноеописаниебезпробеловкотороедолжнообрезатьсямноготочиемачтобынеломатьверсткукарточкинадашборде1234567890";
|
||
|
||
test("a long unbroken transaction description never causes horizontal page overflow", async ({ page, request }) => {
|
||
const accountId = await getDefaultAccountId(request);
|
||
const categoryId = await getCategoryId(request, "Groceries");
|
||
await createTransaction(request, {
|
||
account_id: accountId,
|
||
category_id: categoryId,
|
||
type: "expense",
|
||
amount: "12.34",
|
||
description: LONG_DESCRIPTION,
|
||
date: "2016-08-01",
|
||
});
|
||
|
||
await page.goto("/");
|
||
await page.getByRole("button", { name: /^\d{4}$/ }).first().click();
|
||
await page.getByRole("option", { name: "2016" }).click();
|
||
await page.getByRole("button", { name: "Авг", exact: true }).click();
|
||
await expect(page.getByText(LONG_DESCRIPTION.slice(0, 20), { exact: false })).toBeVisible();
|
||
|
||
const overflow = await page.evaluate(() => ({
|
||
scrollWidth: document.documentElement.scrollWidth,
|
||
clientWidth: document.documentElement.clientWidth,
|
||
}));
|
||
expect(overflow.scrollWidth).toBeLessThanOrEqual(overflow.clientWidth);
|
||
});
|
||
|
||
test("same check on a narrow mobile viewport", async ({ page, request }) => {
|
||
await page.setViewportSize({ width: 375, height: 812 });
|
||
const accountId = await getDefaultAccountId(request);
|
||
const categoryId = await getCategoryId(request, "Groceries");
|
||
await createTransaction(request, {
|
||
account_id: accountId,
|
||
category_id: categoryId,
|
||
type: "expense",
|
||
amount: "12.34",
|
||
description: LONG_DESCRIPTION,
|
||
date: "2016-09-01",
|
||
});
|
||
|
||
await page.goto("/");
|
||
await page.getByRole("button", { name: /^\d{4}$/ }).first().click();
|
||
await page.getByRole("option", { name: "2016" }).click();
|
||
await page.getByRole("button", { name: "Сен", exact: true }).click();
|
||
|
||
const overflow = await page.evaluate(() => ({
|
||
scrollWidth: document.documentElement.scrollWidth,
|
||
clientWidth: document.documentElement.clientWidth,
|
||
}));
|
||
expect(overflow.scrollWidth).toBeLessThanOrEqual(overflow.clientWidth);
|
||
});
|