A local-first personal finance app
[AI] Add mobile e2e coverage for the transaction calendar report (#8783)
Zannis Kalampoukisc21df10cc676
diff --git a/packages/desktop-client/e2e/page-models/reports-page.ts b/packages/desktop-client/e2e/page-models/reports-page.tsindex cbc9409eb2..ff9afe85d4 100644--- a/packages/desktop-client/e2e/page-models/reports-page.ts+++ b/packages/desktop-client/e2e/page-models/reports-page.ts@@ -1,3 +1,4 @@+import { expect } from '@playwright/test';import type { Locator, Page } from '@playwright/test';import { CustomReportPage } from './custom-report-page';@@ -25,6 +26,53 @@ export class ReportsPage {return new ReportsPage(this.page);}+ async goToCalendarPage() {+ const card = await this.scrollDashboardCardIntoView(/^Calendar$/);++ await Promise.all([+ this.page.waitForURL(/\/reports\/calendar\/.+/),+ card.click(),+ ]);++ return new ReportsPage(this.page);+ }++ /**+ * Locates the dashboard card whose title matches `name` and scrolls it into+ * view, returning its clickable button.+ *+ * `ReportCard` renders its children only once the card enters the viewport,+ * so an off-screen card has no title to match on — and a card added during+ * the test may not be in the DOM yet at all.+ *+ * The dashboard scrolls inside `Page`'s own `overflowY: auto` container+ * rather than the document, so scrolling the window is a no-op here. Walk+ * the grid items instead and bring each into view until the card renders;+ * `ReportCard` latches `hasRendered`, so a card stays rendered once seen.+ */+ private async scrollDashboardCardIntoView(name: RegExp) {+ const card = this.pageContent+ .getByRole('button')+ .filter({ has: this.page.getByRole('heading', { name }) });++ await expect(async () => {+ const gridItems = this.pageContent.locator('.react-grid-item');+ const count = await gridItems.count();++ for (let i = count - 1; i >= 0; i--) {+ await gridItems.nth(i).scrollIntoViewIfNeeded();++ if (await card.isVisible()) {+ break;+ }+ }++ await expect(card).toBeVisible({ timeout: 1000 });+ }).toPass({ timeout: 20_000 });++ return card;+ }+async goToBalanceForecastPage() {const gridItems = this.pageContent.locator('.react-grid-item');const count = await gridItems.count();diff --git a/packages/desktop-client/e2e/reports.mobile.test.ts b/packages/desktop-client/e2e/reports.mobile.test.tsnew file mode 100644index 0000000000..f90ad0eb8e--- /dev/null+++ b/packages/desktop-client/e2e/reports.mobile.test.ts@@ -0,0 +1,64 @@+import type { Page } from '@playwright/test';++import { expect, test } from './fixtures';+import { ConfigurationPage } from './page-models/configuration-page';+import { Navigation } from './page-models/navigation';++test.describe('Mobile Reports', () => {+ let page: Page;+ let navigation: Navigation;+ let configurationPage: ConfigurationPage;++ test.beforeEach(async ({ browser }) => {+ page = await browser.newPage();+ navigation = new Navigation(page);+ configurationPage = new ConfigurationPage(page);++ await page.goto('/');+ await configurationPage.createTestFile();+ });++ test.afterEach(async () => {+ await page?.close();+ });++ // The narrow-width branch of the calendar report renders the mobile+ // `TransactionList`, whose rows call `useDisplayPayee`. That hook throws when+ // it renders outside a `DisplayPayeeProvider`, which took the whole report+ // down to `FeatureErrorFallback`. The wide-width branch never hit it because+ // it renders `TransactionTable`, which mounts its own provider internally.+ //+ // This starts at desktop width on purpose, mirroring the original report: the+ // calendar widget is not on the default dashboard and "Add new widget" is+ // desktop-only, so the widget is added wide and then viewed narrow.+ test('transaction calendar renders its transaction list on a narrow viewport', async () => {+ const reportsPage = await navigation.goToReportsPage();+ await reportsPage.waitToLoad();+ await reportsPage.addWidget('Calendar card');+ await reportsPage.goToCalendarPage();++ await page.setViewportSize({ width: 350, height: 600 });++ const showTransactions = page.getByRole('button', {+ name: 'Show transactions',+ });+ const errorFallback = page.getByText(+ 'Something went wrong loading this section.',+ );++ // Settle on whichever renders first so a crash reports as a visible error+ // boundary rather than as a timeout waiting for the button.+ await expect(showTransactions.or(errorFallback).first()).toBeVisible();+ await expect(errorFallback).not.toBeVisible();++ await showTransactions.click();++ const transactionList = page.getByLabel('Transaction list');+ await expect(transactionList).toBeVisible();++ // Rendering a row at all is the assertion that matters — a row is what+ // invokes `useDisplayPayee`.+ await expect(transactionList.getByRole('option').first()).toBeVisible();+ await expect(errorFallback).not.toBeVisible();+ });+});diff --git a/upcoming-release-notes/8783.md b/upcoming-release-notes/8783.mdnew file mode 100644index 0000000000..c2778bd74b--- /dev/null+++ b/upcoming-release-notes/8783.md@@ -0,0 +1,6 @@+---+category: Maintenance+authors: [zannis]+---++Add mobile e2e coverage for the transaction calendar report