Skip to content
Snippets Groups Projects
Unverified Commit 411a6791 authored by Julian Dominguez-Schatz's avatar Julian Dominguez-Schatz Committed by GitHub
Browse files

Fix transfer category in temporary transactions (#3239)

* Fix transfer category in temporary transactions

* Add visual regression tests to prevent this issue in the future

* Add release notes
parent 6f3af7b6
No related branches found
No related tags found
No related merge requests found
Showing
with 57 additions and 6 deletions
...@@ -31,17 +31,29 @@ export class AccountPage { ...@@ -31,17 +31,29 @@ export class AccountPage {
} }
/** /**
* Create a single transaction * Enter details of a transaction
*/ */
async createSingleTransaction(transaction) { async enterSingleTransaction(transaction) {
await this.addNewTransactionButton.click(); await this.addNewTransactionButton.click();
await this._fillTransactionFields(this.newTransactionRow, transaction); await this._fillTransactionFields(this.newTransactionRow, transaction);
}
/**
* Finish adding a transaction
*/
async addEnteredTransaction() {
await this.addTransactionButton.click(); await this.addTransactionButton.click();
await this.cancelTransactionButton.click(); await this.cancelTransactionButton.click();
} }
/**
* Create a single transaction
*/
async createSingleTransaction(transaction) {
await this.enterSingleTransaction(transaction);
await this.addEnteredTransaction();
}
/** /**
* Create split transactions * Create split transactions
*/ */
...@@ -82,6 +94,15 @@ export class AccountPage { ...@@ -82,6 +94,15 @@ export class AccountPage {
*/ */
getNthTransaction(index) { getNthTransaction(index) {
const row = this.transactionTableRow.nth(index); const row = this.transactionTableRow.nth(index);
return this._getTransactionDetails(row);
}
getEnteredTransaction() {
return this._getTransactionDetails(this.newTransactionRow);
}
_getTransactionDetails(row) {
const account = row.getByTestId('account'); const account = row.getByTestId('account');
return { return {
......
...@@ -141,4 +141,26 @@ test.describe('Transactions', () => { ...@@ -141,4 +141,26 @@ test.describe('Transactions', () => {
await expect(thirdTransaction.credit).toHaveText(''); await expect(thirdTransaction.credit).toHaveText('');
await expect(page).toMatchThemeScreenshots(); await expect(page).toMatchThemeScreenshots();
}); });
test('creates a transfer test transaction', async () => {
await accountPage.enterSingleTransaction({
payee: 'Bank of America',
notes: 'Notes field',
debit: '12.34',
});
let transaction = accountPage.getEnteredTransaction();
await expect(transaction.category.locator('input')).toHaveValue('Transfer');
await expect(page).toMatchThemeScreenshots();
await accountPage.addEnteredTransaction();
transaction = accountPage.getNthTransaction(0);
await expect(transaction.payee).toHaveText('Bank of America');
await expect(transaction.notes).toHaveText('Notes field');
await expect(transaction.category).toHaveText('Transfer');
await expect(transaction.debit).toHaveText('12.34');
await expect(transaction.credit).toHaveText('');
await expect(page).toMatchThemeScreenshots();
});
}); });
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
...@@ -995,7 +995,9 @@ const Transaction = memo(function Transaction({ ...@@ -995,7 +995,9 @@ const Transaction = memo(function Transaction({
const account = accounts && accountId && getAccountsById(accounts)[accountId]; const account = accounts && accountId && getAccountsById(accounts)[accountId];
const isChild = transaction.is_child; const isChild = transaction.is_child;
const transferAcct = transferAccountsByTransaction[id]; const transferAcct = isTemporaryId(id)
? getAccountsById(accounts)[payee?.transfer_acct]
: transferAccountsByTransaction[id];
const isBudgetTransfer = transferAcct && transferAcct.offbudget === 0; const isBudgetTransfer = transferAcct && transferAcct.offbudget === 0;
const isOffBudget = account && account.offbudget === 1; const isOffBudget = account && account.offbudget === 1;
...@@ -1353,7 +1355,7 @@ const Transaction = memo(function Transaction({ ...@@ -1353,7 +1355,7 @@ const Transaction = memo(function Transaction({
</View> </View>
</CellButton> </CellButton>
</Cell> </Cell>
) : isBudgetTransfer || isOffBudget || isPreview ? ( ) : isBudgetTransfer || isOffBudget ? (
<InputCell <InputCell
/* Category field for transfer and off-budget transactions /* Category field for transfer and off-budget transactions
(NOT preview, it is covered first) */ (NOT preview, it is covered first) */
...@@ -1361,7 +1363,7 @@ const Transaction = memo(function Transaction({ ...@@ -1361,7 +1363,7 @@ const Transaction = memo(function Transaction({
width="flex" width="flex"
exposed={focusedField === 'category'} exposed={focusedField === 'category'}
focused={focusedField === 'category'} focused={focusedField === 'category'}
onExpose={name => !isPreview && onEdit(id, name)} onExpose={name => onEdit(id, name)}
value={ value={
isParent isParent
? 'Split' ? 'Split'
......
---
category: Bugfix
authors: [jfdoming]
---
Fix transfer category in temporary transactions
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment