@@ -8,9 +8,49 @@ import {
88 makeSnapshotState ,
99 PROPERTY_RUNS ,
1010 pixelRectArb ,
11+ finiteRectArb ,
1112} from './snapshot-geometry.fixtures.ts' ;
1213import { resolveInteractionTouchPoint } from './interaction-touch-point.ts' ;
1314
15+ test . each ( [
16+ { x : Number . MAX_VALUE , y : 0 , width : Number . MAX_VALUE , height : 10 } ,
17+ { x : 0 , y : Number . MAX_VALUE , width : 10 , height : Number . MAX_VALUE } ,
18+ ] ) ( 'rejects a center that overflows finite rectangle components: %j' , ( rect ) => {
19+ const node = { index : 0 , rect } ;
20+ assert . deepEqual ( resolveInteractionTouchPoint ( [ node ] , node ) , { kind : 'invalid' } ) ;
21+ } ) ;
22+
23+ test ( 'property: finite rectangles never resolve a non-finite tap coordinate' , ( ) => {
24+ fc . assert (
25+ fc . property ( finiteRectArb , ( rect ) => {
26+ const node = { index : 0 , rect } ;
27+ const result = resolveInteractionTouchPoint ( [ node ] , node ) ;
28+ if ( result . kind !== 'resolved' ) return ;
29+ assert . ok ( Number . isFinite ( result . point . x ) && Number . isFinite ( result . point . y ) ) ;
30+ } ) ,
31+ { numRuns : PROPERTY_RUNS } ,
32+ ) ;
33+ } ) ;
34+
35+ test ( 'the narrow raw parent cannot choose the navigation edge to avoid its child' , ( ) => {
36+ const parent = attachSnapshotNodeInteractionBounds (
37+ { index : 0 , type : 'Link' , rect : { x : 539 , y : 2259 , width : 2 , height : 131 } } ,
38+ { x : 0 , y : 0 , width : 1080 , height : 2274 } ,
39+ ) ;
40+ const child = {
41+ index : 1 ,
42+ parentIndex : 0 ,
43+ type : 'Button' ,
44+ ref : 'e2' ,
45+ rect : { x : 539 , y : 2259 , width : 2 , height : 3 } ,
46+ } ;
47+ assert . deepEqual ( resolveInteractionTouchPoint ( [ parent , child ] , parent ) , {
48+ kind : 'blocked' ,
49+ competitorCount : 1 ,
50+ competitorRefs : [ 'e2' ] ,
51+ } ) ;
52+ } ) ;
53+
1454test ( 'a raw target without competing descendants uses its measured input region' , ( ) => {
1555 const node = attachSnapshotNodeInteractionBounds (
1656 { index : 0 , rect : { x : 0 , y : 2259 , width : 1080 , height : 131 } } ,
0 commit comments