Skip to content

Commit

Permalink
CSV import e2e tests (actualbudget#3467)
Browse files Browse the repository at this point in the history
  • Loading branch information
UnderKoen authored Sep 19, 2024
1 parent 84af8b7 commit 5e12d40
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 0 deletions.
42 changes: 42 additions & 0 deletions packages/desktop-client/e2e/accounts.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { join } from 'path';

import { test, expect } from '@playwright/test';

import { ConfigurationPage } from './page-models/configuration-page';
Expand Down Expand Up @@ -99,4 +101,44 @@ test.describe('Accounts', () => {
await expect(transaction.account).toHaveText('Ally Savings');
});
});

test.describe('Import Transactions', () => {
test.beforeEach(async () => {
accountPage = await navigation.createAccount({
name: 'CSV import',
offBudget: false,
balance: 0,
});
});

test.afterEach(async () => {
const close = await accountPage.clickCloseAccount();
await close.selectTransferAccount('Vanguard 401k');
await close.forceCloseAccount();
});

async function importCsv(screenshot = false) {
const fileChooserPromise = page.waitForEvent('filechooser');
await accountPage.page.getByRole('button', { name: 'Import' }).click();

const fileChooser = await fileChooserPromise;
await fileChooser.setFiles(join(__dirname, 'data/test.csv'));

if (screenshot) await expect(page).toMatchThemeScreenshots();

await accountPage.page
.getByRole('button', { name: /Import \d+ transactions/ })
.click();
}

test('imports transactions from a CSV file', async () => {
await importCsv(true);
});

test('import csv file twice', async () => {
await importCsv(false);
await page.waitForTimeout(1000);
await importCsv(true);
});
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions packages/desktop-client/e2e/data/test.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Date,Payee,Notes,Category,Amount
2024-08-02,Deposit,test 1,Income,1787.76
2024-07-02,Deposit,test 2,Income,1787.76
2024-06-02,Deposit,test 3,Income,1787.76
2024-05-02,Deposit,test 4,Income,1787.76
2024-04-02,Deposit,test 5,Income,1787.76
2024-03-02,Deposit,test 6,Income,1787.76
2024-02-02,Deposit,test 7,Income,1787.76
2024-01-02,Starting Balance,test 8,Starting Balances,-330000
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ export class CloseAccountModal {
async closeAccount() {
await this.page.getByRole('button', { name: 'Close account' }).click();
}

async forceCloseAccount() {
await this.page.getByLabel('Force close').click();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ export function CloseAccountModal({
close();
}}
style={{ color: theme.errorText }}
aria-label="Force close"
>
force close
</Link>{' '}
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/3467.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Maintenance
authors: [UnderKoen]
---

E2E tests for CSV import dialog

0 comments on commit 5e12d40

Please sign in to comment.