A local-first personal finance app
Create e2e tests for mobile payees page (#5905)
Matiss Janis Aboltinsdfaa75f1cf48
diff --git a/packages/desktop-client/e2e/page-models/mobile-navigation.ts b/packages/desktop-client/e2e/page-models/mobile-navigation.tsindex 9edf5ae420..fdc880f5c0 100644--- a/packages/desktop-client/e2e/page-models/mobile-navigation.ts+++ b/packages/desktop-client/e2e/page-models/mobile-navigation.ts@@ -3,6 +3,7 @@ import { type Locator, type Page } from '@playwright/test';import { MobileAccountPage } from './mobile-account-page';import { MobileAccountsPage } from './mobile-accounts-page';import { MobileBudgetPage } from './mobile-budget-page';+import { MobilePayeesPage } from './mobile-payees-page';import { MobileReportsPage } from './mobile-reports-page';import { MobileRulesPage } from './mobile-rules-page';import { MobileTransactionEntryPage } from './mobile-transaction-entry-page';@@ -21,6 +22,7 @@ const ROUTES_BY_PAGE = {Accounts: '/accounts',Transaction: '/transactions/new',Reports: '/reports',+ Payees: '/payees',Rules: '/rules',Settings: '/settings',};@@ -166,6 +168,13 @@ export class MobileNavigation {);}+ async goToPayeesPage() {+ return await this.navigateToPage(+ 'Payees',+ () => new MobilePayeesPage(this.page),+ );+ }+async goToRulesPage() {return await this.navigateToPage('Rules',diff --git a/packages/desktop-client/e2e/page-models/mobile-payees-page.ts b/packages/desktop-client/e2e/page-models/mobile-payees-page.tsnew file mode 100644index 0000000000..8e7bf30a2f--- /dev/null+++ b/packages/desktop-client/e2e/page-models/mobile-payees-page.ts@@ -0,0 +1,75 @@+import { type Locator, type Page } from '@playwright/test';++export class MobilePayeesPage {+ readonly page: Page;+ readonly searchBox: Locator;+ readonly payeesList: Locator;+ readonly emptyMessage: Locator;+ readonly loadingIndicator: Locator;++ constructor(page: Page) {+ this.page = page;+ this.searchBox = page.getByPlaceholder('Filter payees…');+ this.payeesList = page.getByRole('grid', { name: 'Payees' });+ this.emptyMessage = page.getByText('No payees found.');+ this.loadingIndicator = page.getByTestId('animated-loading');+ }++ async waitFor(options?: {+ state?: 'attached' | 'detached' | 'visible' | 'hidden';+ timeout?: number;+ }) {+ await this.payeesList.waitFor(options);+ }++ /**+ * Search for payees using the search box+ */+ async searchFor(text: string) {+ await this.searchBox.fill(text);+ }++ /**+ * Clear the search box+ */+ async clearSearch() {+ await this.searchBox.fill('');+ }++ /**+ * Get the nth payee item (0-based index)+ */+ getNthPayee(index: number) {+ return this.getAllPayees().nth(index);+ }++ /**+ * Get all visible payee items+ */+ getAllPayees() {+ return this.payeesList.getByRole('gridcell');+ }++ /**+ * Click on a payee to view/edit rules+ */+ async clickPayee(index: number) {+ const payee = this.getNthPayee(index);+ await payee.click();+ }++ /**+ * Get the number of visible payees+ */+ async getPayeeCount() {+ const payees = this.getAllPayees();+ return await payees.count();+ }++ /**+ * Wait for loading to complete+ */+ async waitForLoadingToComplete(timeout: number = 10000) {+ await this.loadingIndicator.waitFor({ state: 'hidden', timeout });+ }+}diff --git a/packages/desktop-client/e2e/page-models/mobile-rules-page.ts b/packages/desktop-client/e2e/page-models/mobile-rules-page.tsindex d12acfad09..b4762ca5ea 100644--- a/packages/desktop-client/e2e/page-models/mobile-rules-page.ts+++ b/packages/desktop-client/e2e/page-models/mobile-rules-page.ts@@ -73,28 +73,6 @@ export class MobileRulesPage {return await rules.count();}- /**- * Check if the search bar has a border- */- async hasSearchBarBorder() {- const searchContainer = this.searchBox.locator('..');- const borderStyle = await searchContainer.evaluate(el => {- const style = window.getComputedStyle(el);- return style.borderBottomWidth;- });- return borderStyle === '2px';- }-- /**- * Get the background color of the search box- */- async getSearchBackgroundColor() {- return await this.searchBox.evaluate(el => {- const style = window.getComputedStyle(el);- return style.backgroundColor;- });- }-/*** Check if a rule contains specific text*/diff --git a/packages/desktop-client/e2e/payees.mobile.test.ts b/packages/desktop-client/e2e/payees.mobile.test.tsnew file mode 100644index 0000000000..07d4f45245--- /dev/null+++ b/packages/desktop-client/e2e/payees.mobile.test.ts@@ -0,0 +1,112 @@+import { type Page } from '@playwright/test';++import { expect, test } from './fixtures';+import { ConfigurationPage } from './page-models/configuration-page';+import { MobileNavigation } from './page-models/mobile-navigation';+import { type MobilePayeesPage } from './page-models/mobile-payees-page';++test.describe('Mobile Payees', () => {+ let page: Page;+ let navigation: MobileNavigation;+ let payeesPage: MobilePayeesPage;+ let configurationPage: ConfigurationPage;++ test.beforeEach(async ({ browser }) => {+ page = await browser.newPage();+ navigation = new MobileNavigation(page);+ configurationPage = new ConfigurationPage(page);++ // Set mobile viewport+ await page.setViewportSize({+ width: 350,+ height: 600,+ });++ await page.goto('/');+ await configurationPage.createTestFile();++ // Navigate to payees page and wait for it to load+ payeesPage = await navigation.goToPayeesPage();+ });++ test.afterEach(async () => {+ await page.close();+ });++ test('checks the page visuals', async () => {+ await payeesPage.waitForLoadingToComplete();++ // Check that the header is present+ await expect(page.getByRole('heading', { name: 'Payees' })).toBeVisible();++ // Check that the search box is present with proper placeholder+ await expect(payeesPage.searchBox).toBeVisible();+ await expect(payeesPage.searchBox).toHaveAttribute(+ 'placeholder',+ 'Filter payees…',+ );++ const payeeCount = await payeesPage.getPayeeCount();+ expect(payeeCount).toBeGreaterThan(0);+ await expect(page).toMatchThemeScreenshots();+ });++ test('filters out unrelated payees', async () => {+ await payeesPage.searchFor('asdfasdf-nonsense');++ // Get the text 'No payees found.' from the page+ const noPayeesMessage = page.getByText('No payees found.');++ // Assert it is visible+ await expect(noPayeesMessage).toBeVisible();+ await expect(page).toMatchThemeScreenshots();+ });++ test('clicking on a payee opens rule creation form', async () => {+ await payeesPage.waitForLoadingToComplete();++ const payeeCount = await payeesPage.getPayeeCount();+ expect(payeeCount).toBeGreaterThan(0);++ await payeesPage.clickPayee(0);++ // Should navigate to rules page for creating a new rule+ await expect(page).toHaveURL(/\/rules/);+ await expect(page).toMatchThemeScreenshots();+ });++ test('page handles empty state gracefully', async () => {+ // Search for something that won't match to get empty state+ await payeesPage.searchFor('NonExistentPayee123456789');+ await page.waitForTimeout(500);++ // Check that empty message is shown+ const emptyMessage = page.getByText('No payees found.');+ await expect(emptyMessage).toBeVisible();++ // Check that no payee items are visible+ const payees = payeesPage.getAllPayees();+ await expect(payees).toHaveCount(0);+ await expect(page).toMatchThemeScreenshots();+ });++ test('search functionality works correctly', async () => {+ await payeesPage.waitForLoadingToComplete();++ // Test searching for a specific payee+ await payeesPage.searchFor('Fast Internet');++ // Should show at least one result+ const payeeCount = await payeesPage.getPayeeCount();+ expect(payeeCount).toBeGreaterThan(0);+ await expect(page).toMatchThemeScreenshots();++ // Clear search+ await payeesPage.clearSearch();++ // Should show all payees again+ const allPayeeCount = await payeesPage.getPayeeCount();+ expect(allPayeeCount).toBeGreaterThan(payeeCount);+ await expect(page).toMatchThemeScreenshots();+ });+});diff --git a/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-checks-the-page-visuals-1-chromium-linux.png b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-checks-the-page-visuals-1-chromium-linux.pngnew file mode 100644index 0000000000..4ae3da5a0eBinary files /dev/null and b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-checks-the-page-visuals-1-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-checks-the-page-visuals-2-chromium-linux.png b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-checks-the-page-visuals-2-chromium-linux.pngnew file mode 100644index 0000000000..229d2f357dBinary files /dev/null and b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-checks-the-page-visuals-2-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-checks-the-page-visuals-3-chromium-linux.png b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-checks-the-page-visuals-3-chromium-linux.pngnew file mode 100644index 0000000000..fe3b9cf919Binary files /dev/null and b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-checks-the-page-visuals-3-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-clicking-on-a-payee-opens-rule-creation-form-1-chromium-linux.png b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-clicking-on-a-payee-opens-rule-creation-form-1-chromium-linux.pngnew file mode 100644index 0000000000..cc8308d518Binary files /dev/null and b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-clicking-on-a-payee-opens-rule-creation-form-1-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-clicking-on-a-payee-opens-rule-creation-form-2-chromium-linux.png b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-clicking-on-a-payee-opens-rule-creation-form-2-chromium-linux.pngnew file mode 100644index 0000000000..ef947e58e9Binary files /dev/null and b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-clicking-on-a-payee-opens-rule-creation-form-2-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-clicking-on-a-payee-opens-rule-creation-form-3-chromium-linux.png b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-clicking-on-a-payee-opens-rule-creation-form-3-chromium-linux.pngnew file mode 100644index 0000000000..84fdb21676Binary files /dev/null and b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-clicking-on-a-payee-opens-rule-creation-form-3-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-filters-out-unrelated-payees-1-chromium-linux.png b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-filters-out-unrelated-payees-1-chromium-linux.pngnew file mode 100644index 0000000000..afefea22a9Binary files /dev/null and b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-filters-out-unrelated-payees-1-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-filters-out-unrelated-payees-2-chromium-linux.png b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-filters-out-unrelated-payees-2-chromium-linux.pngnew file mode 100644index 0000000000..cacd9da233Binary files /dev/null and b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-filters-out-unrelated-payees-2-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-filters-out-unrelated-payees-3-chromium-linux.png b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-filters-out-unrelated-payees-3-chromium-linux.pngnew file mode 100644index 0000000000..2f741ceb35Binary files /dev/null and b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-filters-out-unrelated-payees-3-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-page-handles-empty-state-gracefully-1-chromium-linux.png b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-page-handles-empty-state-gracefully-1-chromium-linux.pngnew file mode 100644index 0000000000..fa2df25282Binary files /dev/null and b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-page-handles-empty-state-gracefully-1-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-page-handles-empty-state-gracefully-2-chromium-linux.png b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-page-handles-empty-state-gracefully-2-chromium-linux.pngnew file mode 100644index 0000000000..4b9d481154Binary files /dev/null and b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-page-handles-empty-state-gracefully-2-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-page-handles-empty-state-gracefully-3-chromium-linux.png b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-page-handles-empty-state-gracefully-3-chromium-linux.pngnew file mode 100644index 0000000000..0691ee17a2Binary files /dev/null and b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-page-handles-empty-state-gracefully-3-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-search-functionality-works-correctly-1-chromium-linux.png b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-search-functionality-works-correctly-1-chromium-linux.pngnew file mode 100644index 0000000000..aaf986668eBinary files /dev/null and b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-search-functionality-works-correctly-1-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-search-functionality-works-correctly-2-chromium-linux.png b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-search-functionality-works-correctly-2-chromium-linux.pngnew file mode 100644index 0000000000..c20bbe559dBinary files /dev/null and b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-search-functionality-works-correctly-2-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-search-functionality-works-correctly-3-chromium-linux.png b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-search-functionality-works-correctly-3-chromium-linux.pngnew file mode 100644index 0000000000..8d103c7d2dBinary files /dev/null and b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-search-functionality-works-correctly-3-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-search-functionality-works-correctly-4-chromium-linux.png b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-search-functionality-works-correctly-4-chromium-linux.pngnew file mode 100644index 0000000000..cbf0186bbcBinary files /dev/null and b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-search-functionality-works-correctly-4-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-search-functionality-works-correctly-5-chromium-linux.png b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-search-functionality-works-correctly-5-chromium-linux.pngnew file mode 100644index 0000000000..051063fa40Binary files /dev/null and b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-search-functionality-works-correctly-5-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-search-functionality-works-correctly-6-chromium-linux.png b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-search-functionality-works-correctly-6-chromium-linux.pngnew file mode 100644index 0000000000..417de5c024Binary files /dev/null and b/packages/desktop-client/e2e/payees.mobile.test.ts-snapshots/Mobile-Payees-search-functionality-works-correctly-6-chromium-linux.png differdiff --git a/upcoming-release-notes/5905.md b/upcoming-release-notes/5905.mdnew file mode 100644index 0000000000..f849a970b8--- /dev/null+++ b/upcoming-release-notes/5905.md@@ -0,0 +1,7 @@+---+category: Maintenance+authors: [MatissJanis]+---++Add end-to-end tests for the mobile Payees page, verifying UI and interactions.+