Files
actual/packages/desktop-client/e2e/page-models/configuration-page.js
2024-06-08 11:55:09 -04:00

65 lines
1.7 KiB
JavaScript
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 { BudgetPage } from './budget-page';
export class ConfigurationPage {
constructor(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();
}
async importBudget(type, file) {
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);
}
}