@@ -12,6 +12,8 @@ import classes from './thumb-page.module.css';
1212
1313import React from 'react' ;
1414import { useDragDropThumb } from './drag-drop-thumb.hook' ;
15+ import Konva from 'konva' ;
16+ import { ENV } from '@/core/constants' ;
1517
1618interface Props {
1719 pageIndex : number ;
@@ -35,6 +37,7 @@ export const ThumbPage: React.FunctionComponent<Props> = props => {
3537 } ) ;
3638
3739 const divRef = useRef < HTMLDivElement > ( null ) ;
40+ const layerRef = useRef < Konva . Layer > ( null ) ;
3841 const [ key , setKey ] = React . useState ( 0 ) ;
3942
4043 const { dragging, isDraggedOver } = useDragDropThumb ( divRef , pageIndex ) ;
@@ -52,6 +55,15 @@ export const ThumbPage: React.FunctionComponent<Props> = props => {
5255 } , 100 ) ;
5356 } ;
5457
58+ // Exposing thumb layer for testing
59+
60+ if ( typeof window !== 'undefined' && ENV . IS_TEST_ENV && layerRef . current ) {
61+ if ( ! window . __TESTING_KONVA_THUMB_LAYERS__ ) {
62+ window . __TESTING_KONVA_THUMB_LAYERS__ = [ ] ;
63+ }
64+ window . __TESTING_KONVA_THUMB_LAYERS__ [ pageIndex ] = layerRef . current ;
65+ }
66+
5567 React . useLayoutEffect ( ( ) => {
5668 handleResizeAndForceRedraw ( ) ;
5769 } , [ ] ) ;
@@ -105,7 +117,7 @@ export const ThumbPage: React.FunctionComponent<Props> = props => {
105117 scaleX = { finalScale }
106118 scaleY = { finalScale }
107119 >
108- < Layer >
120+ < Layer ref = { layerRef } >
109121 { shapes . map ( shape => {
110122 if ( ! fakeShapeRefs . current [ shape . id ] ) {
111123 fakeShapeRefs . current [ shape . id ] = createRef ( ) ;
0 commit comments