Skip to content

Commit

Permalink
Merge branch 'master' into toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
carkom authored Jan 11, 2024
2 parents 46adddf + 3eee0b1 commit ddebe3f
Show file tree
Hide file tree
Showing 75 changed files with 1,061 additions and 752 deletions.
20 changes: 20 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,26 @@ module.exports = {
],
},
},
{
files: ['./packages/desktop-client/**/*'],
excludedFiles: [
'./packages/desktop-client/src/hooks/useNavigate.{ts,tsx}',
],
rules: {
'no-restricted-imports': [
'warn',
{
patterns: [
{
group: ['react-router-dom'],
importNames: ['useNavigate'],
message: 'Please use Actual’s useNavigate() hook instead.',
},
],
},
],
},
},
{
files: ['./packages/loot-core/src/**/*'],
rules: {
Expand Down
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ yarn.lock text eol=lf

# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
*.jpg binary
35 changes: 0 additions & 35 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,38 +66,3 @@ jobs:
name: desktop-client-test-results
path: packages/desktop-client/test-results/
retention-days: 30
- uses: actions-ecosystem/action-add-labels@v1
if: failure()
with:
labels: ':red_circle: VRT failing'
- uses: actions-ecosystem/action-remove-labels@v1
if: success()
with:
labels: ':red_circle: VRT failing'
- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: VRT
- name: Create comment if failed
if: failure()
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
:wave: Looks like VRT (visual regression tests) are failing in this PR. This indicates a problem in the app. It could be either a bug in this PR or a visual change introduced by changing something.
To fix this: please follow [these instructions](https://github.com/actualbudget/actual/blob/master/packages/desktop-client/README.md#visual-regression) and review the output of the failing CI job to see the generated screenshots.
We look forward to reviewing this PR once all the CI jobs have passed successfully!
edit-mode: replace
- name: Update comment when CI job passes
if: success() && steps.fc.outputs.comment-id != ''
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
body: The VRT tests have passed! Thank you!
edit-mode: replace
50 changes: 50 additions & 0 deletions .github/workflows/electron-master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Electron

defaults:
run:
shell: bash

env:
CI: true

on:
push:
branches:
- master

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

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
env:
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
CSC_LINK: ${{ secrets.CSC_LINK }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
- 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
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ env:
CI: true

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.event.pull_request.number }}
cancel-in-progress: true

jobs:
build:
Expand Down
2 changes: 2 additions & 0 deletions .secret-tokens.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export [email protected]
export APPLE_APP_SPECIFIC_PASSWORD=password
7 changes: 2 additions & 5 deletions bin/package-electron
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

ROOT=`dirname $0`
RELEASE=""
RELEASE_NOTES="" # TODO: figure out automation for release notes when we start publishing electron versions
CI=${CI:-false}

cd "$ROOT/.."
Expand Down Expand Up @@ -47,15 +46,13 @@ yarn workspace desktop-electron update-client
cd packages/desktop-electron;
yarn clean;

export npm_config_better_sqlite3_binary_host="https://static.actualbudget.com/prebuild/better-sqlite3"

if [ "$RELEASE" == "production" ]; then
if [ -f ../../.secret-tokens ]; then
source ../../.secret-tokens
fi
yarn build --publish always -c.releaseInfo.releaseNotes="$RELEASE_NOTES" --arm64 --x64
yarn build --publish never --arm64 --x64

echo "\nCreated release with release notes \"$RELEASE_NOTES\""
echo "\nCreated release"
else
SKIP_NOTARIZATION=true yarn build --publish never --x64
fi
Expand Down
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);
});
});
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"test": "yarn run build:app && jest -c jest.config.js"
},
"dependencies": {
"better-sqlite3": "^9.1.1",
"better-sqlite3": "^9.2.2",
"compare-versions": "^6.1.0",
"node-fetch": "^3.3.2",
"uuid": "^9.0.0"
Expand Down
7 changes: 4 additions & 3 deletions packages/desktop-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ First start the dev server:
```sh
HTTPS=true yarn start
```

Next, navigate to the root of your project folder, run the standartised docker container, and launch the visual regression tests from within it.

```sh
# Run docker container
docker run --rm --network host -v $(pwd):/work/ -w /work/ -it mcr.microsoft.com/playwright:v1.37.0-jammy /bin/bash
docker run --rm --network host -v $(pwd):/work/ -w /work/ -it mcr.microsoft.com/playwright:v1.37.1-jammy /bin/bash

# If you recieve an error such as "docker: invalid reference format", please instead use the following command:
docker run --rm --network host -v ${pwd}:/work/ -w /work/ -it mcr.microsoft.com/playwright:v1.37.0-jammy /bin/bash
# If you receive an error such as "docker: invalid reference format", please instead use the following command:
docker run --rm --network host -v ${pwd}:/work/ -w /work/ -it mcr.microsoft.com/playwright:v1.37.1-jammy /bin/bash

# Run the VRT tests: important - they MUST be ran against a HTTPS server
E2E_START_URL=https://192.168.0.178:3001 yarn vrt
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/desktop-client/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
sizes="16x16"
href="%PUBLIC_URL%/favicon-16x16.png"
/>
<link rel="manifest" href="%PUBLIC_URL%/site.webmanifest" />
<link rel="manifest" href="%PUBLIC_URL%/site.webmanifest" crossorigin="use-credentials"/>
<meta name="msapplication-TileColor" content="#da532c" />
<meta name="theme-color" content="#ffffff" />

Expand Down
7 changes: 4 additions & 3 deletions packages/desktop-client/public/site.webmanifest
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "",
"short_name": "",
"name": "Actual",
"short_name": "Actual",
"icons": [
{
"src": "/android-chrome-192x192.png",
Expand All @@ -15,5 +15,6 @@
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
"display": "standalone",
"start_url": "."
}
1 change: 1 addition & 0 deletions packages/desktop-client/src/browser-preload.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ global.Actual = {
applyAppUpdate: () => {},
updateAppMenu: isBudgetOpen => {},

ipcConnect: () => {},
getServerSocket: async () => {
return worker;
},
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop-client/src/components/FinancesApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
Route,
Routes,
Navigate,
useNavigate,
BrowserRouter,
useLocation,
useHref,
Expand All @@ -20,6 +19,7 @@ import { checkForUpdateNotification } from 'loot-core/src/client/update-notifica
import * as undo from 'loot-core/src/platform/client/undo';

import { useActions } from '../hooks/useActions';
import { useNavigate } from '../hooks/useNavigate';
import { useResponsive } from '../ResponsiveProvider';
import { theme } from '../style';
import { ExposeNavigate } from '../util/router-tools';
Expand Down
Loading

0 comments on commit ddebe3f

Please sign in to comment.