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>
92 lines
2.3 KiB
TypeScript
92 lines
2.3 KiB
TypeScript
import { type Page } from '@playwright/test';
|
|
|
|
import { AccountPage } from './account-page';
|
|
import { ReportsPage } from './reports-page';
|
|
import { RulesPage } from './rules-page';
|
|
import { SchedulesPage } from './schedules-page';
|
|
import { SettingsPage } from './settings-page';
|
|
|
|
type AccountEntry = {
|
|
name: string;
|
|
balance: number;
|
|
offBudget: boolean;
|
|
};
|
|
|
|
export class Navigation {
|
|
readonly page: Page;
|
|
|
|
constructor(page: Page) {
|
|
this.page = page;
|
|
}
|
|
|
|
async goToAccountPage(accountName: string) {
|
|
await this.page
|
|
.getByRole('link', { name: new RegExp(`^${accountName}`) })
|
|
.click();
|
|
|
|
return new AccountPage(this.page);
|
|
}
|
|
|
|
async goToReportsPage() {
|
|
await this.page.getByRole('link', { name: 'Reports' }).click();
|
|
|
|
return new ReportsPage(this.page);
|
|
}
|
|
|
|
async goToSchedulesPage() {
|
|
await this.page.getByRole('link', { name: 'Schedules' }).click();
|
|
|
|
return new SchedulesPage(this.page);
|
|
}
|
|
|
|
async goToRulesPage() {
|
|
const rulesLink = this.page.getByRole('link', { name: 'Rules' });
|
|
|
|
// Expand the "more" menu only if it is not already expanded
|
|
if (!(await rulesLink.isVisible())) {
|
|
await this.page.getByRole('button', { name: 'More' }).click();
|
|
}
|
|
|
|
await rulesLink.click();
|
|
|
|
return new RulesPage(this.page);
|
|
}
|
|
|
|
async goToSettingsPage() {
|
|
const settingsLink = this.page.getByRole('link', { name: 'Settings' });
|
|
|
|
// Expand the "more" menu only if it is not already expanded
|
|
if (!(await settingsLink.isVisible())) {
|
|
await this.page.getByRole('button', { name: 'More' }).click();
|
|
}
|
|
|
|
await settingsLink.click();
|
|
|
|
return new SettingsPage(this.page);
|
|
}
|
|
|
|
async createAccount(data: AccountEntry) {
|
|
await this.page.getByRole('button', { name: 'Add account' }).click();
|
|
await this.page
|
|
.getByRole('button', { name: 'Create a local account' })
|
|
.click();
|
|
|
|
// Fill the form
|
|
await this.page.getByLabel('Name:').fill(data.name);
|
|
await this.page.getByLabel('Balance:').fill(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);
|
|
}
|
|
|
|
async clickOnNoServer() {
|
|
await this.page.getByRole('button', { name: 'No server' }).click();
|
|
}
|
|
}
|