Files
actual/packages/desktop-client/e2e/budget.test.js
Joel Jeremy Marquez 219e139d55 Consistent accounts terminology (For budget / Budgeted --> On budget) (#3903)
* Change for budget and budgeted terms to on-budget

* Release notes

* Update mobile account header

* Fix release notes

* Fix release note category

* Update VRT

* Rename variables

* Remove hyphens

* Show off budget

* Update VRT

* Dummy commit

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-12-10 15:15:44 -08:00

68 lines
2.2 KiB
JavaScript

import { test, expect } from '@playwright/test';
import { ConfigurationPage } from './page-models/configuration-page';
test.describe('Budget', () => {
let page;
let configurationPage;
let 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();
});
});