Skip to content

A local-first personal finance app

make import button reflect accurate number of transactions to be added (#3613)

Matt Fiddamane37a42faf9f9
diff --git a/packages/desktop-client/e2e/accounts.test.js b/packages/desktop-client/e2e/accounts.test.js
index eb83edaf16..1467e6d114 100644
--- a/packages/desktop-client/e2e/accounts.test.js
+++ b/packages/desktop-client/e2e/accounts.test.js
@@ -134,7 +134,27 @@ test.describe('Accounts', () => {
test('import csv file twice', async () => {
await importCsv(false);
- await importCsv(true);
+
+ 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'));
+
+ await expect(page).toMatchThemeScreenshots();
+
+ const importButton = accountPage.page.getByRole('button', {
+ name: /Import \d+ transactions/,
+ });
+
+ await expect(importButton).toBeDisabled();
+ await expect(await importButton.innerText()).toMatch(
+ /Import 0 transactions/,
+ );
+
+ await accountPage.page.getByRole('button', { name: 'Close' }).click();
+
+ await expect(importButton).not.toBeVisible();
});
});
});
diff --git a/packages/desktop-client/src/components/modals/ImportTransactionsModal/ImportTransactionsModal.jsx b/packages/desktop-client/src/components/modals/ImportTransactionsModal/ImportTransactionsModal.jsx
index 9aa7b0e4d9..b65187279f 100644
--- a/packages/desktop-client/src/components/modals/ImportTransactionsModal/ImportTransactionsModal.jsx
+++ b/packages/desktop-client/src/components/modals/ImportTransactionsModal/ImportTransactionsModal.jsx
@@ -1045,8 +1045,9 @@ export function ImportTransactionsModal({ options }) {
variant="primary"
autoFocus
isDisabled={
- transactions?.filter(trans => !trans.isMatchedTransaction)
- .length === 0
+ transactions?.filter(
+ trans => !trans.isMatchedTransaction && trans.selected,
+ ).length === 0
}
isLoading={loadingState === 'importing'}
onPress={() => {
@@ -1055,8 +1056,9 @@ export function ImportTransactionsModal({ options }) {
>
Import{' '}
{
- transactions?.filter(trans => !trans.isMatchedTransaction)
- .length
+ transactions?.filter(
+ trans => !trans.isMatchedTransaction && trans.selected,
+ ).length
}{' '}
transactions
</ButtonWithLoading>
diff --git a/upcoming-release-notes/3613.md b/upcoming-release-notes/3613.md
new file mode 100644
index 0000000000..ccd87763cb
--- /dev/null
+++ b/upcoming-release-notes/3613.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: [matt-fidd]
+---
+
+Make import button reflect accurate number of transactions to be added