@@ -125,6 +125,83 @@ const run = async () => {
125125 `Canvas rendered: ${ canvasDrawn . width } x${ canvasDrawn . height } with ${ canvasDrawn . nonTransparentPixels . toLocaleString ( ) } drawn pixels`
126126 )
127127
128+ console . log ( 'Checking that 2D graph is hidden in 3D mode...' )
129+ const graphVisibility = await page . evaluate ( ( ) => {
130+ const calendarGraph = document . querySelector ( '.js-calendar-graph' )
131+ if ( ! calendarGraph ) return { exists : false }
132+ const style = window . getComputedStyle ( calendarGraph )
133+ return {
134+ exists : true ,
135+ display : style . display ,
136+ visibility : style . visibility ,
137+ isHidden : style . display === 'none'
138+ }
139+ } )
140+
141+ if ( ! graphVisibility . exists ) {
142+ throw new Error ( 'Could not find .js-calendar-graph element' )
143+ }
144+
145+ if ( ! graphVisibility . isHidden ) {
146+ throw new Error (
147+ `2D graph should be hidden in 3D mode but has display: "${ graphVisibility . display } "`
148+ )
149+ }
150+
151+ console . log ( '2D graph correctly hidden in 3D mode' )
152+
153+ // Test 2D mode
154+ console . log ( 'Clicking 2D toggle...' )
155+ await page . click ( '[data-ic-option="squares"]' )
156+ await new Promise ( ( resolve ) => setTimeout ( resolve , 500 ) )
157+
158+ const mode2D = await page . evaluate ( ( ) => {
159+ const canvas = document . querySelector ( '#isometric-contributions' )
160+ const calendarGraph = document . querySelector ( '.js-calendar-graph' )
161+ const canvasStyle = window . getComputedStyle ( canvas )
162+ const graphStyle = window . getComputedStyle ( calendarGraph )
163+ return {
164+ canvasHidden : canvasStyle . display === 'none' ,
165+ graphVisible : graphStyle . display !== 'none'
166+ }
167+ } )
168+
169+ if ( ! mode2D . canvasHidden ) {
170+ throw new Error ( '3D canvas should be hidden in 2D mode' )
171+ }
172+ if ( ! mode2D . graphVisible ) {
173+ throw new Error ( '2D graph should be visible in 2D mode' )
174+ }
175+ console . log ( '2D mode working correctly' )
176+
177+ // Test Both mode
178+ console . log ( 'Clicking Both toggle...' )
179+ await page . click ( '[data-ic-option="both"]' )
180+ await new Promise ( ( resolve ) => setTimeout ( resolve , 500 ) )
181+
182+ const modeBoth = await page . evaluate ( ( ) => {
183+ const canvas = document . querySelector ( '#isometric-contributions' )
184+ const calendarGraph = document . querySelector ( '.js-calendar-graph' )
185+ const canvasStyle = window . getComputedStyle ( canvas )
186+ const graphStyle = window . getComputedStyle ( calendarGraph )
187+ return {
188+ canvasVisible : canvasStyle . display !== 'none' ,
189+ graphVisible : graphStyle . display !== 'none'
190+ }
191+ } )
192+
193+ if ( ! modeBoth . canvasVisible ) {
194+ throw new Error ( '3D canvas should be visible in Both mode' )
195+ }
196+ if ( ! modeBoth . graphVisible ) {
197+ throw new Error ( '2D graph should be visible in Both mode' )
198+ }
199+ console . log ( 'Both mode working correctly' )
200+
201+ // Switch back to 3D for contribution data check
202+ await page . click ( '[data-ic-option="cubes"]' )
203+ await new Promise ( ( resolve ) => setTimeout ( resolve , 500 ) )
204+
128205 console . log ( 'Checking contribution data...' )
129206 const contribTotal = await page . $eval (
130207 '.ic-contributions-wrapper ::-p-text(Contributions) + div ::-p-text(Total)' ,
0 commit comments