Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add calculated values for mileage distance and amount #3381

Merged
merged 5 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/app/core/mock-data/transaction.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2628,6 +2628,8 @@ export const transformedExpensePayload: Partial<Expense> = deepFreezeStrict({
commute_details_id: undefined,
hotel_is_breakfast_provided: null,
file_ids: undefined,
mileage_calculated_distance: null,
mileage_calculated_amount: null,
Comment on lines +2631 to +2632
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Mind it! The test coverage for these mileage properties needs attention, macha!

Looking at the codebase, I can see that while there are extensive test files for mileage functionality, the new mileage_calculated_distance and mileage_calculated_amount properties are not properly covered in the test scenarios. Here's what needs to be done:

  • Add test cases in src/app/fyle/add-edit-mileage/add-edit-mileage-*.spec.ts files to verify these calculated properties
  • Ensure both null and non-null scenarios are covered
  • Include validation for these properties in the form generation tests
🔗 Analysis chain

Aiyoo, superb addition to store mileage details, but don't forget the test coverage, macha!

These fresh properties look ready to roar, but ensure you’ve got test scenarios to confirm they flex their muscles properly under all conditions.


Let me verify the test coverage for these mileage properties with style!

These commands will help us understand:

  1. What transaction-related test files exist
  2. If there are any existing mileage calculation tests
  3. How the transaction mock data is being used in tests

Let me analyze the results and give you a stylish verdict, mind it!


Let me check the mileage test files more deeply, mind it!

These commands will show us if the new properties are already covered in the test cases or if we need to add new ones. Let the power of testing flow through our code!


Let me check one final thing about the mileage test cases, mind it!

This command will show us the actual test implementations for mileage expenses. Let's see if they're testing these calculated properties properly!

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Let's search for test files related to transactions and mileage
fd -e spec.ts -e test.ts | grep -i "transaction"

# Let's also check for any existing tests with mileage calculations
rg -i "mileage.*calculated" --type ts -g "*spec.ts" -g "*test.ts"

# Search for transaction test data usage
rg "transaction.data" --type ts -g "*spec.ts" -g "*test.ts"

Length of output: 2673


Script:

#!/bin/bash
# Let's check the mileage test content, style-ah!
rg -A 10 "mileage_calculated" src/app/fyle/add-edit-mileage/add-edit-mileage-*.spec.ts

# Check the transaction mock data for mileage tests
cat src/app/core/mock-data/transaction.data.ts | grep -A 10 -B 10 "mileage_calculated"

Length of output: 23574


Script:

#!/bin/bash
# Let's check the actual test implementations for mileage, thalaiva style!
rg -l "mileage" src/app/fyle/add-edit-mileage/add-edit-mileage-*.spec.ts | xargs cat

Length of output: 106268

});

export const splitExpenseTxn2: Transaction = deepFreeze({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ export class ExpensesService {
file_ids: transaction.file_ids,
report_id: transaction.report_id,
travel_classes: [],
mileage_calculated_distance: transaction.mileage_calculated_distance,
mileage_calculated_amount: transaction.mileage_calculated_amount,
};

if (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CurrencyPipe } from '@angular/common';
import { CUSTOM_ELEMENTS_SCHEMA, EventEmitter } from '@angular/core';
import { ComponentFixture, TestBed, fakeAsync, tick, waitForAsync } from '@angular/core/testing';
import { ComponentFixture, TestBed, fakeAsync, flush, tick, waitForAsync } from '@angular/core/testing';
import { FormsModule } from '@angular/forms';
import { MatSnackBar } from '@angular/material/snack-bar';
import { By } from '@angular/platform-browser';
Expand Down Expand Up @@ -588,7 +588,6 @@ describe('ViewTeamReportPageV2', () => {
component.report$ = of(reportWithExpenses);
component.expenses$ = of(expenseResponseData);
launchDarklyService.getVariation.and.returnValue(of(true));
fixture.detectChanges();

component.approveReport();
tick(1000);
Expand Down Expand Up @@ -653,7 +652,6 @@ describe('ViewTeamReportPageV2', () => {

component.report$ = of(reportWithExpenses);
component.expenses$ = of(expenseResponseData);
fixture.detectChanges();

component.approveReport();
tick();
Expand All @@ -679,7 +677,6 @@ describe('ViewTeamReportPageV2', () => {

component.report$ = of(reportWithExpenses);
component.expenses$ = of(expenseResponseData);
fixture.detectChanges();

component.approveReport();
tick();
Expand All @@ -704,7 +701,6 @@ describe('ViewTeamReportPageV2', () => {

component.report$ = of(reportWithExpenses);
component.expenses$ = of(expenseResponseData);
fixture.detectChanges();

component.approveReport();
tick();
Expand Down
Loading