Skip to content

A local-first personal finance app

CSV import e2e tests (#3467)

Koen van Staveren5e12d4013a2f
diff --git a/packages/desktop-client/e2e/accounts.test.js b/packages/desktop-client/e2e/accounts.test.js
index c7e0d02219..69eac67dac 100644
--- a/packages/desktop-client/e2e/accounts.test.js
+++ b/packages/desktop-client/e2e/accounts.test.js
@@ -1,3 +1,5 @@
+import { join } from 'path';
+
import { test, expect } from '@playwright/test';
import { ConfigurationPage } from './page-models/configuration-page';
@@ -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);
+ });
+ });
});
diff --git a/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-Import-Transactions-import-csv-file-twice-1-chromium-linux.png b/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-Import-Transactions-import-csv-file-twice-1-chromium-linux.png
new file mode 100644
index 0000000000..c3349157f3
Binary files /dev/null and b/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-Import-Transactions-import-csv-file-twice-1-chromium-linux.png differ
diff --git a/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-Import-Transactions-import-csv-file-twice-2-chromium-linux.png b/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-Import-Transactions-import-csv-file-twice-2-chromium-linux.png
new file mode 100644
index 0000000000..d5155500fd
Binary files /dev/null and b/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-Import-Transactions-import-csv-file-twice-2-chromium-linux.png differ
diff --git a/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-Import-Transactions-import-csv-file-twice-3-chromium-linux.png b/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-Import-Transactions-import-csv-file-twice-3-chromium-linux.png
new file mode 100644
index 0000000000..aab5a9f277
Binary files /dev/null and b/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-Import-Transactions-import-csv-file-twice-3-chromium-linux.png differ
diff --git a/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-Import-Transactions-imports-transactions-from-a-CSV-file-1-chromium-linux.png b/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-Import-Transactions-imports-transactions-from-a-CSV-file-1-chromium-linux.png
new file mode 100644
index 0000000000..e0b56f46d6
Binary files /dev/null and b/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-Import-Transactions-imports-transactions-from-a-CSV-file-1-chromium-linux.png differ
diff --git a/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-Import-Transactions-imports-transactions-from-a-CSV-file-2-chromium-linux.png b/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-Import-Transactions-imports-transactions-from-a-CSV-file-2-chromium-linux.png
new file mode 100644
index 0000000000..8a9ec7068f
Binary files /dev/null and b/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-Import-Transactions-imports-transactions-from-a-CSV-file-2-chromium-linux.png differ
diff --git a/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-Import-Transactions-imports-transactions-from-a-CSV-file-3-chromium-linux.png b/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-Import-Transactions-imports-transactions-from-a-CSV-file-3-chromium-linux.png
new file mode 100644
index 0000000000..b421286bae
Binary files /dev/null and b/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-Import-Transactions-imports-transactions-from-a-CSV-file-3-chromium-linux.png differ
diff --git a/packages/desktop-client/e2e/data/test.csv b/packages/desktop-client/e2e/data/test.csv
new file mode 100644
index 0000000000..022d65f739
--- /dev/null
+++ b/packages/desktop-client/e2e/data/test.csv
@@ -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
diff --git a/packages/desktop-client/e2e/page-models/close-account-modal.js b/packages/desktop-client/e2e/page-models/close-account-modal.js
index 7cd689732a..d25eebcdb4 100644
--- a/packages/desktop-client/e2e/page-models/close-account-modal.js
+++ b/packages/desktop-client/e2e/page-models/close-account-modal.js
@@ -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();
+ }
}
diff --git a/packages/desktop-client/src/components/modals/CloseAccountModal.tsx b/packages/desktop-client/src/components/modals/CloseAccountModal.tsx
index 0a9966d59d..64f072891e 100644
--- a/packages/desktop-client/src/components/modals/CloseAccountModal.tsx
+++ b/packages/desktop-client/src/components/modals/CloseAccountModal.tsx
@@ -230,6 +230,7 @@ export function CloseAccountModal({
close();
}}
style={{ color: theme.errorText }}
+ aria-label="Force close"
>
force close
</Link>{' '}
diff --git a/upcoming-release-notes/3467.md b/upcoming-release-notes/3467.md
new file mode 100644
index 0000000000..ef1ecb2648
--- /dev/null
+++ b/upcoming-release-notes/3467.md
@@ -0,0 +1,6 @@
+---
+category: Maintenance
+authors: [UnderKoen]
+---
+
+E2E tests for CSV import dialog