mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-21 15:36:50 -05:00
* Convert playwright config and tests to TS * Release notes * Update VRT * Dummy commit * Delete js snapshots * Fix call to expect * Move extended expect and test to fixtures * Fix wrong commit * Fix typecheck error * Update VRT * Dummy commit to run GH actions * Delete mobile budget test JS --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
70 lines
2.4 KiB
TypeScript
70 lines
2.4 KiB
TypeScript
import { type Page } from '@playwright/test';
|
|
|
|
import { expect, test } from './fixtures';
|
|
import { type BudgetPage } from './page-models/budget-page';
|
|
import { ConfigurationPage } from './page-models/configuration-page';
|
|
|
|
test.describe('Budget', () => {
|
|
let page: Page;
|
|
let configurationPage: ConfigurationPage;
|
|
let budgetPage: BudgetPage;
|
|
|
|
test.beforeAll(async ({ browser }) => {
|
|
page = await browser.newPage();
|
|
configurationPage = new ConfigurationPage(page);
|
|
|
|
await page.goto('/');
|
|
budgetPage = await configurationPage.createTestFile();
|
|
|
|
// Move mouse to corner of the screen;
|
|
// sometimes the mouse hovers on a budget element thus rendering an input box
|
|
// and this breaks screenshot tests
|
|
await page.mouse.move(0, 0);
|
|
});
|
|
|
|
test.afterAll(async () => {
|
|
await page.close();
|
|
});
|
|
|
|
test('renders the summary information: available funds, overspent, budgeted and for next month', async () => {
|
|
const summary = budgetPage.budgetSummary.first();
|
|
|
|
await expect(summary.getByText('Available funds')).toBeVisible({
|
|
timeout: 10000,
|
|
});
|
|
await expect(summary.getByText(/^Overspent in /)).toBeVisible();
|
|
await expect(summary.getByText('Budgeted')).toBeVisible();
|
|
await expect(summary.getByText('For next month')).toBeVisible();
|
|
await expect(page).toMatchThemeScreenshots();
|
|
});
|
|
|
|
test('transfer funds to another category', async () => {
|
|
const currentFundsA = await budgetPage.getBalanceForRow(1);
|
|
const currentFundsB = await budgetPage.getBalanceForRow(2);
|
|
|
|
await budgetPage.transferAllBalance(1, 2);
|
|
await page.waitForTimeout(1000);
|
|
|
|
expect(await budgetPage.getBalanceForRow(2)).toEqual(
|
|
currentFundsA + currentFundsB,
|
|
);
|
|
await expect(page).toMatchThemeScreenshots();
|
|
});
|
|
|
|
test('budget table is rendered', async () => {
|
|
await expect(budgetPage.budgetTable).toBeVisible();
|
|
expect(await budgetPage.getTableTotals()).toEqual({
|
|
budgeted: expect.any(Number),
|
|
spent: expect.any(Number),
|
|
balance: expect.any(Number),
|
|
});
|
|
});
|
|
|
|
test('clicking on spent amounts opens a transaction page', async () => {
|
|
const accountPage = await budgetPage.clickOnSpentAmountForRow(1);
|
|
expect(page.url()).toContain('/accounts');
|
|
expect(await accountPage.accountName.textContent()).toMatch('All Accounts');
|
|
await page.getByRole('button', { name: 'Back' }).click();
|
|
});
|
|
});
|