-
Notifications
You must be signed in to change notification settings - Fork 1
feat: verification flight quality gate #430
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
src/renderer/components/TuningHistory/VerificationQualityWarning.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| import { describe, it, expect, vi } from 'vitest'; | ||
| import { render, screen } from '@testing-library/react'; | ||
| import userEvent from '@testing-library/user-event'; | ||
| import { VerificationQualityWarning } from './VerificationQualityWarning'; | ||
| import type { DataQualityScore } from '@shared/types/analysis.types'; | ||
|
|
||
| const fairQuality: DataQualityScore = { | ||
| overall: 46, | ||
| tier: 'fair', | ||
| subScores: [ | ||
| { name: 'Step count', score: 20, weight: 0.3 }, | ||
| { name: 'Axis coverage', score: 0, weight: 0.3 }, | ||
| { name: 'Magnitude variety', score: 100, weight: 0.2 }, | ||
| { name: 'Hold quality', score: 100, weight: 0.2 }, | ||
| ], | ||
| }; | ||
|
|
||
| const poorQuality: DataQualityScore = { | ||
| overall: 15, | ||
| tier: 'poor', | ||
| subScores: [ | ||
| { name: 'Step count', score: 0, weight: 0.3 }, | ||
| { name: 'Axis coverage', score: 0, weight: 0.3 }, | ||
| { name: 'Magnitude variety', score: 50, weight: 0.2 }, | ||
| { name: 'Hold quality', score: 25, weight: 0.2 }, | ||
| ], | ||
| }; | ||
|
|
||
| describe('VerificationQualityWarning', () => { | ||
| it('renders fair quality warning with score', () => { | ||
| render( | ||
| <VerificationQualityWarning dataQuality={fairQuality} onAccept={vi.fn()} onReject={vi.fn()} /> | ||
| ); | ||
| expect(screen.getByText(/Fair \(46\/100\)/)).toBeInTheDocument(); | ||
| expect(screen.getByText('Low Verification Data Quality')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders poor quality warning', () => { | ||
| render( | ||
| <VerificationQualityWarning dataQuality={poorQuality} onAccept={vi.fn()} onReject={vi.fn()} /> | ||
| ); | ||
| expect(screen.getByText(/Poor \(15\/100\)/)).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('shows failing sub-scores', () => { | ||
| render( | ||
| <VerificationQualityWarning dataQuality={fairQuality} onAccept={vi.fn()} onReject={vi.fn()} /> | ||
| ); | ||
| expect(screen.getByText('Step count: 20/100')).toBeInTheDocument(); | ||
| expect(screen.getByText('Axis coverage: 0/100')).toBeInTheDocument(); | ||
| // Good sub-scores should not be shown | ||
| expect(screen.queryByText(/Magnitude variety/)).not.toBeInTheDocument(); | ||
| expect(screen.queryByText(/Hold quality/)).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('calls onAccept when Accept Anyway clicked', async () => { | ||
| const onAccept = vi.fn(); | ||
| const user = userEvent.setup(); | ||
| render( | ||
| <VerificationQualityWarning | ||
| dataQuality={fairQuality} | ||
| onAccept={onAccept} | ||
| onReject={vi.fn()} | ||
| /> | ||
| ); | ||
| await user.click(screen.getByRole('button', { name: 'Accept Anyway' })); | ||
| expect(onAccept).toHaveBeenCalledOnce(); | ||
| }); | ||
|
|
||
| it('calls onReject when Fly Again clicked', async () => { | ||
| const onReject = vi.fn(); | ||
| const user = userEvent.setup(); | ||
| render( | ||
| <VerificationQualityWarning | ||
| dataQuality={fairQuality} | ||
| onAccept={vi.fn()} | ||
| onReject={onReject} | ||
| /> | ||
| ); | ||
| await user.click(screen.getByRole('button', { name: 'Fly Again' })); | ||
| expect(onReject).toHaveBeenCalledOnce(); | ||
| }); | ||
|
|
||
| it('has correct dialog role', () => { | ||
| render( | ||
| <VerificationQualityWarning dataQuality={fairQuality} onAccept={vi.fn()} onReject={vi.fn()} /> | ||
| ); | ||
| expect( | ||
| screen.getByRole('dialog', { name: 'Verification quality warning' }) | ||
| ).toBeInTheDocument(); | ||
| }); | ||
| }); |
64 changes: 64 additions & 0 deletions
64
src/renderer/components/TuningHistory/VerificationQualityWarning.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import React from 'react'; | ||
| import type { DataQualityScore } from '@shared/types/analysis.types'; | ||
|
|
||
| interface VerificationQualityWarningProps { | ||
| dataQuality: DataQualityScore; | ||
| onAccept: () => void; | ||
| onReject: () => void; | ||
| } | ||
|
|
||
| const TIER_DISPLAY: Record<DataQualityScore['tier'], { label: string; color: string }> = { | ||
| poor: { label: 'Poor', color: '#e74c3c' }, | ||
| fair: { label: 'Fair', color: '#f39c12' }, | ||
| good: { label: 'Good', color: '#27ae60' }, | ||
| excellent: { label: 'Excellent', color: '#2ecc71' }, | ||
| }; | ||
|
|
||
| export function VerificationQualityWarning({ | ||
| dataQuality, | ||
| onAccept, | ||
| onReject, | ||
| }: VerificationQualityWarningProps) { | ||
| const { label: tierLabel, color: tierColor } = TIER_DISPLAY[dataQuality.tier]; | ||
|
|
||
| return ( | ||
| <div className="profile-wizard-overlay" role="dialog" aria-label="Verification quality warning"> | ||
| <div className="profile-wizard-modal" style={{ maxWidth: 480 }}> | ||
| <h3>Low Verification Data Quality</h3> | ||
| <p style={{ margin: '12px 0' }}> | ||
| The verification flight data quality is{' '} | ||
| <strong style={{ color: tierColor }}> | ||
| {tierLabel} ({dataQuality.overall}/100) | ||
| </strong> | ||
| . This may not give reliable results. | ||
| </p> | ||
|
|
||
| {dataQuality.subScores && dataQuality.subScores.length > 0 && ( | ||
| <div style={{ margin: '12px 0', fontSize: 13, color: 'var(--text-secondary, #888)' }}> | ||
| {dataQuality.subScores | ||
| .filter((s) => s.score < 60) | ||
| .map((s) => ( | ||
| <div key={s.name}> | ||
| {s.name}: {s.score}/100 | ||
| </div> | ||
| ))} | ||
| </div> | ||
| )} | ||
|
|
||
| <p style={{ margin: '12px 0', fontSize: 13 }}> | ||
| For PID Tune, include at least 8-10 sharp stick snaps across roll and pitch axes. For | ||
| Filter Tune, include a steady throttle sweep from low to high. | ||
| </p> | ||
|
|
||
| <div style={{ display: 'flex', gap: 8, justifyContent: 'flex-end', marginTop: 20 }}> | ||
| <button className="wizard-btn wizard-btn-secondary" onClick={onReject}> | ||
| Fly Again | ||
| </button> | ||
| <button className="wizard-btn wizard-btn-primary" onClick={onAccept}> | ||
| Accept Anyway | ||
| </button> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handleQualityGateAcceptcan be triggered multiple times (e.g., double-clicking “Accept Anyway”), which could runcommitVerificationconcurrently and perform duplicate updates. Consider guarding against re-entry (disable modal buttons while accepting, clearpendingVerificationbefore awaiting, or add an in-flight flag).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed — pendingVerification is cleared before await in 22f0dcf.