Files
actual/packages/desktop-client/e2e/page-models/mobile-account-page.ts
Joel Jeremy Marquez 0504becaf5 [TypeScript] Convert test page models to TS (#4218)
* Dummy commit

* Delete js snapshots

* Move extended expect and test to fixtures

* Fix wrong commit

* Update VRT

* Dummy commit to run GH actions

* Convert test page models to TS

* Release notes

* Fix typecheck errors

* New page models to TS

* Fix typecheck error

* Fix page name

* Put awaits on getTableTotals

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-02-16 10:24:38 -08:00

63 lines
1.7 KiB
TypeScript

import { type Locator, type Page } from '@playwright/test';
import { MobileTransactionEntryPage } from './mobile-transaction-entry-page';
export class MobileAccountPage {
readonly page: Page;
readonly heading: Locator;
readonly balance: Locator;
readonly noTransactionsMessage: Locator;
readonly searchBox: Locator;
readonly transactionList: Locator;
readonly transactions: Locator;
readonly createTransactionButton: Locator;
constructor(page: Page) {
this.page = page;
this.heading = page.getByRole('heading');
this.balance = page.getByTestId('transactions-balance');
this.noTransactionsMessage = page.getByText('No transactions');
this.searchBox = page.getByPlaceholder(/^Search/);
this.transactionList = page.getByLabel('Transaction list');
this.transactions = this.transactionList.getByRole('button');
this.createTransactionButton = page.getByRole('button', {
name: 'Add Transaction',
});
}
async waitFor(...options: Parameters<Locator['waitFor']>) {
await this.transactionList.waitFor(...options);
}
/**
* Retrieve the balance of the account as a number
*/
async getBalance() {
const balanceText = await this.balance.textContent();
if (!balanceText) {
throw new Error('Failed to get balance.');
}
return parseInt(balanceText, 10);
}
/**
* Search by the given term
*/
async searchByText(term: string) {
await this.searchBox.fill(term);
}
async clearSearch() {
await this.searchBox.clear();
}
/**
* Go to transaction creation page
*/
async clickCreateTransaction() {
this.createTransactionButton.click();
return new MobileTransactionEntryPage(this.page);
}
}