-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into sortable_cleared
- Loading branch information
Showing
430 changed files
with
5,978 additions
and
5,337 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ app/bundle.api.js* | |
app/stats.json | ||
migrations | ||
default-db.sqlite | ||
mocks/budgets/**/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`API setup and teardown successfully loads budget 1`] = ` | ||
Array [ | ||
"2016-10", | ||
"2016-11", | ||
"2016-12", | ||
"2017-01", | ||
"2017-02", | ||
"2017-03", | ||
"2017-04", | ||
"2017-05", | ||
"2017-06", | ||
"2017-07", | ||
"2017-08", | ||
"2017-09", | ||
"2017-10", | ||
"2017-11", | ||
"2017-12", | ||
] | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module.exports = { | ||
moduleFileExtensions: [ | ||
'testing.js', | ||
'testing.ts', | ||
'api.js', | ||
'api.ts', | ||
'api.tsx', | ||
'electron.js', | ||
'electron.ts', | ||
'mjs', | ||
'js', | ||
'ts', | ||
'tsx', | ||
'json', | ||
], | ||
testEnvironment: 'node', | ||
testPathIgnorePatterns: ['/node_modules/'], | ||
watchPathIgnorePatterns: ['<rootDir>/mocks/budgets/'], | ||
setupFilesAfterEnv: ['<rootDir>/../loot-core/src/mocks/setup.ts'], | ||
transformIgnorePatterns: ['/node_modules/'], | ||
transform: { | ||
'^.+\\.(t|j)sx?$': '@swc/jest', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,250 @@ | ||
import * as fs from 'fs/promises'; | ||
import * as path from 'path'; | ||
|
||
import * as api from './index'; | ||
|
||
const budgetName = 'test-budget'; | ||
|
||
beforeEach(async () => { | ||
// we need real datetime if we are going to mix new timestamps with our mock data | ||
global.restoreDateNow(); | ||
|
||
const budgetPath = path.join(__dirname, '/mocks/budgets/', budgetName); | ||
await fs.rm(budgetPath, { force: true, recursive: true }); | ||
|
||
await createTestBudget('default-budget-template', budgetName); | ||
await api.init({ | ||
dataDir: path.join(__dirname, '/mocks/budgets/'), | ||
}); | ||
}); | ||
|
||
afterEach(async () => { | ||
global.currentMonth = null; | ||
await api.shutdown(); | ||
}); | ||
|
||
async function createTestBudget(templateName: string, name: string) { | ||
const templatePath = path.join( | ||
__dirname, | ||
'/../loot-core/src/mocks/files', | ||
templateName, | ||
); | ||
const budgetPath = path.join(__dirname, '/mocks/budgets/', name); | ||
|
||
await fs.mkdir(budgetPath); | ||
await fs.copyFile( | ||
path.join(templatePath, 'metadata.json'), | ||
path.join(budgetPath, 'metadata.json'), | ||
); | ||
await fs.copyFile( | ||
path.join(templatePath, 'db.sqlite'), | ||
path.join(budgetPath, 'db.sqlite'), | ||
); | ||
} | ||
|
||
describe('API setup and teardown', () => { | ||
// apis: loadBudget, getBudgetMonths | ||
test('successfully loads budget', async () => { | ||
await expect(api.loadBudget(budgetName)).resolves.toBeUndefined(); | ||
|
||
await expect(api.getBudgetMonths()).resolves.toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
describe('API CRUD operations', () => { | ||
beforeEach(async () => { | ||
// load test budget | ||
await api.loadBudget(budgetName); | ||
}); | ||
|
||
// apis: createCategoryGroup, updateCategoryGroup, deleteCategoryGroup | ||
test('CategoryGroups: successfully update category groups', async () => { | ||
const month = '2023-10'; | ||
global.currentMonth = month; | ||
|
||
// create our test category group | ||
const mainGroupId = await api.createCategoryGroup({ | ||
name: 'test-group', | ||
}); | ||
|
||
let budgetMonth = await api.getBudgetMonth(month); | ||
expect(budgetMonth.categoryGroups).toEqual( | ||
expect.arrayContaining([ | ||
expect.objectContaining({ | ||
id: mainGroupId, | ||
}), | ||
]), | ||
); | ||
|
||
// update group | ||
await api.updateCategoryGroup(mainGroupId, { | ||
name: 'update-tests', | ||
}); | ||
|
||
budgetMonth = await api.getBudgetMonth(month); | ||
expect(budgetMonth.categoryGroups).toEqual( | ||
expect.arrayContaining([ | ||
expect.objectContaining({ | ||
id: mainGroupId, | ||
}), | ||
]), | ||
); | ||
|
||
// delete group | ||
await api.deleteCategoryGroup(mainGroupId); | ||
|
||
budgetMonth = await api.getBudgetMonth(month); | ||
expect(budgetMonth.categoryGroups).toEqual( | ||
expect.arrayContaining([ | ||
expect.not.objectContaining({ | ||
id: mainGroupId, | ||
}), | ||
]), | ||
); | ||
}); | ||
|
||
// apis: createCategory, getCategories, updateCategory, deleteCategory | ||
test('Categories: successfully update categories', async () => { | ||
const month = '2023-10'; | ||
global.currentMonth = month; | ||
|
||
// create our test category group | ||
const mainGroupId = await api.createCategoryGroup({ | ||
name: 'test-group', | ||
}); | ||
const secondaryGroupId = await api.createCategoryGroup({ | ||
name: 'test-secondary-group', | ||
}); | ||
const categoryId = await api.createCategory({ | ||
name: 'test-budget', | ||
group_id: mainGroupId, | ||
}); | ||
|
||
let categories = await api.getCategories(); | ||
expect(categories).toEqual( | ||
expect.arrayContaining([ | ||
expect.objectContaining({ | ||
id: categoryId, | ||
name: 'test-budget', | ||
group_id: mainGroupId, | ||
}), | ||
]), | ||
); | ||
|
||
// update/move category | ||
await api.updateCategory(categoryId, { | ||
name: 'updated-budget', | ||
group_id: secondaryGroupId, | ||
}); | ||
|
||
categories = await api.getCategories(); | ||
expect(categories).toEqual( | ||
expect.arrayContaining([ | ||
expect.objectContaining({ | ||
id: categoryId, | ||
name: 'updated-budget', | ||
group_id: secondaryGroupId, | ||
}), | ||
]), | ||
); | ||
|
||
// delete categories | ||
await api.deleteCategory(categoryId); | ||
|
||
expect(categories).toEqual( | ||
expect.arrayContaining([ | ||
expect.not.objectContaining({ | ||
id: categoryId, | ||
}), | ||
]), | ||
); | ||
}); | ||
|
||
// apis: setBudgetAmount, setBudgetCarryover, getBudgetMonth | ||
test('Budgets: successfully update budgets', async () => { | ||
const month = '2023-10'; | ||
global.currentMonth = month; | ||
|
||
// create some new categories to test with | ||
const groupId = await api.createCategoryGroup({ | ||
name: 'tests', | ||
}); | ||
const categoryId = await api.createCategory({ | ||
name: 'test-budget', | ||
group_id: groupId, | ||
}); | ||
|
||
await api.setBudgetAmount(month, categoryId, 100); | ||
await api.setBudgetCarryover(month, categoryId, true); | ||
|
||
const budgetMonth = await api.getBudgetMonth(month); | ||
expect(budgetMonth.categoryGroups).toEqual( | ||
expect.arrayContaining([ | ||
expect.objectContaining({ | ||
id: groupId, | ||
categories: expect.arrayContaining([ | ||
expect.objectContaining({ | ||
id: categoryId, | ||
budgeted: 100, | ||
carryover: true, | ||
}), | ||
]), | ||
}), | ||
]), | ||
); | ||
}); | ||
|
||
//apis: createAccount, getAccounts, updateAccount, closeAccount, deleteAccount, reopenAccount | ||
test('Accounts: successfully complete account operators', async () => { | ||
const accountId1 = await api.createAccount( | ||
{ name: 'test-account1', offbudget: true }, | ||
1000, | ||
); | ||
const accountId2 = await api.createAccount({ name: 'test-account2' }, 0); | ||
let accounts = await api.getAccounts(); | ||
|
||
// accounts successfully created | ||
expect(accounts).toEqual( | ||
expect.arrayContaining([ | ||
expect.objectContaining({ | ||
id: accountId1, | ||
name: 'test-account1', | ||
offbudget: true, | ||
}), | ||
expect.objectContaining({ id: accountId2, name: 'test-account2' }), | ||
]), | ||
); | ||
|
||
await api.updateAccount(accountId1, { offbudget: false }); | ||
await api.closeAccount(accountId1, accountId2, null); | ||
await api.deleteAccount(accountId2); | ||
|
||
// accounts successfully updated, and one of them deleted | ||
accounts = await api.getAccounts(); | ||
expect(accounts).toEqual( | ||
expect.arrayContaining([ | ||
expect.objectContaining({ | ||
id: accountId1, | ||
name: 'test-account1', | ||
closed: true, | ||
offbudget: false, | ||
}), | ||
expect.not.objectContaining({ id: accountId2 }), | ||
]), | ||
); | ||
|
||
await api.reopenAccount(accountId1); | ||
|
||
// the non-deleted account is reopened | ||
accounts = await api.getAccounts(); | ||
expect(accounts).toEqual( | ||
expect.arrayContaining([ | ||
expect.objectContaining({ | ||
id: accountId1, | ||
name: 'test-account1', | ||
closed: false, | ||
}), | ||
]), | ||
); | ||
}); | ||
}); |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
-47 Bytes
(100%)
...s-snapshots/Mobile-checks-that-settings-page-can-be-opened-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-67 Bytes
(100%)
...s-snapshots/Mobile-checks-that-settings-page-can-be-opened-2-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-44 Bytes
(100%)
...s-snapshots/Mobile-checks-that-settings-page-can-be-opened-3-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-64 Bytes
(100%)
...s-snapshots/Mobile-checks-that-settings-page-can-be-opened-4-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+551 Bytes
(100%)
...apshots/Mobile-creates-a-transaction-from-accounts-id-page-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+646 Bytes
(100%)
...apshots/Mobile-creates-a-transaction-from-accounts-id-page-2-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+586 Bytes
(100%)
...s-snapshots/Mobile-creates-a-transaction-via-footer-button-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+705 Bytes
(100%)
...s-snapshots/Mobile-creates-a-transaction-via-footer-button-2-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+109 Bytes
(100%)
...s-snapshots/Mobile-creates-a-transaction-via-footer-button-3-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+157 Bytes
(100%)
...s-snapshots/Mobile-creates-a-transaction-via-footer-button-4-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+297 Bytes
(100%)
...s-snapshots/Mobile-creates-a-transaction-via-footer-button-5-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+322 Bytes
(100%)
...s-snapshots/Mobile-creates-a-transaction-via-footer-button-6-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1 Byte
(100%)
...apshots/Mobile-loads-the-budget-page-with-budgeted-amounts-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+2 Bytes
(100%)
...apshots/Mobile-loads-the-budget-page-with-budgeted-amounts-2-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+867 Bytes
(100%)
...dividual-account-page-and-checks-that-filtering-is-working-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+910 Bytes
(100%)
...dividual-account-page-and-checks-that-filtering-is-working-2-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+900 Bytes
(110%)
...dividual-account-page-and-checks-that-filtering-is-working-3-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+960 Bytes
(110%)
...dividual-account-page-and-checks-that-filtering-is-working-4-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+886 Bytes
(100%)
...dividual-account-page-and-checks-that-filtering-is-working-5-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+928 Bytes
(100%)
...dividual-account-page-and-checks-that-filtering-is-working-6-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+89 Bytes
(100%)
...ots/Mobile-opens-the-accounts-page-and-asserts-on-balances-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+19 Bytes
(100%)
...ots/Mobile-opens-the-accounts-page-and-asserts-on-balances-2-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-3 Bytes
(100%)
...ettings.test.js-snapshots/Settings-checks-the-page-visuals-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-2 Bytes
(100%)
...ettings.test.js-snapshots/Settings-checks-the-page-visuals-2-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.