66/* eslint-disable @typescript-eslint/consistent-type-assertions */
77import type { FrontendWorkspaceMetadata } from "@/types/workspace" ;
88import type { IPCApi } from "@/types/ipc" ;
9- import type { ProjectConfig } from "@/config" ;
109import { act , cleanup , render , waitFor } from "@testing-library/react" ;
1110import { afterEach , describe , expect , mock , test } from "bun:test" ;
1211import { GlobalWindow } from "happy-dom" ;
1312import type { WorkspaceContext } from "./WorkspaceContext" ;
1413import { WorkspaceProvider , useWorkspaceContext } from "./WorkspaceContext" ;
14+ import { ProjectProvider } from "@/contexts/ProjectContext" ;
1515
1616// Helper to create test workspace metadata with default runtime config
1717const createWorkspaceMetadata = (
@@ -66,7 +66,6 @@ describe("WorkspaceContext", () => {
6666 list : ( ) => Promise . resolve ( [ ] ) ,
6767 } ) ;
6868
69-
7069 const ctx = await setup ( ) ;
7170
7271 await waitFor ( ( ) => expect ( ctx ( ) . workspaceMetadata . size ) . toBe ( 2 ) ) ;
@@ -85,7 +84,6 @@ describe("WorkspaceContext", () => {
8584 list : ( ) => Promise . resolve ( [ ] ) ,
8685 } ) ;
8786
88-
8987 const ctx = await setup ( ) ;
9088
9189 // Should have empty workspaces after failed load
@@ -131,7 +129,6 @@ describe("WorkspaceContext", () => {
131129 list : ( ) => Promise . resolve ( [ ] ) ,
132130 } ) ;
133131
134-
135132 const ctx = await setup ( ) ;
136133
137134 await waitFor ( ( ) => expect ( ctx ( ) . workspaceMetadata . size ) . toBe ( 1 ) ) ;
@@ -167,7 +164,6 @@ describe("WorkspaceContext", () => {
167164 list : ( ) => Promise . resolve ( [ ] ) ,
168165 } ) ;
169166
170-
171167 const ctx = await setup ( ) ;
172168
173169 await waitFor ( ( ) => expect ( ctx ( ) . loading ) . toBe ( false ) ) ;
@@ -198,7 +194,6 @@ describe("WorkspaceContext", () => {
198194 list : ( ) => Promise . resolve ( [ ] ) ,
199195 } ) ;
200196
201-
202197 const ctx = await setup ( ) ;
203198
204199 await waitFor ( ( ) => expect ( ctx ( ) . loading ) . toBe ( false ) ) ;
@@ -229,7 +224,6 @@ describe("WorkspaceContext", () => {
229224 list : ( ) => Promise . resolve ( [ ] ) ,
230225 } ) ;
231226
232-
233227 const ctx = await setup ( ) ;
234228
235229 await waitFor ( ( ) => expect ( ctx ( ) . loading ) . toBe ( false ) ) ;
@@ -276,7 +270,6 @@ describe("WorkspaceContext", () => {
276270 list : ( ) => Promise . resolve ( [ ] ) ,
277271 } ) ;
278272
279-
280273 const ctx = await setup ( ) ;
281274
282275 await waitFor ( ( ) => expect ( ctx ( ) . loading ) . toBe ( false ) ) ;
@@ -329,7 +322,6 @@ describe("WorkspaceContext", () => {
329322 list : ( ) => Promise . resolve ( [ ] ) ,
330323 } ) ;
331324
332-
333325 const ctx = await setup ( ) ;
334326
335327 await waitFor ( ( ) => expect ( ctx ( ) . loading ) . toBe ( false ) ) ;
@@ -382,7 +374,6 @@ describe("WorkspaceContext", () => {
382374 list : ( ) => Promise . resolve ( [ ] ) ,
383375 } ) ;
384376
385-
386377 const ctx = await setup ( ) ;
387378
388379 await waitFor ( ( ) => expect ( ctx ( ) . loading ) . toBe ( false ) ) ;
@@ -421,7 +412,6 @@ describe("WorkspaceContext", () => {
421412 list : ( ) => Promise . resolve ( [ ] ) ,
422413 } ) ;
423414
424-
425415 const ctx = await setup ( ) ;
426416
427417 await waitFor ( ( ) => expect ( ctx ( ) . loading ) . toBe ( false ) ) ;
@@ -440,7 +430,6 @@ describe("WorkspaceContext", () => {
440430 list : ( ) => Promise . resolve ( [ ] ) ,
441431 } ) ;
442432
443-
444433 const ctx = await setup ( ) ;
445434
446435 await waitFor ( ( ) => expect ( ctx ( ) . loading ) . toBe ( false ) ) ;
@@ -477,7 +466,6 @@ describe("WorkspaceContext", () => {
477466 list : ( ) => Promise . resolve ( [ ] ) ,
478467 } ) ;
479468
480-
481469 const ctx = await setup ( ) ;
482470
483471 await waitFor ( ( ) => expect ( ctx ( ) . loading ) . toBe ( false ) ) ;
@@ -530,7 +518,6 @@ describe("WorkspaceContext", () => {
530518 list : ( ) => Promise . resolve ( [ ] ) ,
531519 } ) ;
532520
533-
534521 const ctx = await setup ( ) ;
535522
536523 await waitFor ( ( ) => expect ( ctx ( ) . workspaceMetadata . has ( "ws-1" ) ) . toBe ( true ) ) ;
@@ -559,7 +546,6 @@ describe("WorkspaceContext", () => {
559546 list : ( ) => Promise . resolve ( [ ] ) ,
560547 } ) ;
561548
562-
563549 const ctx = await setup ( ) ;
564550
565551 await waitFor ( ( ) => expect ( ctx ( ) . workspaceMetadata . size ) . toBe ( 1 ) ) ;
@@ -575,10 +561,8 @@ async function setup() {
575561 contextRef . current = useWorkspaceContext ( ) ;
576562 return null ;
577563 }
578-
564+
579565 // WorkspaceProvider needs ProjectProvider to call useProjectContext
580- const { ProjectProvider } = await import ( "@/contexts/ProjectContext" ) ;
581-
582566 render (
583567 < ProjectProvider >
584568 < WorkspaceProvider >
0 commit comments