Skip to content

A local-first personal finance app

test: csv import e2e tests (#3499)

Koen van Staveren6d122c898d89
diff --git a/packages/desktop-client/e2e/accounts.test.js b/packages/desktop-client/e2e/accounts.test.js
index c7e0d02219..eb83edaf16 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';
@@ -9,7 +11,7 @@ test.describe('Accounts', () => {
let configurationPage;
let accountPage;
- test.beforeAll(async ({ browser }) => {
+ test.beforeEach(async ({ browser }) => {
page = await browser.newPage();
navigation = new Navigation(page);
configurationPage = new ConfigurationPage(page);
@@ -18,7 +20,7 @@ test.describe('Accounts', () => {
await configurationPage.createTestFile();
});
- test.afterAll(async () => {
+ test.afterEach(async () => {
await page.close();
});
@@ -99,4 +101,40 @@ 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,
+ });
+ });
+
+ 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();
+
+ const importButton = accountPage.page.getByRole('button', {
+ name: /Import \d+ transactions/,
+ });
+ await importButton.click();
+
+ await expect(importButton).not.toBeVisible();
+ }
+
+ test('imports transactions from a CSV file', async () => {
+ await importCsv(true);
+ });
+
+ test('import csv file twice', async () => {
+ await importCsv(false);
+ 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..d6d043c53d
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..ec7958f9ac
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..95d28c6477
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..3fc95842ff
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..94332d6efe
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..b82756952f
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/accounts.test.js-snapshots/Accounts-closes-an-account-1-chromium-linux.png b/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-closes-an-account-1-chromium-linux.png
index ff03598880..9a4c890ee5 100644
Binary files a/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-closes-an-account-1-chromium-linux.png and b/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-closes-an-account-1-chromium-linux.png differ
diff --git a/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-closes-an-account-2-chromium-linux.png b/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-closes-an-account-2-chromium-linux.png
index 8a51b293a7..8cc790234d 100644
Binary files a/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-closes-an-account-2-chromium-linux.png and b/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-closes-an-account-2-chromium-linux.png differ
diff --git a/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-closes-an-account-3-chromium-linux.png b/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-closes-an-account-3-chromium-linux.png
index d5b4b30c7f..fcac4066d8 100644
Binary files a/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-closes-an-account-3-chromium-linux.png and b/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-closes-an-account-3-chromium-linux.png differ
diff --git a/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-closes-an-account-4-chromium-linux.png b/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-closes-an-account-4-chromium-linux.png
index 8b0146d47a..481278c731 100644
Binary files a/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-closes-an-account-4-chromium-linux.png and b/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-closes-an-account-4-chromium-linux.png differ
diff --git a/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-closes-an-account-5-chromium-linux.png b/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-closes-an-account-5-chromium-linux.png
index fa10b0415b..c021b255e9 100644
Binary files a/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-closes-an-account-5-chromium-linux.png and b/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-closes-an-account-5-chromium-linux.png differ
diff --git a/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-closes-an-account-6-chromium-linux.png b/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-closes-an-account-6-chromium-linux.png
index dfd30f5f2f..e9588ed638 100644
Binary files a/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-closes-an-account-6-chromium-linux.png and b/packages/desktop-client/e2e/accounts.test.js-snapshots/Accounts-closes-an-account-6-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/src/components/modals/ImportTransactionsModal/FieldMappings.jsx b/packages/desktop-client/src/components/modals/ImportTransactionsModal/FieldMappings.jsx
index 55cbf2fb72..b57e651dce 100644
--- a/packages/desktop-client/src/components/modals/ImportTransactionsModal/FieldMappings.jsx
+++ b/packages/desktop-client/src/components/modals/ImportTransactionsModal/FieldMappings.jsx
@@ -33,45 +33,41 @@ export function FieldMappings({
spacing={1}
style={{ marginTop: 5 }}
>
- <View style={{ flex: 1 }}>
+ <View style={{ flex: 1, marginRight: 10 }}>
<SubLabel title="Date" />
<SelectField
options={options}
value={mappings.date}
- style={{ marginRight: 5 }}
onChange={name => onChange('date', name)}
hasHeaderRow={hasHeaderRow}
firstTransaction={transactions[0]}
/>
</View>
- <View style={{ flex: 1 }}>
+ <View style={{ flex: 1, marginRight: 10 }}>
<SubLabel title="Payee" />
<SelectField
options={options}
value={mappings.payee}
- style={{ marginRight: 5 }}
onChange={name => onChange('payee', name)}
hasHeaderRow={hasHeaderRow}
firstTransaction={transactions[0]}
/>
</View>
- <View style={{ flex: 1 }}>
+ <View style={{ flex: 1, marginRight: 10 }}>
<SubLabel title="Notes" />
<SelectField
options={options}
value={mappings.notes}
- style={{ marginRight: 5 }}
onChange={name => onChange('notes', name)}
hasHeaderRow={hasHeaderRow}
firstTransaction={transactions[0]}
/>
</View>
- <View style={{ flex: 1 }}>
+ <View style={{ flex: 1, marginRight: 10 }}>
<SubLabel title="Category" />
<SelectField
options={options}
value={mappings.category}
- style={{ marginRight: 5 }}
onChange={name => onChange('category', name)}
hasHeaderRow={hasHeaderRow}
firstTransaction={transactions[0]}
diff --git a/upcoming-release-notes/3499.md b/upcoming-release-notes/3499.md
new file mode 100644
index 0000000000..ef1ecb2648
--- /dev/null
+++ b/upcoming-release-notes/3499.md
@@ -0,0 +1,6 @@
+---
+category: Maintenance
+authors: [UnderKoen]
+---
+
+E2E tests for CSV import dialog