From 761b3c6a167f642908fd1989209938463745f001 Mon Sep 17 00:00:00 2001 From: DJ Mountney Date: Tue, 9 Jan 2024 11:20:06 -0800 Subject: [PATCH 1/3] Tests: Add api tests for payees and transactions (#2168) * Tests: Add api CRUD tests for payees and transactions --- packages/api/methods.test.ts | 113 +++++++++++++++++++++++++++++++++ upcoming-release-notes/2168.md | 6 ++ 2 files changed, 119 insertions(+) create mode 100644 upcoming-release-notes/2168.md diff --git a/packages/api/methods.test.ts b/packages/api/methods.test.ts index cca376242fc..f38a6985e70 100644 --- a/packages/api/methods.test.ts +++ b/packages/api/methods.test.ts @@ -272,4 +272,117 @@ describe('API CRUD operations', () => { ]), ); }); + + // apis: createPayee, getPayees, updatePayee, deletePayee + test('Payees: successfully update payees', async () => { + const payeeId1 = await api.createPayee({ name: 'test-payee1' }); + const payeeId2 = await api.createPayee({ name: 'test-payee2' }); + let payees = await api.getPayees(); + + // payees successfully created + expect(payees).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + id: payeeId1, + name: 'test-payee1', + }), + expect.objectContaining({ + id: payeeId2, + name: 'test-payee2', + }), + ]), + ); + + await api.updatePayee(payeeId1, { name: 'test-updated-payee' }); + await api.deletePayee(payeeId2); + + // confirm update and delete were successful + payees = await api.getPayees(); + expect(payees).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + id: payeeId1, + name: 'test-updated-payee', + }), + expect.not.objectContaining({ + name: 'test-payee1', + }), + expect.not.objectContaining({ + id: payeeId2, + }), + ]), + ); + }); + + // apis: addTransactions, getTransactions, importTransactions, updateTransaction, deleteTransaction + test('Transactions: successfully update transactions', async () => { + const accountId = await api.createAccount({ name: 'test-account' }, 0); + + let newTransaction = [ + { date: '2023-11-03', imported_id: '11', amount: 100 }, + { date: '2023-11-03', imported_id: '11', amount: 100 }, + ]; + + const addResult = await api.addTransactions(accountId, newTransaction, { + learnCategories: true, + runTransfers: true, + }); + expect(addResult).toBe('ok'); + + // confirm added transactions exist + let transactions = await api.getTransactions( + accountId, + '2023-11-01', + '2023-11-30', + ); + expect(transactions).toEqual( + expect.arrayContaining( + newTransaction.map(trans => expect.objectContaining(trans)), + ), + ); + expect(transactions).toHaveLength(2); + + newTransaction = [ + { date: '2023-12-03', imported_id: '11', amount: 100 }, + { date: '2023-12-03', imported_id: '22', amount: 200 }, + ]; + + const reconciled = await api.importTransactions(accountId, newTransaction); + + // Expect it to reconcile and to have updated one of the previous transactions + expect(reconciled.added).toHaveLength(1); + expect(reconciled.updated).toHaveLength(1); + + // confirm imported transactions exist + transactions = await api.getTransactions( + accountId, + '2023-12-01', + '2023-12-31', + ); + expect(transactions).toEqual( + expect.arrayContaining( + newTransaction.map(trans => expect.objectContaining(trans)), + ), + ); + expect(transactions).toHaveLength(2); + + const idToUpdate = reconciled.added[0]; + const idToDelete = reconciled.updated[0]; + await api.updateTransaction(idToUpdate, { amount: 500 }); + await api.deleteTransaction(idToDelete); + + // confirm updates and deletions work + transactions = await api.getTransactions( + accountId, + '2023-12-01', + '2023-12-31', + ); + expect(transactions).toEqual( + expect.arrayContaining([ + expect.objectContaining({ id: idToUpdate, amount: 500 }), + expect.not.objectContaining({ id: idToDelete }), + ]), + ); + expect(transactions).toHaveLength(1); + }); }); diff --git a/upcoming-release-notes/2168.md b/upcoming-release-notes/2168.md new file mode 100644 index 00000000000..8362cc10cf6 --- /dev/null +++ b/upcoming-release-notes/2168.md @@ -0,0 +1,6 @@ +--- +category: Maintenance +authors: [twk3] +--- + +Add api tests for payees and transactions From 4ece4a7ff6df6781c375f2b73fc5c146ab16b32e Mon Sep 17 00:00:00 2001 From: Matiss Janis Aboltins Date: Tue, 9 Jan 2024 19:21:16 +0000 Subject: [PATCH 2/3] :recycle: (gocardless) rename nordigen_* secrets to gocardless_* (#2181) --- .../src/components/modals/GoCardlessInitialise.tsx | 4 ++-- upcoming-release-notes/2181.md | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 upcoming-release-notes/2181.md diff --git a/packages/desktop-client/src/components/modals/GoCardlessInitialise.tsx b/packages/desktop-client/src/components/modals/GoCardlessInitialise.tsx index 78a19b5fc61..2a8555522b3 100644 --- a/packages/desktop-client/src/components/modals/GoCardlessInitialise.tsx +++ b/packages/desktop-client/src/components/modals/GoCardlessInitialise.tsx @@ -36,11 +36,11 @@ export const GoCardlessInitialise = ({ await Promise.all([ send('secret-set', { - name: 'nordigen_secretId', + name: 'gocardless_secretId', value: secretId, }), send('secret-set', { - name: 'nordigen_secretKey', + name: 'gocardless_secretKey', value: secretKey, }), ]); diff --git a/upcoming-release-notes/2181.md b/upcoming-release-notes/2181.md new file mode 100644 index 00000000000..7d835a7ae4c --- /dev/null +++ b/upcoming-release-notes/2181.md @@ -0,0 +1,6 @@ +--- +category: Maintenance +authors: [MatissJanis] +--- + +migration: rename `nordigen_*` secrets to `gocardless_*` From ef9a7cfe855b7b2080f300512a6873eb2a7e1567 Mon Sep 17 00:00:00 2001 From: Matiss Janis Aboltins Date: Tue, 9 Jan 2024 20:06:50 +0000 Subject: [PATCH 3/3] :wrench: (ci) fork the electron build job - master and PR (#2209) --- .../{electron.yml => electron-master.yml} | 5 +-- .github/workflows/electron-pr.yml | 43 +++++++++++++++++++ upcoming-release-notes/2209.md | 6 +++ 3 files changed, 51 insertions(+), 3 deletions(-) rename .github/workflows/{electron.yml => electron-master.yml} (87%) create mode 100644 .github/workflows/electron-pr.yml create mode 100644 upcoming-release-notes/2209.md diff --git a/.github/workflows/electron.yml b/.github/workflows/electron-master.yml similarity index 87% rename from .github/workflows/electron.yml rename to .github/workflows/electron-master.yml index 717d197c79f..0fe0dd17025 100644 --- a/.github/workflows/electron.yml +++ b/.github/workflows/electron-master.yml @@ -11,11 +11,10 @@ on: push: branches: - master - pull_request: concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false jobs: build: diff --git a/.github/workflows/electron-pr.yml b/.github/workflows/electron-pr.yml new file mode 100644 index 00000000000..8a5f2a98682 --- /dev/null +++ b/.github/workflows/electron-pr.yml @@ -0,0 +1,43 @@ +name: Electron + +defaults: + run: + shell: bash + +env: + CI: true + +on: + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + build: + strategy: + matrix: + os: + - ubuntu-latest + - windows-latest + - macos-latest + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - if: ${{ startsWith(matrix.os, 'windows') }} + run: pip.exe install setuptools + - if: ${{ ! startsWith(matrix.os, 'windows') }} + run: python3 -m pip install setuptools + - name: Set up environment + uses: ./.github/actions/setup + - name: Build Electron + run: ./bin/package-electron + - name: Upload Build + uses: actions/upload-artifact@v3 + with: + name: actual-electron-${{ matrix.os }} + path: | + packages/desktop-electron/dist/*.dmg + packages/desktop-electron/dist/*.exe + packages/desktop-electron/dist/*.AppImage diff --git a/upcoming-release-notes/2209.md b/upcoming-release-notes/2209.md new file mode 100644 index 00000000000..2f7915f4ff0 --- /dev/null +++ b/upcoming-release-notes/2209.md @@ -0,0 +1,6 @@ +--- +category: Maintenance +authors: [MatissJanis] +--- + +electron: split the build script in 2x parts to fix it failing when no code signing cert is provided (PRs from forks).