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

73 lines
2.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { type Locator, type Page } from '@playwright/test';
import { AccountPage } from './account-page';
import { BudgetPage } from './budget-page';
export class ConfigurationPage {
readonly page: Page;
readonly heading: Locator;
constructor(page: Page) {
this.page = page;
this.heading = page.getByRole('heading');
}
async createTestFile() {
await this.page.getByRole('button', { name: 'Create test file' }).click();
return new BudgetPage(this.page);
}
async clickOnNoServer() {
await this.page.getByRole('button', { name: 'Dont use a server' }).click();
}
async startFresh() {
await this.page.getByRole('button', { name: 'Start fresh' }).click();
return new AccountPage(this.page);
}
async importBudget(type: 'YNAB4' | 'nYNAB' | 'Actual', file: string) {
const fileChooserPromise = this.page.waitForEvent('filechooser');
await this.page.getByRole('button', { name: 'Import my budget' }).click();
switch (type) {
case 'YNAB4':
await this.page
.getByRole('button', {
name: 'YNAB4 The old unsupported desktop app',
})
.click();
await this.page
.getByRole('button', { name: 'Select zip file...' })
.click();
break;
case 'nYNAB':
await this.page
.getByRole('button', { name: 'nYNAB The newer web app' })
.click();
await this.page.getByRole('button', { name: 'Select file...' }).click();
break;
case 'Actual':
await this.page
.getByRole('button', {
name: 'Actual Import a file exported from Actual',
})
.click();
await this.page.getByRole('button', { name: 'Select file...' }).click();
break;
default:
throw new Error(`Unrecognized import type: ${type}`);
}
const fileChooser = await fileChooserPromise;
await fileChooser.setFiles(file);
return new BudgetPage(this.page);
}
}