Files
actual/packages/desktop-client/e2e/schedules.test.ts
Josh Woodward 942d3ea4d5 Schedules with the same amount and date are now handled properly (#5414)
* minor typescript updates

* [autofix.ci] apply automated fixes

* more typescript changes

* [autofix.ci] apply automated fixes

* Another typescript

* fixes

* [autofix.ci] apply automated fixes

* fixed test

* [autofix.ci] apply automated fixes

* renaming a few things

* [autofix.ci] apply automated fixes

* a test

* test 2

* [autofix.ci] apply automated fixes

* test 3

* attempting to add a new test

* [autofix.ci] apply automated fixes

* test update

* additional typing.

* [autofix.ci] apply automated fixes

* Testing first item again

* [autofix.ci] apply automated fixes

* temporarily adding logging

* [autofix.ci] apply automated fixes

* only running rules within a schedule if exists

* swapping if

* removing unused import

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* fixing typecheck

* updated test

* [autofix.ci] apply automated fixes

* Updated screenshots

* further test fixing

* changing test order

* [autofix.ci] apply automated fixes

* Almost there

* new images

* tests may be flaky

* just one image

* 🙏

* 🙏 🙏

* removing all images

* Revert "removing all images"

This reverts commit 4492cb7080.

* small order change

* [autofix.ci] apply automated fixes

* Update VRT

* Update packages/desktop-client/e2e/schedules.test.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* reverting unrelated changes

* [autofix.ci] apply automated fixes

* Reverting one other typescript change

* testing completing 1 schedule

* Update VRT

* release wrote rewrite

* Making sure rule application is saved

* Cleaning up get function

* prettier and null catch

* Removed now unused schedule type

* Better falling back if rule / schedule no longer exists

* linting

* Better typing for db request

* camel case to make code rabbit happier

* slightly more accurate comment

* [autofix.ci] apply automated fixes

* Running other rules when linked rule runs

* lint / prettier

* one more lint

* Update 5414.md

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2025-09-16 20:12:31 -07:00

166 lines
5.8 KiB
TypeScript

import { type Page } from '@playwright/test';
import { expect, test } from './fixtures';
import { ConfigurationPage } from './page-models/configuration-page';
import { Navigation } from './page-models/navigation';
import { type SchedulesPage } from './page-models/schedules-page';
test.describe('Schedules', () => {
let page: Page;
let navigation: Navigation;
let schedulesPage: SchedulesPage;
let configurationPage: ConfigurationPage;
test.beforeAll(async ({ browser }) => {
page = await browser.newPage();
navigation = new Navigation(page);
configurationPage = new ConfigurationPage(page);
await page.goto('/');
await configurationPage.createTestFile();
});
test.afterAll(async () => {
await page.close();
});
test.beforeEach(async () => {
schedulesPage = await navigation.goToSchedulesPage();
});
test('checks the page visuals', async () => {
await expect(page).toMatchThemeScreenshots();
});
test('creates a new schedule, posts the transaction and later completes it', async () => {
test.setTimeout(40000);
await schedulesPage.addNewSchedule({
payee: 'Home Depot',
account: 'HSBC',
amount: 25,
});
const schedule = schedulesPage.getNthSchedule(2);
await expect(schedule.payee).toHaveText('Home Depot');
await expect(schedule.account).toHaveText('HSBC');
await expect(schedule.amount).toHaveText('~25.00');
await expect(schedule.status).toHaveText('Due');
await expect(page).toMatchThemeScreenshots();
await schedulesPage.postNthSchedule(2);
await expect(schedulesPage.getNthSchedule(2).status).toHaveText('Paid');
await expect(page).toMatchThemeScreenshots();
// Go to transactions page
const accountPage = await navigation.goToAccountPage('HSBC');
const transaction = accountPage.getNthTransaction(0);
await expect(transaction.payee).toHaveText('Home Depot');
await expect(transaction.category).toHaveText('Categorize');
await expect(transaction.debit).toHaveText('25.00');
await expect(transaction.credit).toHaveText('');
const icon = transaction.payee.getByTestId('schedule-icon');
await icon.hover();
await expect(page).toMatchThemeScreenshots();
// go to rules page
const rulesPage = await navigation.goToRulesPage();
await rulesPage.searchFor('Home Depot');
const rule = rulesPage.getNthRule(0);
await expect(rule.actions).toHaveText([
'link schedule Home Depot (2017-01-01)',
]);
await expect(rule.conditions).toHaveText([
'payee is Home Depot',
'and account is HSBC',
'and date is approx Every month on the 1st',
'and amount is approx -25.00',
]);
// Go back to schedules page
await navigation.goToSchedulesPage();
await schedulesPage.completeNthSchedule(2);
await expect(schedulesPage.getNthScheduleRow(4)).toHaveText(
'Show completed schedules',
);
await expect(page).toMatchThemeScreenshots();
});
test('creates two new schedules, posts both transactions and later completes one', async () => {
test.setTimeout(40000);
// Adding two schedules with the same payee and account and amount, mimicking two different subscriptions
await schedulesPage.addNewSchedule({
payee: 'Apple',
account: 'HSBC',
amount: 5,
});
await schedulesPage.addNewSchedule({
payee: 'Apple',
account: 'HSBC',
amount: 5,
});
const schedule = schedulesPage.getNthSchedule(2);
await expect(schedule.payee).toHaveText('Apple');
await expect(schedule.account).toHaveText('HSBC');
await expect(schedule.amount).toHaveText('~5.00');
await expect(schedule.status).toHaveText('Due');
await expect(page).toMatchThemeScreenshots();
const schedule2 = schedulesPage.getNthSchedule(3);
await expect(schedule2.payee).toHaveText('Apple');
await expect(schedule2.account).toHaveText('HSBC');
await expect(schedule2.amount).toHaveText('~5.00');
await expect(schedule2.status).toHaveText('Due');
await expect(page).toMatchThemeScreenshots();
await schedulesPage.postNthSchedule(2);
await expect(schedulesPage.getNthSchedule(2).status).toHaveText('Paid');
await expect(schedulesPage.getNthSchedule(3).status).toHaveText('Due');
await expect(page).toMatchThemeScreenshots();
await schedulesPage.postNthSchedule(3);
await expect(schedulesPage.getNthSchedule(2).status).toHaveText('Paid');
await expect(schedulesPage.getNthSchedule(3).status).toHaveText('Paid');
await expect(page).toMatchThemeScreenshots();
// Go to transactions page
const accountPage = await navigation.goToAccountPage('HSBC');
const transaction = accountPage.getNthTransaction(0);
await expect(transaction.payee).toHaveText('Apple');
await expect(transaction.category).toHaveText('Categorize');
await expect(transaction.debit).toHaveText('5.00');
await expect(transaction.credit).toHaveText('');
// Go to transactions page
const transaction2 = accountPage.getNthTransaction(1);
await expect(transaction2.payee).toHaveText('Apple');
await expect(transaction2.category).toHaveText('Categorize');
await expect(transaction2.debit).toHaveText('5.00');
await expect(transaction2.credit).toHaveText('');
const icon = transaction.payee.getByTestId('schedule-icon');
await icon.hover();
await expect(page).toMatchThemeScreenshots();
const icon2 = transaction2.payee.getByTestId('schedule-icon');
await icon2.hover();
await expect(page).toMatchThemeScreenshots();
});
test('creates a "full" list of schedules', async () => {
// Schedules search shouldn't shrink with many schedules
for (let i = 0; i < 10; i++) {
await schedulesPage.addNewSchedule({
payee: 'Home Depot',
account: 'HSBC',
amount: 0,
});
}
await expect(page).toMatchThemeScreenshots();
});
});