Files
actual/packages/desktop-client/e2e/page-models/navigation.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

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();
}
}