Skip to content

Commit

Permalink
fix: Fixed the Select All and Stats Issue on My Expenses V2 Page (#2665)
Browse files Browse the repository at this point in the history
* fixed it

* resolved comments

* increased branch coverage

---------

Co-authored-by: Jay Budhadev <[email protected]>
  • Loading branch information
2 people authored and Jay Budhadev committed Jan 4, 2024
1 parent e6da65b commit ef3a048
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
11 changes: 11 additions & 0 deletions src/app/fyle/my-expenses-v2/my-expenses-v2.page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1912,6 +1912,16 @@ describe('MyExpensesV2Page', () => {
{ id: apiExpenses1[0].id, persist_filters: true },
]);
});

it('should not navigate to any other page, if category is not present', () => {
component.goToTransaction({ expense: { ...apiExpenses1[0], category: null }, expenseIndex: 1 });
expect(router.navigate).toHaveBeenCalledOnceWith([
'/',
'enterprise',
'add_edit_expense',
{ id: apiExpenses1[0].id, persist_filters: true },
]);
});
});

describe('openCriticalPolicyViolationPopOver():', () => {
Expand Down Expand Up @@ -2762,6 +2772,7 @@ describe('MyExpensesV2Page', () => {

it('should update selectedElements, allExpensesCount and call apiV2Service if checked is true', () => {
expensesService.getAllExpenses.and.returnValue(of(cloneDeep(apiExpenses1)));
component.outboxExpensesToBeDeleted = apiExpenseRes;
component.pendingTransactions = cloneDeep([]);
component.onSelectAll(true);
expect(component.isReportableExpensesSelected).toBeTrue();
Expand Down
10 changes: 6 additions & 4 deletions src/app/fyle/my-expenses-v2/my-expenses-v2.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export class MyExpensesV2Page implements OnInit {

expensesToBeDeleted: PlatformExpense[];

outboxExpensesToBeDeleted: Partial<Expense>[];
outboxExpensesToBeDeleted: Partial<Expense>[] = [];

cccExpenses: number;

Expand Down Expand Up @@ -778,7 +778,7 @@ export class MyExpensesV2Page implements OnInit {
this.myExpensesService.generateDateFilterPills(filter, filterPills);
}

if (filter?.type?.length > 0) {
if (filter.type?.length > 0) {
this.myExpensesService.generateTypeFilterPills(filter, filterPills);
}

Expand Down Expand Up @@ -1393,7 +1393,7 @@ export class MyExpensesV2Page implements OnInit {
if (data.status === 'success') {
let totalNoOfSelectedExpenses = 0;
if (offlineExpenses?.length > 0) {
totalNoOfSelectedExpenses = offlineExpenses?.length + this.selectedElements.length;
totalNoOfSelectedExpenses = offlineExpenses.length + this.selectedElements.length;
} else {
totalNoOfSelectedExpenses = this.selectedElements.length;
}
Expand Down Expand Up @@ -1454,7 +1454,9 @@ export class MyExpensesV2Page implements OnInit {
.subscribe((allExpenses) => {
this.selectedElements = this.selectedElements.concat(allExpenses);
if (this.selectedElements.length > 0) {
this.outboxExpensesToBeDeleted = this.transactionService.getDeletableTxns(this.outboxExpensesToBeDeleted);
if (this.outboxExpensesToBeDeleted.length > 0) {
this.outboxExpensesToBeDeleted = this.transactionService.getDeletableTxns(this.outboxExpensesToBeDeleted);
}

this.expensesToBeDeleted = this.sharedExpenseService.excludeCCCExpenses(this.selectedElements);

Expand Down

0 comments on commit ef3a048

Please sign in to comment.