Skip to content

A local-first personal finance app

Payees functional tests (#4766)

Alvaro Crespo0d60da5ba9c8
diff --git a/packages/desktop-client/e2e/page-models/navigation.ts b/packages/desktop-client/e2e/page-models/navigation.ts
index f665a2e8b7..5b1081da02 100644
--- a/packages/desktop-client/e2e/page-models/navigation.ts
+++ b/packages/desktop-client/e2e/page-models/navigation.ts
@@ -1,6 +1,7 @@
import { type Page } from '@playwright/test';
import { AccountPage } from './account-page';
+import { PayeesPage } from './payees-page';
import { ReportsPage } from './reports-page';
import { RulesPage } from './rules-page';
import { SchedulesPage } from './schedules-page';
@@ -52,6 +53,19 @@ export class Navigation {
return new RulesPage(this.page);
}
+ async goToPayeesPage() {
+ const payeesLink = this.page.getByRole('link', { name: 'Payees' });
+
+ // Expand the "More" menu only if the Payees link is not visible
+ if (!(await payeesLink.isVisible())) {
+ await this.page.getByRole('button', { name: 'More' }).click();
+ }
+
+ await payeesLink.click();
+
+ return new PayeesPage(this.page);
+ }
+
async goToSettingsPage() {
const settingsLink = this.page.getByRole('link', { name: 'Settings' });
diff --git a/packages/desktop-client/e2e/page-models/payees-page.ts b/packages/desktop-client/e2e/page-models/payees-page.ts
new file mode 100644
index 0000000000..7075afdc6f
--- /dev/null
+++ b/packages/desktop-client/e2e/page-models/payees-page.ts
@@ -0,0 +1,16 @@
+import { type Locator, type Page } from '@playwright/test';
+
+export class PayeesPage {
+ readonly page: Page;
+ readonly searchBox: Locator;
+
+ constructor(page: Page) {
+ this.page = page;
+
+ this.searchBox = page.getByPlaceholder('Filter payees...');
+ }
+
+ async searchFor(payeeName: string) {
+ await this.searchBox.fill(payeeName);
+ }
+}
diff --git a/packages/desktop-client/e2e/payees.test.ts b/packages/desktop-client/e2e/payees.test.ts
new file mode 100644
index 0000000000..5a7dcd4a36
--- /dev/null
+++ b/packages/desktop-client/e2e/payees.test.ts
@@ -0,0 +1,62 @@
+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 PayeesPage } from './page-models/payees-page';
+
+test.describe('Payees', () => {
+ let page: Page;
+ let configurationPage: ConfigurationPage;
+ let navigation: Navigation;
+ let payeesPage: PayeesPage;
+
+ test.beforeAll(async ({ browser }) => {
+ page = await browser.newPage();
+ navigation = new Navigation(page);
+ configurationPage = new ConfigurationPage(page);
+
+ // Navigate to the root URL and create a fresh test file
+ await page.goto('/');
+ await configurationPage.createTestFile();
+ });
+
+ test.afterAll(async () => {
+ await page.close();
+ });
+
+ test.beforeEach(async () => {
+ // Navigate to the Payees page before each test
+ payeesPage = await navigation.goToPayeesPage();
+ });
+
+ test('checks the payees page visuals', async () => {
+ // This is a simple visual check to ensure the page loads
+ await expect(page).toMatchThemeScreenshots();
+
+ // Try searching for “Fast Internet” or “Home Depot,” etc.
+ await payeesPage.searchFor('Fast Internet');
+ // Screenshot check after searching
+ await expect(page).toMatchThemeScreenshots();
+ });
+
+ test('shows Fast Internet in the payee list', async () => {
+ await payeesPage.searchFor('Fast Internet');
+ await expect(page.getByText('Fast Internet')).toBeVisible();
+ });
+
+ test('shows "Create rule" text for a payee', async () => {
+ await payeesPage.searchFor('Deposit');
+ await expect(page.getByText('Create rule')).toBeVisible();
+ });
+
+ test('filters out unrelated payees', async () => {
+ await payeesPage.searchFor('asdfasdf-nonsense');
+
+ // Get the text 'No payees' matching the search from the page
+ const noPayeesMessage = page.locator('text=No payees').first();
+
+ // Assert it is visible
+ await expect(noPayeesMessage).toBeVisible();
+ });
+});
diff --git a/packages/desktop-client/e2e/payees.test.ts-snapshots/Payees-checks-the-payees-page-visuals-1-chromium-linux.png b/packages/desktop-client/e2e/payees.test.ts-snapshots/Payees-checks-the-payees-page-visuals-1-chromium-linux.png
new file mode 100644
index 0000000000..8e6d93a7b9
Binary files /dev/null and b/packages/desktop-client/e2e/payees.test.ts-snapshots/Payees-checks-the-payees-page-visuals-1-chromium-linux.png differ
diff --git a/packages/desktop-client/e2e/payees.test.ts-snapshots/Payees-checks-the-payees-page-visuals-2-chromium-linux.png b/packages/desktop-client/e2e/payees.test.ts-snapshots/Payees-checks-the-payees-page-visuals-2-chromium-linux.png
new file mode 100644
index 0000000000..66d269fc2a
Binary files /dev/null and b/packages/desktop-client/e2e/payees.test.ts-snapshots/Payees-checks-the-payees-page-visuals-2-chromium-linux.png differ
diff --git a/packages/desktop-client/e2e/payees.test.ts-snapshots/Payees-checks-the-payees-page-visuals-3-chromium-linux.png b/packages/desktop-client/e2e/payees.test.ts-snapshots/Payees-checks-the-payees-page-visuals-3-chromium-linux.png
new file mode 100644
index 0000000000..de70029136
Binary files /dev/null and b/packages/desktop-client/e2e/payees.test.ts-snapshots/Payees-checks-the-payees-page-visuals-3-chromium-linux.png differ
diff --git a/packages/desktop-client/e2e/payees.test.ts-snapshots/Payees-checks-the-payees-page-visuals-4-chromium-linux.png b/packages/desktop-client/e2e/payees.test.ts-snapshots/Payees-checks-the-payees-page-visuals-4-chromium-linux.png
new file mode 100644
index 0000000000..35c8074a75
Binary files /dev/null and b/packages/desktop-client/e2e/payees.test.ts-snapshots/Payees-checks-the-payees-page-visuals-4-chromium-linux.png differ
diff --git a/packages/desktop-client/e2e/payees.test.ts-snapshots/Payees-checks-the-payees-page-visuals-5-chromium-linux.png b/packages/desktop-client/e2e/payees.test.ts-snapshots/Payees-checks-the-payees-page-visuals-5-chromium-linux.png
new file mode 100644
index 0000000000..842d1809de
Binary files /dev/null and b/packages/desktop-client/e2e/payees.test.ts-snapshots/Payees-checks-the-payees-page-visuals-5-chromium-linux.png differ
diff --git a/packages/desktop-client/e2e/payees.test.ts-snapshots/Payees-checks-the-payees-page-visuals-6-chromium-linux.png b/packages/desktop-client/e2e/payees.test.ts-snapshots/Payees-checks-the-payees-page-visuals-6-chromium-linux.png
new file mode 100644
index 0000000000..c0ddb51562
Binary files /dev/null and b/packages/desktop-client/e2e/payees.test.ts-snapshots/Payees-checks-the-payees-page-visuals-6-chromium-linux.png differ
diff --git a/upcoming-release-notes/4766.md b/upcoming-release-notes/4766.md
new file mode 100644
index 0000000000..10fa3a007f
--- /dev/null
+++ b/upcoming-release-notes/4766.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: [alvaro-crespo]
+---
+
+Add functional tests for the payee page