mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-21 15:36:50 -05:00
* 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>
63 lines
1.7 KiB
TypeScript
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);
|
|
}
|
|
}
|