File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,8 +46,8 @@ describe('detectDrift', () => {
4646 expect ( report . fields [ 0 ] . emptyRate ) . toBe ( 0.8 ) ;
4747 } ) ;
4848
49- it ( 'does not detect drift below threshold' , ( ) => {
50- // 3 out of 5 = 60%, below default 0.8
49+ it ( 'does not detect drift below threshold (60%) ' , ( ) => {
50+ // 3 out of 5 = 60%, well below default 0.8
5151 const rows = [
5252 { title : '' } ,
5353 { title : '' } ,
@@ -59,6 +59,18 @@ describe('detectDrift', () => {
5959 expect ( report . hasDrift ) . toBe ( false ) ;
6060 } ) ;
6161
62+ it ( 'does not detect drift just below threshold (75%)' , ( ) => {
63+ // 3 out of 4 = 75%, just under 0.8
64+ const rows = [
65+ { title : '' } ,
66+ { title : '' } ,
67+ { title : '' } ,
68+ { title : 'x' } ,
69+ ] ;
70+ const report = detectDrift ( rows , [ 'title' ] , 0.8 ) ;
71+ expect ( report . hasDrift ) . toBe ( false ) ;
72+ } ) ;
73+
6274 it ( 'detects multiple fields drifting' , ( ) => {
6375 const rows = [
6476 { title : '' , author : '' , score : 10 } ,
Original file line number Diff line number Diff line change @@ -61,6 +61,7 @@ export function detectDrift(
6161 * Wrapped in chalk.yellow. No trailing newline (console.error adds it).
6262 */
6363export function formatDriftWarning ( report : DriftReport , commandName : string ) : string {
64+ if ( ! report . fields . length ) return '' ;
6465 const lines = [ chalk . yellow ( `\u26a0 Schema drift detected (${ commandName } ):` ) ] ;
6566 for ( const f of report . fields ) {
6667 const pct = Math . round ( f . emptyRate * 100 ) ;
Original file line number Diff line number Diff line change @@ -206,6 +206,7 @@ for (const [, cmd] of registry) {
206206 if ( actionOpts . verbose && ( ! result || ( Array . isArray ( result ) && result . length === 0 ) ) ) {
207207 console . error ( chalk . yellow ( `[Verbose] Warning: Command returned an empty result. If the website structural API changed or requires authentication, check the network or update the adapter.` ) ) ;
208208 }
209+ // Schema drift: warn if columns are suspiciously empty (non-breaking, stderr only)
209210 if ( Array . isArray ( result ) && result . length > 0 && cmd . columns ?. length ) {
210211 const report = detectDrift ( result , cmd . columns ) ;
211212 if ( report . hasDrift ) {
You can’t perform that action at this time.
0 commit comments