@@ -9,6 +9,16 @@ import { vi, expect, it, describe, beforeEach } from "vitest";
99// Mock the API hook
1010vi . mock ( "../../lib/hooks/useApi" ) ;
1111
12+ // Mock react-syntax-highlighter to avoid ESM issues
13+ vi . mock ( "react-syntax-highlighter" , ( ) => ( {
14+ default : ( { children } : { children : string } ) => < pre > { children } </ pre > ,
15+ Prism : ( { children } : { children : string } ) => < pre > { children } </ pre > ,
16+ } ) ) ;
17+
18+ vi . mock ( "react-syntax-highlighter/dist/esm/styles/prism" , ( ) => ( {
19+ vscDarkPlus : { } ,
20+ } ) ) ;
21+
1222// Mock utility functions
1323vi . mock ( "../../lib/date/utils" , ( ) => ( {
1424 getTimeLeft : vi . fn ( ( ) => "2 days 5 hours remaining" ) ,
@@ -42,6 +52,7 @@ describe("Home", () => {
4252 const mockHookReturn = {
4353 data : null ,
4454 loading : true ,
55+ hasLoaded : false ,
4556 error : null ,
4657 errorStatus : null ,
4758 call : mockCall ,
@@ -53,13 +64,18 @@ describe("Home", () => {
5364
5465 renderWithProviders ( < Home /> ) ;
5566
56- expect ( screen . getByText ( / S u m m o n i n g / i) ) . toBeInTheDocument ( ) ;
67+ // Page structure is visible during loading
68+ expect ( screen . getByText ( "Leaderboards" ) ) . toBeInTheDocument ( ) ;
69+ expect ( screen . getByText ( "Submit your first kernel" ) ) . toBeInTheDocument ( ) ;
70+ // Loading indicator is present
71+ expect ( screen . getByRole ( "progressbar" ) ) . toBeInTheDocument ( ) ;
5772 } ) ;
5873
5974 it ( "shows error message" , ( ) => {
6075 const mockHookReturn = {
6176 data : null ,
6277 loading : false ,
78+ hasLoaded : true ,
6379 error : "Something went wrong" ,
6480 errorStatus : 500 ,
6581 call : mockCall ,
@@ -79,6 +95,7 @@ describe("Home", () => {
7995 const mockHookReturn = {
8096 data : null ,
8197 loading : false ,
98+ hasLoaded : true ,
8299 error : "Network error" ,
83100 errorStatus : null ,
84101 call : mockCall ,
@@ -118,6 +135,7 @@ describe("Home", () => {
118135 const mockHookReturn = {
119136 data : mockData ,
120137 loading : false ,
138+ hasLoaded : true ,
121139 error : null ,
122140 errorStatus : null ,
123141 call : mockCall ,
@@ -144,6 +162,7 @@ describe("Home", () => {
144162 const mockHookReturn = {
145163 data : mockData ,
146164 loading : false ,
165+ hasLoaded : true ,
147166 error : null ,
148167 errorStatus : null ,
149168 call : mockCall ,
@@ -203,6 +222,7 @@ describe("Home", () => {
203222 const mockHookReturn = {
204223 data : mockData ,
205224 loading : false ,
225+ hasLoaded : true ,
206226 error : null ,
207227 errorStatus : null ,
208228 call : mockCall ,
@@ -241,6 +261,7 @@ describe("Home", () => {
241261 const mockHookReturn = {
242262 data : mockData ,
243263 loading : false ,
264+ hasLoaded : true ,
244265 error : null ,
245266 errorStatus : null ,
246267 call : mockCall ,
@@ -274,6 +295,7 @@ describe("Home", () => {
274295 const mockHookReturn = {
275296 data : mockData ,
276297 loading : false ,
298+ hasLoaded : true ,
277299 error : null ,
278300 errorStatus : null ,
279301 call : mockCall ,
@@ -314,6 +336,7 @@ describe("Home", () => {
314336 const mockHookReturn = {
315337 data : mockData ,
316338 loading : false ,
339+ hasLoaded : true ,
317340 error : null ,
318341 errorStatus : null ,
319342 call : mockCall ,
@@ -352,6 +375,7 @@ describe("Home", () => {
352375 const mockHookReturn = {
353376 data : mockData ,
354377 loading : false ,
378+ hasLoaded : true ,
355379 error : null ,
356380 errorStatus : null ,
357381 call : mockCall ,
@@ -400,6 +424,7 @@ describe("Home", () => {
400424 const mockHookReturn = {
401425 data : mockData ,
402426 loading : false ,
427+ hasLoaded : true ,
403428 error : null ,
404429 errorStatus : null ,
405430 call : mockCall ,
@@ -440,6 +465,7 @@ describe("Home", () => {
440465 const mockHookReturn = {
441466 data : mockData ,
442467 loading : false ,
468+ hasLoaded : true ,
443469 error : null ,
444470 errorStatus : null ,
445471 call : mockCall ,
@@ -479,6 +505,7 @@ describe("Home", () => {
479505 const mockHookReturn = {
480506 data : mockData ,
481507 loading : false ,
508+ hasLoaded : true ,
482509 error : null ,
483510 errorStatus : null ,
484511 call : mockCall ,
@@ -529,6 +556,7 @@ describe("Home", () => {
529556 const mockHookReturn = {
530557 data : mockData ,
531558 loading : false ,
559+ hasLoaded : true ,
532560 error : null ,
533561 errorStatus : null ,
534562 call : mockCall ,
@@ -569,6 +597,7 @@ describe("Home", () => {
569597 const mockHookReturn = {
570598 data : mockData ,
571599 loading : false ,
600+ hasLoaded : true ,
572601 error : null ,
573602 errorStatus : null ,
574603 call : mockCall ,
@@ -611,6 +640,7 @@ describe("Home", () => {
611640 const mockHookReturn = {
612641 data : mockData ,
613642 loading : false ,
643+ hasLoaded : true ,
614644 error : null ,
615645 errorStatus : null ,
616646 call : mockCall ,
@@ -650,6 +680,7 @@ describe("Home", () => {
650680 const mockHookReturn = {
651681 data : mockData ,
652682 loading : false ,
683+ hasLoaded : true ,
653684 error : null ,
654685 errorStatus : null ,
655686 call : mockCall ,
0 commit comments