Skip to content
Snippets Groups Projects
Unverified Commit 53df1a03 authored by Jed Fox's avatar Jed Fox Committed by GitHub
Browse files

Fix navigating to the per-category per-month page (#1182)

I checked through the other references to `navigate` and none of them
appeared to be affected.
parent 0f81d877
No related branches found
No related tags found
No related merge requests found
...@@ -50,4 +50,14 @@ test.describe('Budget', () => { ...@@ -50,4 +50,14 @@ test.describe('Budget', () => {
balance: expect.any(Number), balance: expect.any(Number),
}); });
}); });
test('clicking on spent amounts opens a transaction page', async () => {
let categoryName = await budgetPage.getCategoryNameForRow(1);
let accountPage = await budgetPage.clickOnSpentAmountForRow(1);
expect(page.url()).toContain('/accounts');
expect(await accountPage.accountName.textContent()).toMatch(
new RegExp(String.raw`${categoryName} \(\w+ \d+\)`),
);
await page.getByRole('button', { name: 'Back' }).click();
});
}); });
import { AccountPage } from './account-page';
export class BudgetPage { export class BudgetPage {
constructor(page) { constructor(page) {
this.page = page; this.page = page;
...@@ -46,12 +48,25 @@ export class BudgetPage { ...@@ -46,12 +48,25 @@ export class BudgetPage {
); );
} }
async transferAllBalance(fromIdx, toIdx) { async getCategoryNameForRow(idx) {
const toName = await this.budgetTable return this.budgetTable
.getByTestId('row') .getByTestId('row')
.nth(toIdx) .nth(idx)
.getByTestId('category-name') .getByTestId('category-name')
.textContent(); .textContent();
}
async clickOnSpentAmountForRow(idx) {
await this.budgetTable
.getByTestId('row')
.nth(idx)
.getByTestId('category-month-spent')
.click();
return new AccountPage(this.page);
}
async transferAllBalance(fromIdx, toIdx) {
const toName = await this.getCategoryNameForRow(toIdx);
await this.budgetTable await this.budgetTable
.getByTestId('row') .getByTestId('row')
......
...@@ -332,8 +332,7 @@ class Budget extends PureComponent { ...@@ -332,8 +332,7 @@ class Budget extends PureComponent {
}; };
onShowActivity = (categoryName, categoryId, month) => { onShowActivity = (categoryName, categoryId, month) => {
this.props.navigate({ this.props.navigate('/accounts', {
pathname: '/accounts',
state: { state: {
goBack: true, goBack: true,
filterName: `${categoryName} (${monthUtils.format( filterName: `${categoryName} (${monthUtils.format(
......
...@@ -246,6 +246,7 @@ export const CategoryMonth = memo(function CategoryMonth({ ...@@ -246,6 +246,7 @@ export const CategoryMonth = memo(function CategoryMonth({
style={{ textAlign: 'right' }} style={{ textAlign: 'right' }}
> >
<span <span
data-testid="category-month-spent"
onClick={() => onShowActivity(category.name, category.id, monthIndex)} onClick={() => onShowActivity(category.name, category.id, monthIndex)}
> >
<CellValue <CellValue
......
...@@ -371,6 +371,7 @@ export const ExpenseCategoryMonth = memo(function ExpenseCategoryMonth({ ...@@ -371,6 +371,7 @@ export const ExpenseCategoryMonth = memo(function ExpenseCategoryMonth({
style={{ textAlign: 'right' }} style={{ textAlign: 'right' }}
> >
<span <span
data-testid="category-month-spent"
onClick={() => onShowActivity(category.name, category.id, monthIndex)} onClick={() => onShowActivity(category.name, category.id, monthIndex)}
> >
<CellValue <CellValue
......
---
category: Bugfix
authors: [j-f1]
---
Fix navigating to the per-category per-month page
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