Add missing tests: Label_SQ and Label_20_POS#275
Conversation
Co-Authored-By: Kevin Elliott <kevin@welikeinc.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Bug Report
Comments? Email us. |
WalkthroughAdds two new unit test files for plugins Label_20_POS and Label_SQ that exercise decoding across multiple input variants, asserting decode results, decodeLevel, raw fields, and formatted items. No production code or public API changes. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~7 minutes Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (8)
lib/plugins/Label_20_POS.test.ts (4)
8-10: Pass a fully shaped Message object to satisfy typing and future-proof testsCalling plugin.decode with only { text } relies on Message having text as the only required property. To avoid brittle tests if Message tightens in the future and to better mirror real pipeline input, include label: '20'.
- const decode = (text: string) => { - return plugin.decode({ text }); - }; + const decode = (text: string) => { + return plugin.decode({ label: '20', text }); + };
16-20: Also assert decoder identity for stronger verificationVerifying the decoder name guards against accidental routing to the wrong plugin if multiple handlers ever overlap.
expect(res.decoded).toBe(true); expect(res.decoder.decodeLevel).toBe('full'); + expect(res.decoder.name).toBe('label-20-pos'); expect(res.formatted.description).toBe('Position Report'); expect(res.raw.preamble).toBe('POS');
22-29: Validate preamble in the 5-field variation as wellThis mirrors the 11-field test and ensures the plugin consistently sets the preamble.
expect(res.decoded).toBe(true); expect(res.decoder.decodeLevel).toBe('full'); expect(res.formatted.description).toBe('Position Report'); + expect(res.raw.preamble).toBe('POS');
31-38: Optional: Add an integration test via MessageDecoder for end-to-end behaviorSince MessageDecoder filters by plugin qualifiers (labels/preambles), a small integration check would validate routing beyond direct plugin calls. Not required, but useful for regression safety.
I can draft an additional test using decoder.decode({ label: '20', text }) if you’d like.
lib/plugins/Label_SQ.test.ts (4)
8-10: Pass a fully shaped Message object to satisfy typing and future-proof testsInclude label: 'SQ' to align with the Message shape and real decoding flow.
- const decode = (text: string) => { - return plugin.decode({ text }); - }; + const decode = (text: string) => { + return plugin.decode({ label: 'SQ', text }); + };
12-41: Add assertion for formatted descriptionThis ensures human-readable formatting remains stable.
expect(res.decoder.decodeLevel).toBe('full'); + expect(res.formatted.description).toBe('Ground Station Squitter'); expect(res.raw.preamble).toBe(text.substring(0, 4)); expect(res.raw.version).toBe('2'); expect(res.raw.network).toBe('A');
43-57: Also assert decoder identity/decodeLevel for the SITA/no-match caseEven without a regex match, the plugin intentionally sets decoded=true and decodeLevel='full'. Asserting these protects behavior from future changes.
const res = decode(text); expect(res.decoded).toBe(true); + expect(res.decoder.name).toBe('label-sq'); + expect(res.decoder.decodeLevel).toBe('full'); expect(res.raw.version).toBe('2'); expect(res.raw.network).toBe('S');
59-70: Optionally assert description for non-v2 payloadsKeeps formatted output expectations uniform across versions.
const res = decode(text); expect(res.decoded).toBe(true); + expect(res.formatted.description).toBe('Ground Station Squitter'); expect(res.raw.version).toBe('1'); expect(res.raw.network).toBe('A');
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
lib/plugins/Label_20_POS.test.ts(1 hunks)lib/plugins/Label_SQ.test.ts(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
lib/plugins/Label_20_POS.test.ts (2)
lib/MessageDecoder.ts (1)
MessageDecoder(6-175)lib/plugins/Label_20_POS.ts (1)
Label_20_POS(7-61)
lib/plugins/Label_SQ.test.ts (2)
lib/MessageDecoder.ts (1)
MessageDecoder(6-175)lib/plugins/Label_SQ.ts (1)
Label_SQ(4-118)
🔇 Additional comments (1)
lib/plugins/Label_SQ.test.ts (1)
12-41: LGTM on core decoding assertionsGood coverage of version/network parsing, ground station extraction, coordinates, frequency, and formatted items.
…ted POS item Co-Authored-By: Kevin Elliott <kevin@welikeinc.com>
Bug Report
Comments? Email us. |
Add Missing Tests
Summary
This PR adds comprehensive test coverage to previously untested or low-coverage sections across three Airframes repositories:
Label_SQ(13.33% → 90.83% coverage) andLabel_20_POS(31.74% → 82.53% coverage) pluginsThe tests focus on core parsing logic, validation edge cases, and error handling scenarios that were previously untested.
Review & Testing Checklist for Human
Diagram
%%{ init : { "theme" : "default" }}%% graph TB subgraph "acars-decoder-typescript" LabelSQ["lib/plugins/Label_SQ.ts"]:::context LabelSQTest["lib/plugins/Label_SQ.test.ts"]:::major-edit Label20POS["lib/plugins/Label_20_POS.ts"]:::context Label20POSTest["lib/plugins/Label_20_POS.test.ts"]:::major-edit MessageDecoder["lib/MessageDecoder.ts"]:::context end LabelSQTest -->|"tests decode logic"| LabelSQ Label20POSTest -->|"tests position parsing"| Label20POS TestMain -->|"mocks dependencies"| AppMain subgraph Legend L1[Major Edit]:::major-edit L2[Minor Edit]:::minor-edit L3[Context/No Edit]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
Session requested by: Kevin Elliott (@kevinelliott)
Devin session: https://app.devin.ai/sessions/144ecd3792924403b4cd3c823b89d108
Summary by CodeRabbit