@@ -774,14 +774,16 @@ describe('rectangles', () => {
774774 desktopOptions . browserInstance = mockBrowserInstance
775775 } )
776776
777- it ( 'should resolve elements via raw BCR on desktop and apply DPR without re-querying ' , async ( ) => {
777+ it ( 'should resolve elements via raw BCR on desktop and apply DPR' , async ( ) => {
778778 const mockElement = { elementId : 'el1' , selector : '.nav' } as WebdriverIO . Element
779+ const freshElement = { elementId : 'el1-fresh' , selector : '.nav' } as unknown as WebdriverIO . Element
780+ vi . mocked ( mockBrowserInstance . $$ ) . mockResolvedValueOnce ( [ freshElement ] as any )
779781 mockExecute . mockResolvedValueOnce ( { x : 10 , y : 20 , width : 200 , height : 50 } )
780782
781783 const result = await determineWebScreenIgnoreRegions ( desktopOptions , [ mockElement ] )
782784
785+ expect ( mockBrowserInstance . $$ ) . toHaveBeenCalledWith ( '.nav' )
783786 expect ( mockExecute ) . toHaveBeenCalledOnce ( )
784- expect ( mockBrowserInstance . $ ) . not . toHaveBeenCalled ( )
785787 expect ( result ) . toEqual ( [
786788 { x : 20 , y : 40 , width : 400 , height : 100 } ,
787789 ] )
@@ -867,6 +869,7 @@ describe('rectangles', () => {
867869 isAndroidNativeWebScreenshot : true ,
868870 }
869871 const mockElement = { elementId : 'el1' , selector : '#header' } as WebdriverIO . Element
872+ vi . mocked ( mockBrowserInstance . $$ ) . mockResolvedValueOnce ( [ mockElement ] as any )
870873 mockExecute . mockResolvedValueOnce ( { x : 0 , y : 0 , width : 412 , height : 64 } )
871874
872875 const result = await determineWebScreenIgnoreRegions ( androidOptions , [ mockElement ] )
@@ -886,6 +889,7 @@ describe('rectangles', () => {
886889 isAndroidNativeWebScreenshot : false ,
887890 }
888891 const mockElement = { elementId : 'el1' , selector : '#header' } as WebdriverIO . Element
892+ vi . mocked ( mockBrowserInstance . $$ ) . mockResolvedValueOnce ( [ mockElement ] as any )
889893 mockExecute . mockResolvedValueOnce ( { x : 0 , y : 0 , width : 412 , height : 64 } )
890894
891895 const result = await determineWebScreenIgnoreRegions ( androidChromeOptions , [ mockElement ] )
@@ -909,6 +913,7 @@ describe('rectangles', () => {
909913
910914 it ( 'should handle mixed elements and regions with DPR applied to both' , async ( ) => {
911915 const mockElement = { elementId : 'el1' , selector : '.ad' } as WebdriverIO . Element
916+ vi . mocked ( mockBrowserInstance . $$ ) . mockResolvedValueOnce ( [ mockElement ] as any )
912917 const region = { x : 500 , y : 0 , width : 200 , height : 90 }
913918 mockExecute . mockResolvedValueOnce ( { x : 10 , y : 20 , width : 300 , height : 80 } )
914919
@@ -929,6 +934,8 @@ describe('rectangles', () => {
929934
930935 it ( 'should handle chainable promise elements' , async ( ) => {
931936 const chainableElement = Promise . resolve ( { elementId : 'el1' , selector : '.footer' } as WebdriverIO . Element )
937+ const freshElement = { elementId : 'el1-fresh' , selector : '.footer' } as unknown as WebdriverIO . Element
938+ vi . mocked ( mockBrowserInstance . $$ ) . mockResolvedValueOnce ( [ freshElement ] as any )
932939 mockExecute . mockResolvedValueOnce ( { x : 0 , y : 900 , width : 1200 , height : 100 } )
933940
934941 const result = await determineWebScreenIgnoreRegions ( desktopOptions , [ chainableElement as any ] )
@@ -940,6 +947,7 @@ describe('rectangles', () => {
940947
941948 it ( 'should use floor/ceil rounding on sub-pixel BCR values to fully cover elements' , async ( ) => {
942949 const mockElement = { elementId : 'el1' , selector : '.banner' } as WebdriverIO . Element
950+ vi . mocked ( mockBrowserInstance . $$ ) . mockResolvedValueOnce ( [ mockElement ] as any )
943951 // Sub-pixel BCR values that would lose precision if rounded independently
944952 mockExecute . mockResolvedValueOnce ( { x : 0.33 , y : 50.67 , width : 412.5 , height : 64.33 } )
945953
0 commit comments