Skip to content

Commit

Permalink
Merge branch 'master' into crossorigin
Browse files Browse the repository at this point in the history
  • Loading branch information
MatissJanis authored Jan 9, 2024
2 parents 4244564 + ef9a7cf commit 7bf9517
Show file tree
Hide file tree
Showing 7 changed files with 178 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/electron-pr.yml
Original file line number Diff line number Diff line change
@@ -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
113 changes: 113 additions & 0 deletions packages/api/methods.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}),
]);
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/2168.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Maintenance
authors: [twk3]
---

Add api tests for payees and transactions
6 changes: 6 additions & 0 deletions upcoming-release-notes/2181.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Maintenance
authors: [MatissJanis]
---

migration: rename `nordigen_*` secrets to `gocardless_*`
6 changes: 6 additions & 0 deletions upcoming-release-notes/2209.md
Original file line number Diff line number Diff line change
@@ -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).

0 comments on commit 7bf9517

Please sign in to comment.