A local-first personal finance app
[AI] Optimize CI e2e tests with pre-built bundle serving (#7503)
Matiss Janis Aboltins362d8d60e497
diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.ymlindex 777551c8ce..ef5f163717 100644--- a/.github/workflows/e2e-test.yml+++ b/.github/workflows/e2e-test.yml@@ -17,20 +17,62 @@ on:env:GITHUB_PR_NUMBER: ${{github.event.pull_request.number}}+permissions:+ contents: read+concurrency:group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}cancel-in-progress: truejobs:+ build-web:+ name: Build web bundle+ runs-on: ubuntu-latest+ container:+ image: mcr.microsoft.com/playwright:v1.59.1-jammy+ steps:+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2+ with:+ persist-credentials: false+ - name: Set up environment+ uses: ./.github/actions/setup+ with:+ download-translations: 'false'+ - name: Trust the repository directory+ run: git config --global --add safe.directory "$GITHUB_WORKSPACE"+ - name: Build browser bundle+ # REACT_APP_NETLIFY=true flips isNonProductionEnvironment() on in the+ # bundle so the "Create test file" button (used by every e2e beforeEach+ # via ConfigurationPage.createTestFile()) is still rendered in a+ # production build. Without it, e2e tests would time out waiting for+ # a button that was tree-shaken out.+ env:+ REACT_APP_NETLIFY: 'true'+ run: |+ yarn workspace plugins-service build+ yarn workspace @actual-app/crdt build+ yarn workspace @actual-app/core build:browser+ yarn workspace @actual-app/web build:browser+ - name: Upload build artifact+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1+ with:+ name: desktop-client-build+ path: packages/desktop-client/build/+ retention-days: 1+ overwrite: true+functional:- name: Functional (shard ${{ matrix.shard }}/5)+ name: Functional (shard ${{ matrix.shard }}/3)runs-on: ubuntu-latest+ needs: build-webstrategy:fail-fast: falsematrix:- shard: [1, 2, 3, 4, 5]+ shard: [1, 2, 3]container:image: mcr.microsoft.com/playwright:v1.59.1-jammy+ env:+ E2E_USE_BUILD: '1'steps:- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2with:@@ -41,10 +83,15 @@ jobs:download-translations: 'false'- name: Trust the repository directoryrun: git config --global --add safe.directory "$GITHUB_WORKSPACE"+ - name: Download web build+ uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1+ with:+ name: desktop-client-build+ path: packages/desktop-client/build/- name: Run E2E Tests- run: yarn e2e --shard=${{ matrix.shard }}/5+ run: yarn e2e --shard=${{ matrix.shard }}/3- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1- if: always()+ if: failure()with:name: desktop-client-test-results-shard-${{ matrix.shard }}path: packages/desktop-client/test-results/@@ -84,14 +131,17 @@ jobs:overwrite: truevrt:- name: Visual regression (shard ${{ matrix.shard }}/5)+ name: Visual regression (shard ${{ matrix.shard }}/3)runs-on: ubuntu-latest+ needs: build-webstrategy:fail-fast: falsematrix:- shard: [1, 2, 3, 4, 5]+ shard: [1, 2, 3]container:image: mcr.microsoft.com/playwright:v1.59.1-jammy+ env:+ E2E_USE_BUILD: '1'steps:- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2with:@@ -100,8 +150,15 @@ jobs:uses: ./.github/actions/setupwith:download-translations: 'false'+ - name: Trust the repository directory+ run: git config --global --add safe.directory "$GITHUB_WORKSPACE"+ - name: Download web build+ uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1+ with:+ name: desktop-client-build+ path: packages/desktop-client/build/- name: Run VRT Tests- run: yarn vrt --shard=${{ matrix.shard }}/5+ run: yarn vrt --shard=${{ matrix.shard }}/3- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1if: always()with:diff --git a/packages/desktop-client/bin/serve-build.mjs b/packages/desktop-client/bin/serve-build.mjsnew file mode 100644index 0000000000..2c76de0fbf--- /dev/null+++ b/packages/desktop-client/bin/serve-build.mjs@@ -0,0 +1,97 @@+#!/usr/bin/env node+// Minimal static file server for the prebuilt browser bundle at+// packages/desktop-client/build. Serves with the COOP/COEP headers required+// by the app (SharedArrayBuffer/SQLite). Intended for CI e2e runs where+// starting the full Vite dev server is unnecessary overhead.++import fs from 'node:fs';+import http from 'node:http';+import path from 'node:path';+import { fileURLToPath } from 'node:url';++const __dirname = path.dirname(fileURLToPath(import.meta.url));+const ROOT = path.resolve(__dirname, '..', 'build');+const INDEX_PATH = path.join(ROOT, 'index.html');+const PORT = Number(process.env.PORT) || 3001;++const MIME = {+ '.html': 'text/html; charset=utf-8',+ '.js': 'text/javascript; charset=utf-8',+ '.mjs': 'text/javascript; charset=utf-8',+ '.css': 'text/css; charset=utf-8',+ '.json': 'application/json; charset=utf-8',+ '.map': 'application/json; charset=utf-8',+ '.svg': 'image/svg+xml',+ '.png': 'image/png',+ '.jpg': 'image/jpeg',+ '.jpeg': 'image/jpeg',+ '.gif': 'image/gif',+ '.ico': 'image/x-icon',+ '.wasm': 'application/wasm',+ '.woff': 'font/woff',+ '.woff2': 'font/woff2',+ '.ttf': 'font/ttf',+ '.otf': 'font/otf',+ '.webmanifest': 'application/manifest+json',+ '.txt': 'text/plain; charset=utf-8',+};++function setSharedHeaders(res) {+ res.setHeader('Cross-Origin-Opener-Policy', 'same-origin');+ res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp');+ res.setHeader('Cross-Origin-Resource-Policy', 'same-origin');+}++function resolveFile(urlPath) {+ let cleanPath;+ try {+ cleanPath = decodeURIComponent(urlPath.split('?')[0].split('#')[0]);+ } catch {+ return null;+ }+ if (cleanPath.includes('\0')) return null;+ // Strip leading slashes so path.resolve treats it as relative to ROOT,+ // regardless of whether the URL was absolute or contained duplicate+ // separators.+ const relPath = cleanPath.replace(/^\/+/, '');+ const candidate = path.resolve(ROOT, relPath);+ const relative = path.relative(ROOT, candidate);+ if (relative.startsWith('..') || path.isAbsolute(relative)) return null;+ try {+ return fs.statSync(candidate).isFile() ? candidate : null;+ } catch {+ return null;+ }+}++const server = http.createServer((req, res) => {+ setSharedHeaders(res);++ const rawUrlPath = (req.url || '/').split('?')[0].split('#')[0];+ let filePath = resolveFile(req.url || '/');+ // SPA fallback: serve index.html only for routes without a file extension+ // (i.e. client-side routes). Asset requests that miss get a real 404 so the+ // browser doesn't receive HTML when it asked for JS/CSS/etc.+ if (!filePath) {+ const hasExtension = path.extname(rawUrlPath) !== '';+ if (hasExtension) {+ res.writeHead(404);+ res.end('Not found');+ return;+ }+ filePath = INDEX_PATH;+ }++ const ext = path.extname(filePath).toLowerCase();+ res.setHeader('Content-Type', MIME[ext] || 'application/octet-stream');+ fs.createReadStream(filePath)+ .on('error', err => {+ res.writeHead(500);+ res.end(String(err));+ })+ .pipe(res);+});++server.listen(PORT, () => {+ console.log(`serve-build: serving ${ROOT} on http://localhost:${PORT}`);+});diff --git a/packages/desktop-client/e2e/accounts.test.ts b/packages/desktop-client/e2e/accounts.test.tsindex 85903c1c03..3010eb0f04 100644--- a/packages/desktop-client/e2e/accounts.test.ts+++ b/packages/desktop-client/e2e/accounts.test.ts@@ -86,7 +86,14 @@ test.describe('Accounts', () => {credit: '34.56',});- await page.waitForTimeout(100); // Give time for the previous transaction to be rendered+ // Wait for both newly created transactions to actually be in the+ // transaction list before selecting them. A bare waitForTimeout(100)+ // here is not enough under parallel CI load: the second+ // createSingleTransaction's row may still be mounting when the+ // selection clicks land, so the selection doesn't stick and the+ // 'Make transfer' button (rendered only when items are selected)+ // never appears.+ await expect(accountPage.getNthTransaction(1).payee).toBeVisible();await accountPage.selectNthTransaction(0);await accountPage.selectNthTransaction(1);diff --git a/packages/desktop-client/e2e/accounts.test.ts-snapshots/Accounts-creates-a-new-account-and-views-the-initial-balance-transaction-1-chromium-linux.png b/packages/desktop-client/e2e/accounts.test.ts-snapshots/Accounts-creates-a-new-account-and-views-the-initial-balance-transaction-1-chromium-linux.pngindex bad01046c6..cb6b79e918 100644Binary files a/packages/desktop-client/e2e/accounts.test.ts-snapshots/Accounts-creates-a-new-account-and-views-the-initial-balance-transaction-1-chromium-linux.png and b/packages/desktop-client/e2e/accounts.test.ts-snapshots/Accounts-creates-a-new-account-and-views-the-initial-balance-transaction-1-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/accounts.test.ts-snapshots/Accounts-creates-a-new-account-and-views-the-initial-balance-transaction-2-chromium-linux.png b/packages/desktop-client/e2e/accounts.test.ts-snapshots/Accounts-creates-a-new-account-and-views-the-initial-balance-transaction-2-chromium-linux.pngindex a785ac324f..aa50285bb1 100644Binary files a/packages/desktop-client/e2e/accounts.test.ts-snapshots/Accounts-creates-a-new-account-and-views-the-initial-balance-transaction-2-chromium-linux.png and b/packages/desktop-client/e2e/accounts.test.ts-snapshots/Accounts-creates-a-new-account-and-views-the-initial-balance-transaction-2-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/accounts.test.ts-snapshots/Accounts-creates-a-new-account-and-views-the-initial-balance-transaction-3-chromium-linux.png b/packages/desktop-client/e2e/accounts.test.ts-snapshots/Accounts-creates-a-new-account-and-views-the-initial-balance-transaction-3-chromium-linux.pngindex 701d1a3d2d..e41f6c77b8 100644Binary files a/packages/desktop-client/e2e/accounts.test.ts-snapshots/Accounts-creates-a-new-account-and-views-the-initial-balance-transaction-3-chromium-linux.png and b/packages/desktop-client/e2e/accounts.test.ts-snapshots/Accounts-creates-a-new-account-and-views-the-initial-balance-transaction-3-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/fixtures.ts b/packages/desktop-client/e2e/fixtures.tsindex 2e98f092f4..619791482e 100644--- a/packages/desktop-client/e2e/fixtures.ts+++ b/packages/desktop-client/e2e/fixtures.ts@@ -1,7 +1,54 @@-import { expect as baseExpect } from '@playwright/test';-import type { Locator } from '@playwright/test';+import { test as base, expect as baseExpect } from '@playwright/test';+import type { Browser, Locator } from '@playwright/test';-export { test } from '@playwright/test';+/**+ * Disable CSS transitions and animations globally in e2e (non-VRT) runs.+ * The Modal component's 100ms opacity transition races with Playwright's+ * click-stability check under parallel CI load ("element was detached+ * from the DOM, retrying"); snapping to final state makes clicks+ * deterministic.+ *+ * Wraps `browser.newPage` on the worker-scoped browser fixture because+ * every test creates its own page via `browser.newPage()` rather than+ * using the test-scoped `page` fixture — a `page`-fixture override would+ * be a no-op.+ */+const disableAnimationsInitScript = () => {+ const css = `*, *::before, *::after {+ transition-duration: 0s !important;+ transition-delay: 0s !important;+ animation-duration: 0s !important;+ animation-delay: 0s !important;+ }`;+ const install = () => {+ const style = document.createElement('style');+ style.setAttribute('data-e2e-disable-animations', 'true');+ style.textContent = css;+ document.head.appendChild(style);+ };+ if (document.head) {+ install();+ } else {+ document.addEventListener('DOMContentLoaded', install);+ }+};++export const test = process.env.VRT+ ? base+ : base.extend<object, { browser: Browser }>({+ browser: [+ async ({ browser }, runWithBrowser) => {+ const originalNewPage = browser.newPage.bind(browser);+ browser.newPage = async options => {+ const page = await originalNewPage(options);+ await page.addInitScript(disableAnimationsInitScript);+ return page;+ };+ await runWithBrowser(browser);+ },+ { scope: 'worker' },+ ],+ });export const expect = baseExpect.extend({async toMatchThemeScreenshots(locator: Locator) {diff --git a/packages/desktop-client/e2e/page-models/budget-page.ts b/packages/desktop-client/e2e/page-models/budget-page.tsindex ecb33b8584..300d823a02 100644--- a/packages/desktop-client/e2e/page-models/budget-page.ts+++ b/packages/desktop-client/e2e/page-models/budget-page.ts@@ -16,6 +16,15 @@ export class BudgetPage {this.budgetTableTotals = this.budgetTable.getByTestId('budget-totals');}+ /**+ * Wait for the budget page to finish loading. The budget-table is+ * inside AutoSizer which returns null until layout provides width/+ * height, so it only appears after the page has fully mounted.+ */+ async waitFor(...options: Parameters<Locator['waitFor']>) {+ await this.budgetTable.waitFor(...options);+ }+async getTotalBudgeted() {const totalBudgetedText = await this.budgetTableTotals.getByTestId(/total-budgeted$/)diff --git a/packages/desktop-client/e2e/page-models/configuration-page.ts b/packages/desktop-client/e2e/page-models/configuration-page.tsindex a54f1eabec..989a757337 100644--- a/packages/desktop-client/e2e/page-models/configuration-page.ts+++ b/packages/desktop-client/e2e/page-models/configuration-page.ts@@ -16,12 +16,18 @@ export class ConfigurationPage {async createTestFile() {await this.page.getByRole('button', { name: 'Create test file' }).click();- return new BudgetPage(this.page);+ const budgetPage = new BudgetPage(this.page);+ // Wait for the budget page to be fully mounted before returning so+ // callers don't race the virtualized budget-table's layout step.+ await budgetPage.waitFor();+ return budgetPage;}async createDemoFile() {await this.page.getByRole('button', { name: 'View demo' }).click();- return new BudgetPage(this.page);+ const budgetPage = new BudgetPage(this.page);+ await budgetPage.waitFor();+ return budgetPage;}async clickOnNoServer() {@@ -37,7 +43,9 @@ export class ConfigurationPage {async startFresh() {await this.page.getByRole('button', { name: 'Start fresh' }).click();- return new AccountPage(this.page);+ const accountPage = new AccountPage(this.page);+ await accountPage.accountName.waitFor();+ return accountPage;}async importBudget(type: 'YNAB4' | 'nYNAB' | 'Actual', file: string) {diff --git a/packages/desktop-client/e2e/page-models/mobile-budget-page.ts b/packages/desktop-client/e2e/page-models/mobile-budget-page.tsindex 189a15b7bb..621d2c18bf 100644--- a/packages/desktop-client/e2e/page-models/mobile-budget-page.ts+++ b/packages/desktop-client/e2e/page-models/mobile-budget-page.ts@@ -312,21 +312,14 @@ export class MobileBudgetPage {async #getButtonForEnvelopeBudgetSummary({throwIfNotFound = true,}: { throwIfNotFound?: boolean } = {}) {- if (await this.toBudgetButton.isVisible()) {- return this.toBudgetButton;+ const button = this.toBudgetButton.or(this.overbudgetedButton).first();+ try {+ await button.waitFor();+ } catch (err) {+ if (!throwIfNotFound) return null;+ throw err;}-- if (await this.overbudgetedButton.isVisible()) {- return this.overbudgetedButton;- }-- if (!throwIfNotFound) {- return null;- }-- throw new Error(- 'Neither "To Budget" nor "Overbudgeted" button could be located on the page.',- );+ return button;}async openEnvelopeBudgetSummary() {@@ -346,25 +339,17 @@ export class MobileBudgetPage {async #getButtonForTrackingBudgetSummary({throwIfNotFound = true,}: { throwIfNotFound?: boolean } = {}) {- if (await this.savedButton.isVisible()) {- return this.savedButton;- }-- if (await this.projectedSavingsButton.isVisible()) {- return this.projectedSavingsButton;- }-- if (await this.overspentButton.isVisible()) {- return this.overspentButton;- }-- if (!throwIfNotFound) {- return null;+ const button = this.savedButton+ .or(this.projectedSavingsButton)+ .or(this.overspentButton)+ .first();+ try {+ await button.waitFor();+ } catch (err) {+ if (!throwIfNotFound) return null;+ throw err;}-- throw new Error(- 'None of "Saved", "Projected savings", or "Overspent" buttons could be located on the page.',- );+ return button;}async openTrackingBudgetSummary() {diff --git a/packages/desktop-client/e2e/page-models/mobile-navigation.ts b/packages/desktop-client/e2e/page-models/mobile-navigation.tsindex 3652ee22dd..e211056fdf 100644--- a/packages/desktop-client/e2e/page-models/mobile-navigation.ts+++ b/packages/desktop-client/e2e/page-models/mobile-navigation.ts@@ -131,7 +131,9 @@ export class MobileNavigation {}const link = this.navbar.getByRole('link', { name: pageName });- await link.click();+ // Click via evaluate: the navbar uses react-spring transforms, so+ // Playwright's viewport-stability check rejects mid-animation clicks.+ await link.evaluate(el => (el as HTMLElement).click());await pageInstance.waitFor();diff --git a/packages/desktop-client/e2e/page-models/mobile-transaction-entry-page.ts b/packages/desktop-client/e2e/page-models/mobile-transaction-entry-page.tsindex 302d6113f5..3716814f59 100644--- a/packages/desktop-client/e2e/page-models/mobile-transaction-entry-page.ts+++ b/packages/desktop-client/e2e/page-models/mobile-transaction-entry-page.ts@@ -25,10 +25,31 @@ export class MobileTransactionEntryPage {await this.transactionForm.waitFor(...options);}+ async fillAmount(value: string) {+ await this.amountField.fill(value);+ await this.amountField.evaluate(el => (el as HTMLInputElement).blur());+ // TransactionEdit.onUpdate runs an async rules-run before setTransactions,+ // so wait for the outer display button (reads props.value) to reflect the+ // committed amount before the next fillField snapshots the transaction.+ await this.transactionForm+ .getByRole('button')+ .filter({ hasText: value })+ .waitFor();+ }+async fillField(fieldLocator: Locator, content: string) {await fieldLocator.click();- await this.page.locator('css=[role=combobox] input').fill(content);- await this.page.keyboard.press('Enter');+ const comboboxInput = this.page.getByRole('combobox').locator('input');+ // pressSequentially + option click: fill()+Enter breaks the autocomplete+ // highlight and selects "None"/wrong entry under CPU contention.+ await comboboxInput.pressSequentially(content);+ await this.page+ .getByRole('option')+ .filter({ hasText: content })+ .first()+ .click();+ await comboboxInput.waitFor({ state: 'hidden' });+ await fieldLocator.filter({ hasText: content }).waitFor();}async createTransaction() {diff --git a/packages/desktop-client/e2e/page-models/navigation.ts b/packages/desktop-client/e2e/page-models/navigation.tsindex 94792451ed..a457161acb 100644--- a/packages/desktop-client/e2e/page-models/navigation.ts+++ b/packages/desktop-client/e2e/page-models/navigation.ts@@ -1,4 +1,4 @@-import type { Page } from '@playwright/test';+import type { Locator, Page } from '@playwright/test';import { AccountPage } from './account-page';import { BankSyncPage } from './bank-sync-page';@@ -14,6 +14,55 @@ type AccountEntry = {offBudget: boolean;};+/**+ * Click a React Aria <Button> via a programmatic browser-side click.+ *+ * React Aria components re-render on focus state changes (`data-focused`,+ * `data-focus-visible`). Under parallel CI load, Playwright's `.click()`+ * stability check often sees the DOM node get detached and re-mounted+ * mid-action, leading to "element was detached from the DOM, retrying"+ * loops that exhaust the test timeout.+ *+ * `dispatchEvent('click')` is documented to skip stability checks but+ * dispatches a generic `Event` that React Aria's pointer-based onPress+ * does not respond to, so it doesn't actually activate the button.+ *+ * Calling `.click()` inside `page.evaluate` runs synchronously in the+ * browser: querySelector + click happen in one JS task with no CDP+ * roundtrip in between, so React has no chance to re-render between+ * resolution and click. HTMLElement.click() dispatches a real MouseEvent+ * that React Aria handles correctly.+ */+async function clickReactAriaButton(locator: Locator): Promise<void> {+ await locator.evaluate((el: HTMLElement) => el.click());+}++/**+ * Fill a React-controlled input via the native value setter + input event.+ *+ * React's controlled inputs respond to `input` events to update state.+ * Playwright's `.fill()` clears + types, dispatching multiple events that+ * each cause React Aria's input wrappers to re-render. Under load this+ * loops indefinitely as `.fill()`'s editability check keeps seeing+ * detached nodes.+ *+ * The native value setter pattern (https://stackoverflow.com/q/23892547)+ * sets the value once and dispatches a single input event. React+ * processes one state update and one re-render, then the input is stable.+ */+async function fillReactInput(locator: Locator, value: string): Promise<void> {+ await locator.evaluate((el, val) => {+ const input = el as HTMLInputElement;+ // oxlint-disable-next-line typescript/unbound-method -- documented React-controlled-input pattern+ const setter = Object.getOwnPropertyDescriptor(+ HTMLInputElement.prototype,+ 'value',+ )?.set;+ setter?.call(input, val);+ input.dispatchEvent(new Event('input', { bubbles: true }));+ }, value);+}+export class Navigation {readonly page: Page;@@ -95,22 +144,34 @@ export class Navigation {async createAccount(data: AccountEntry) {await this.page.getByRole('button', { name: 'Add account' }).click();++ // Clicking "Create a local account" pushes a second modal whose+ // heading is "Create Local Account". Wait for that heading to+ // confirm the form is fully mounted before touching any fields.+ await clickReactAriaButton(+ this.page.getByRole('button', { name: 'Create a local account' }),+ );await this.page- .getByRole('button', { name: 'Create a local account' })- .click();+ .getByRole('heading', { name: 'Create Local Account' })+ .waitFor({ state: 'visible' });- // Fill the form- await this.page.getByLabel('Name:').fill(data.name);- await this.page.getByLabel('Balance:').fill(String(data.balance));+ await fillReactInput(this.page.getByLabel('Name'), data.name);+ await fillReactInput(this.page.getByLabel('Balance'), String(data.balance));if (data.offBudget) {await this.page.getByLabel('Off budget').click();}- await this.page- .getByRole('button', { name: 'Create', exact: true })- .click();- return new AccountPage(this.page);+ await clickReactAriaButton(+ this.page.getByRole('button', { name: 'Create', exact: true }),+ );++ const accountPage = new AccountPage(this.page);+ await accountPage.waitFor();+ if (data.balance !== 0) {+ await accountPage.transactionTableRow.first().waitFor();+ }+ return accountPage;}async clickOnNoServer() {diff --git a/packages/desktop-client/e2e/page-models/schedule-edit-modal.ts b/packages/desktop-client/e2e/page-models/schedule-edit-modal.tsindex 1bc365aeda..75d9b73db8 100644--- a/packages/desktop-client/e2e/page-models/schedule-edit-modal.ts+++ b/packages/desktop-client/e2e/page-models/schedule-edit-modal.ts@@ -46,13 +46,11 @@ export class ScheduleEditModal {}if (data.payee) {- await this.payeeInput.pressSequentially(data.payee);- await this.page.keyboard.press('Enter');+ await this.#typeAndSelectOption(this.payeeInput, data.payee);}if (data.account) {- await this.accountInput.pressSequentially(data.account);- await this.page.keyboard.press('Enter');+ await this.#typeAndSelectOption(this.accountInput, data.account);}if (data.amount) {@@ -60,6 +58,16 @@ export class ScheduleEditModal {}}+ async #typeAndSelectOption(input: Locator, content: string) {+ await input.pressSequentially(content);+ // Click the option: Enter on a not-yet-highlighted list saves "None".+ await this.page+ .getByRole('option')+ .filter({ hasText: content })+ .first()+ .click();+ }+async save() {await this.saveButton.click();}diff --git a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-Switches-to-Area-Graph-and-checks-the-visuals-1-chromium-linux.png b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-Switches-to-Area-Graph-and-checks-the-visuals-1-chromium-linux.pngindex 40ff2d2af8..325b34b31f 100644Binary files a/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-Switches-to-Area-Graph-and-checks-the-visuals-1-chromium-linux.png and b/packages/desktop-client/e2e/reports.test.ts-snapshots/Reports-custom-reports-Switches-to-Area-Graph-and-checks-the-visuals-1-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/transactions.mobile.test.ts b/packages/desktop-client/e2e/transactions.mobile.test.tsindex bb400884ee..d4b343b07a 100644--- a/packages/desktop-client/e2e/transactions.mobile.test.ts+++ b/packages/desktop-client/e2e/transactions.mobile.test.ts@@ -32,7 +32,7 @@ test.describe('Mobile Transactions', () => {await expect(transactionEntryPage.header).toHaveText('New Transaction');- await transactionEntryPage.amountField.fill('12.34');+ await transactionEntryPage.fillAmount('12.34');// Click anywhere to cancel active edit.await transactionEntryPage.header.click();await transactionEntryPage.fillField(@@ -87,7 +87,7 @@ test.describe('Mobile Transactions', () => {await expect(transactionEntryPage.header).toHaveText('New Transaction');await expect(page).toMatchThemeScreenshots();- await transactionEntryPage.amountField.fill('12.34');+ await transactionEntryPage.fillAmount('12.34');// Click anywhere to cancel active edit.await transactionEntryPage.header.click();await transactionEntryPage.fillField(@@ -109,7 +109,7 @@ test.describe('Mobile Transactions', () => {test('creates an uncategorized transaction from `/categories/uncategorized` page', async () => {// Create uncategorized transactionlet transactionEntryPage = await navigation.goToTransactionEntryPage();- await transactionEntryPage.amountField.fill('12.35');+ await transactionEntryPage.fillAmount('12.35');// Click anywhere to cancel active edit.await transactionEntryPage.header.click();await transactionEntryPage.fillField(@@ -123,7 +123,7 @@ test.describe('Mobile Transactions', () => {await expect(transactionEntryPage.header).toHaveText('New Transaction');- await transactionEntryPage.amountField.fill('12.34');+ await transactionEntryPage.fillAmount('12.34');// Click anywhere to cancel active edit.await transactionEntryPage.header.click();await transactionEntryPage.fillField(@@ -142,7 +142,7 @@ test.describe('Mobile Transactions', () => {test('creates a categorized transaction from `/categories/uncategorized` page', async () => {// Create uncategorized transactionlet transactionEntryPage = await navigation.goToTransactionEntryPage();- await transactionEntryPage.amountField.fill('12.35');+ await transactionEntryPage.fillAmount('12.35');// Click anywhere to cancel active edit.await transactionEntryPage.header.click();await transactionEntryPage.fillField(@@ -156,7 +156,7 @@ test.describe('Mobile Transactions', () => {await expect(transactionEntryPage.header).toHaveText('New Transaction');- await transactionEntryPage.amountField.fill('12.34');+ await transactionEntryPage.fillAmount('12.34');// Click anywhere to cancel active edit.await transactionEntryPage.header.click();await transactionEntryPage.fillField(diff --git a/packages/desktop-client/e2e/transactions.mobile.test.ts-snapshots/Mobile-Transactions-creates-a-transaction-via-footer-button-6-chromium-linux.png b/packages/desktop-client/e2e/transactions.mobile.test.ts-snapshots/Mobile-Transactions-creates-a-transaction-via-footer-button-6-chromium-linux.pngindex 2a5745b490..eb44d7b646 100644Binary files a/packages/desktop-client/e2e/transactions.mobile.test.ts-snapshots/Mobile-Transactions-creates-a-transaction-via-footer-button-6-chromium-linux.png and b/packages/desktop-client/e2e/transactions.mobile.test.ts-snapshots/Mobile-Transactions-creates-a-transaction-via-footer-button-6-chromium-linux.png differdiff --git a/packages/desktop-client/playwright.config.ts b/packages/desktop-client/playwright.config.tsindex e0d6d1461a..d71f000aca 100644--- a/packages/desktop-client/playwright.config.ts+++ b/packages/desktop-client/playwright.config.ts@@ -6,31 +6,40 @@ export default defineConfig({timeout: 60000, // 60 secondsretries: 1,fullyParallel: true,- workers: process.env.CI ? 1 : undefined,+ workers: process.env.CI ? 4 : undefined,testDir: 'e2e/',reporter: process.env.CI? [['blob'], ['list']]: [['html', { open: 'never' }]],use: {userAgent: 'playwright',- screenshot: 'on',+ screenshot: 'only-on-failure',browserName: 'chromium',baseURL: process.env.E2E_START_URL ?? 'http://localhost:3001',trace: 'on-first-retry',ignoreHTTPSErrors: true,},expect: {+ // Default expect timeout (5s) is too tight for initial render of the+ // budget page in the production bundle under CI CPU contention —+ // the budget-table testid lives inside AutoSizer, which returns null+ // until layout provides width/height, and that can take >5s. Bumping+ // to 10s lets those assertions settle without per-test overrides.+ timeout: 10_000,toHaveScreenshot: { maxDiffPixels: 5 },},webServer: process.env.E2E_START_URL? undefined: {cwd: path.join(__dirname, '..', '..'),- command: 'yarn start',+ command: process.env.E2E_USE_BUILD+ ? 'node packages/desktop-client/bin/serve-build.mjs'+ : 'yarn start',url: 'http://localhost:3001',reuseExistingServer: !process.env.CI,stdout: 'ignore',stderr: 'pipe',ignoreHTTPSErrors: true,+ timeout: 120_000,},});diff --git a/packages/desktop-client/src/components/mobile/transactions/FocusableAmountInput.tsx b/packages/desktop-client/src/components/mobile/transactions/FocusableAmountInput.tsxindex 3c0939782c..2493ed6afc 100644--- a/packages/desktop-client/src/components/mobile/transactions/FocusableAmountInput.tsx+++ b/packages/desktop-client/src/components/mobile/transactions/FocusableAmountInput.tsx@@ -79,9 +79,14 @@ const AmountInput = memo(function AmountInput({}};- const applyText = () => {- const parsed = currencyToAmount(text) || 0;- const newValue = editing ? parsed : value;+ // Read from the DOM, not React state: onChange state updates flush+ // asynchronously, so an onBlur/onKeyUp fired by the user's next action+ // can see stale `text=''` and save 0 instead of the typed amount.+ const applyText = (rawInput?: string) => {+ const domText = rawInput ?? inputRef.current?.value ?? text;+ const parsed = currencyToAmount(domText) || 0;+ const hasPendingInput = domText !== '' || editing;+ const newValue = hasPendingInput ? parsed : value;setValue(Math.abs(newValue));setEditing(false);@@ -96,7 +101,7 @@ const AmountInput = memo(function AmountInput({const onUpdate = (value: string) => {const originalAmount = Math.abs(props.value);- const amount = applyText();+ const amount = applyText(value);if (amount !== originalAmount) {props.onUpdate?.(value);props.onUpdateAmount?.(amount);diff --git a/upcoming-release-notes/7503.md b/upcoming-release-notes/7503.mdnew file mode 100644index 0000000000..abada84448--- /dev/null+++ b/upcoming-release-notes/7503.md@@ -0,0 +1,6 @@+---+category: Maintenance+authors: [MatissJanis]+---++Optimize CI e2e tests by using pre-built bundles, reducing build time.