@@ -9,7 +9,7 @@ vi.mock("../telemetry/events.js", () => ({
99} ) ) ;
1010
1111import { contrastRatio , parseColorRGBA } from "./contrast-bg.js" ;
12- import { createCheckCommand } from "./check.js" ;
12+ import { createCheckCommand , parseCheckRange } from "./check.js" ;
1313import { trackCommandFailures } from "../utils/command-failure-tracking.js" ;
1414import type { CommandDef } from "citty" ;
1515
@@ -2259,3 +2259,113 @@ describe("dense motion-overlap re-sampling", () => {
22592259 expect ( report . layout . findings . some ( ( f ) => f . code === "content_overlap" ) ) . toBe ( true ) ;
22602260 } ) ;
22612261} ) ;
2262+
2263+ describe ( "scoped check" , ( ) => {
2264+ it ( "bounds all runtime seeks, including dense overlap and transition samples" , async ( ) => {
2265+ const times : number [ ] = [ ] ;
2266+ const overlapTimes : number [ ] = [ ] ;
2267+ const driver = fakeDriver ( {
2268+ getDuration : async ( ) => 10 ,
2269+ getTransitionBoundaries : async ( ) => [ 1 , 7.9 , 9 ] ,
2270+ seek : async ( t ) => {
2271+ times . push ( t ) ;
2272+ } ,
2273+ seekGeometry : async ( t ) => {
2274+ times . push ( t ) ;
2275+ overlapTimes . push ( t ) ;
2276+ } ,
2277+ } ) ;
2278+ const { report } = await runScenario ( driver , { range : [ 7.8 , 8.2 ] , atTransitions : true } ) ;
2279+ expect ( times . length ) . toBeGreaterThan ( 3 ) ;
2280+ expect ( times . every ( ( t ) => t >= 7.8 && t <= 8.2 ) ) . toBe ( true ) ;
2281+ expect ( times ) . toContain ( 7.9 ) ;
2282+ expect ( overlapTimes . every ( ( time ) => ( String ( time ) . split ( "." ) [ 1 ] ?. length ?? 0 ) <= 3 ) ) . toBe ( true ) ;
2283+ expect ( report . scope ?. range ) . toEqual ( [ 7.8 , 8.2 ] ) ;
2284+ } ) ;
2285+ it ( "keeps the full-check failure when the only error is hidden by filtering" , async ( ) => {
2286+ const driver = fakeDriver ( {
2287+ collectLayout : async ( ) => [ layoutIssue ( "error" ) ] ,
2288+ matchComponents : async ( _c , f ) => f . map ( ( ) => false ) ,
2289+ } ) ;
2290+ const { report } = await runScenario ( driver , {
2291+ components : [ "#selected" ] ,
2292+ collapseStatic : false ,
2293+ } ) ;
2294+ expect ( report . ok ) . toBe ( false ) ;
2295+ expect ( report . layout . findings ) . toHaveLength ( 0 ) ;
2296+ expect ( report . layout . errorCount ) . toBe ( 1 ) ;
2297+ expect ( report . runtime . findings ) . toHaveLength ( 0 ) ;
2298+ expect ( report . scope ?. hiddenFindings ) . toBe ( 1 ) ;
2299+ } ) ;
2300+ it . each ( [
2301+ {
2302+ flag : "--caption-zone" ,
2303+ options : {
2304+ range : [ 1 , 2 ] as [ number , number ] ,
2305+ captionZone : { x0 : 0 , y0 : 0.5 , x1 : 1 , y1 : 0.7 } ,
2306+ } ,
2307+ } ,
2308+ {
2309+ flag : "--frame-check" ,
2310+ options : { range : [ 0 , 1 ] as [ number , number ] , frameCheck : { } } ,
2311+ } ,
2312+ ] ) (
2313+ "refuses $flag when none of its gate samples lie within --range" ,
2314+ async ( { flag, options } ) => {
2315+ const { report } = await runScenario ( fakeDriver ( { getDuration : async ( ) => 4 } ) , options ) ;
2316+ expect ( report . ok ) . toBe ( false ) ;
2317+ expect ( report . browserSkipped ) . toBe ( true ) ;
2318+ expect ( report . runtime . findings ) . toEqual ( [
2319+ expect . objectContaining ( { message : expect . stringContaining ( `No ${ flag } seek samples` ) } ) ,
2320+ ] ) ;
2321+ } ,
2322+ ) ;
2323+ it ( "marks a motion spec disabled when a range skips whole-timeline assertions" , async ( ) => {
2324+ const motion : MotionSpecResolution = {
2325+ kind : "valid" ,
2326+ path : "/project/index.motion.json" ,
2327+ spec : { assertions : [ ] } ,
2328+ } ;
2329+ const { report } = await runScenario (
2330+ fakeDriver ( { getDuration : async ( ) => 4 } ) ,
2331+ { range : [ 1 , 2 ] } ,
2332+ { motion } ,
2333+ ) ;
2334+ expect ( report . motion ) . toEqual (
2335+ expect . objectContaining ( {
2336+ enabled : false ,
2337+ specPath : "/project/index.motion.json" ,
2338+ samples : 0 ,
2339+ } ) ,
2340+ ) ;
2341+ } ) ;
2342+ it ( "rejects a range outside the film rather than passing an empty check" , async ( ) => {
2343+ const { report } = await runScenario ( fakeDriver ( { getDuration : async ( ) => 2 } ) , {
2344+ range : [ 3 , 4 ] ,
2345+ } ) ;
2346+ expect ( report . ok ) . toBe ( false ) ;
2347+ expect ( report . browserSkipped ) . toBe ( true ) ;
2348+ expect ( report . runtime . findings [ 0 ] ?. message ) . toContain ( "2 seconds" ) ;
2349+ } ) ;
2350+ } ) ;
2351+
2352+ it ( "validates range syntax before running a check" , ( ) => {
2353+ expect ( parseCheckRange ( "7.8,8.2" ) ) . toEqual ( [ 7.8 , 8.2 ] ) ;
2354+ expect ( parseCheckRange ( "7.8:8.2" ) ) . toEqual ( [ 7.8 , 8.2 ] ) ;
2355+ for ( const value of [ "" , "1" , "1,1" , "2,1" , "-1,2" , "NaN,2" , "1,Infinity" , ",2" , "1,2,3" ] )
2356+ expect ( ( ) => parseCheckRange ( value ) ) . toThrow ( ) ;
2357+ } ) ;
2358+
2359+ it ( "applies transition sample limits within the requested range" , async ( ) => {
2360+ const driver = fakeDriver ( {
2361+ getDuration : async ( ) => 10 ,
2362+ getTransitionBoundaries : async ( ) => [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7.8 , 7.9 , 8 , 9 , 10 ] ,
2363+ } ) ;
2364+ const { report } = await runScenario ( driver , {
2365+ range : [ 7.8 , 8 ] ,
2366+ atTransitions : true ,
2367+ maxTransitionSamples : 2 ,
2368+ } ) ;
2369+ expect ( report . layout . transitionSamples ) . toEqual ( [ 7.8 , 8 ] ) ;
2370+ expect ( report . layout . transitionSamplesDropped ) . toBe ( 3 ) ;
2371+ } ) ;
0 commit comments