Skip to content

Conversation

@sensei-hacker
Copy link
Member

@sensei-hacker sensei-hacker commented Dec 7, 2025

User description

Addresses bot comments


PR Type

Bug fix, Tests


Description

  • Fix test counter logic in regression tests to properly track passed/failed counts

  • Correct flight axis override test imports and API property references

  • Handle both singular and plural error field names in test assertions

  • Improve magnetometer promise handling and error logging with proper null guards


Diagram Walkthrough

flowchart LR
  A["Test Counter Logic"] -->|Fixed| B["Proper Pass/Fail Tracking"]
  C["Flight Axis Tests"] -->|Added Decompiler Import| D["Correct Decompilation"]
  E["API Property Names"] -->|Fixed isArmed| F["Valid Flight API Usage"]
  G["Error Handling"] -->|Added catch blocks| H["Better Error Logging"]
  I["Magnetometer"] -->|Fixed typos & promises| J["Improved Code Quality"]
Loading

File Walkthrough

Relevant files
Bug fix
test_flight_axis_override.js
Fix decompiler import and flight API property names           

js/transpiler/transpiler/tests/test_flight_axis_override.js

  • Added missing Decompiler import from decompiler.js module
  • Fixed incorrect property reference from flight.armed to flight.isArmed
  • Changed transpiler decompile call to proper new Decompiler()
    instantiation
  • Added fallback error field handling for both error and errors
    properties
+6/-4     
test_override_regressions.js
Fix test counter logic for accurate pass/fail tracking     

js/transpiler/transpiler/tests/test_override_regressions.js

  • Replaced broken passed += runTest() pattern with proper if/else logic
    for all 14 tests
  • Now correctly increments both passed and failed counters based on test
    results
  • Ensures accurate test reporting instead of always showing "Passed: 0,
    Failed: 0"
  • Maintains all existing test assertions and validation logic
+84/-28 
Error handling
magnetometer.js
Improve magnetometer promise handling and error logging   

tabs/magnetometer.js

  • Fixed typo: "settting" → "setting" in three null guard warning
    messages
  • Added explicit return Promise.resolve() in null data guards for proper
    promise chaining
  • Added .catch() error handlers for all three magnetometer alignment
    settings calls
  • Changed console.log to console.warn for null data warnings and added
    console.error for failures
+18/-9   

This commit addresses valid feedback from the PR iNavFlight#2462 bot review.

**Fix #1: Test counter logic (test_override_regressions.js)**
The failed counter was never incremented, causing misleading test reports.
Changed from `passed += runTest(...)` to proper if/else logic that
correctly tracks both passed and failed test counts.

Before: Failed tests showed "Passed: 0, Failed: 0"
After: Correctly shows "Passed: X, Failed: Y"

All 14 tests pass with accurate counting.

**Fix #2: Magnetometer improvements (magnetometer.js)**
- Fixed typo: "settting" → "setting" (3 occurrences)
- Improved promise handling: explicit `return Promise.resolve()` in null guard
- Added error handling: `.catch()` blocks for better error logging
- Changed console.log → console.warn for null data warnings

These changes improve code clarity and error handling without changing
functional behavior.
The test_flight_axis_override.js file had multiple bugs preventing tests
from running correctly:

**Fix #1: Missing Decompiler import**
- Added `import { Decompiler } from '../decompiler.js';`
- Changed `transpiler.decompile()` to proper `new Decompiler()` usage
- Error was: "transpiler.decompile is not a function"

**Fix #2: Invalid property name in Test 4**
- Fixed `flight.armed` → `flight.isArmed`
- Error was: "Unknown property 'armed' in 'flight.armed'"
- The correct property is `isArmed` per the flight API

**Fix #3: Error message handling**
- Fixed `result.errors` → `result.error || result.errors`
- Fixed `decompiled.errors` → `decompiled.error || decompiled.errors`
- Handles both singular and plural error field names

**Test Results:**
Before: 3 decompile errors, 1 compilation failure
After: All 4 tests pass ✅

- Test 1: Roll angle override ✅
- Test 2: Pitch rate override ✅
- Test 3: Yaw angle override ✅
- Test 4: Multiple axis overrides ✅
@github-actions
Copy link

github-actions bot commented Dec 7, 2025

Branch Targeting Suggestion

You've targeted the master branch with this PR. Please consider if a version branch might be more appropriate:

  • maintenance-9.x - If your change is backward-compatible and won't create compatibility issues between INAV firmware and Configurator 9.x versions. This will allow your PR to be included in the next 9.x release.

  • maintenance-10.x - If your change introduces compatibility requirements between firmware and configurator that would break 9.x compatibility. This is for PRs which will be included in INAV 10.x

If master is the correct target for this change, no action is needed.


This is an automated suggestion to help route contributions to the appropriate branch.

@qodo-code-review
Copy link
Contributor

PR Compliance Guide 🔍

All compliance sections have been disabled in the configurations.

@sensei-hacker sensei-hacker merged commit 5406389 into iNavFlight:master Dec 12, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant