11import type { EditorProps } from "@monaco-editor/react" ;
22import { TooltipProvider } from "@radix-ui/react-tooltip" ;
3- import { render , screen , waitFor } from "@testing-library/react" ;
3+ import {
4+ cleanup ,
5+ render ,
6+ screen ,
7+ waitFor ,
8+ } from "@testing-library/react" ;
49import type { FC } from "react" ;
510import { createBrowserRouter , RouterProvider } from "react-router" ;
6- import { beforeEach , describe , expect , it , vi } from "vitest" ;
11+ import { afterEach , beforeEach , describe , expect , it , vi } from "vitest" ;
712import { App } from "@/client/App" ;
813import { EditorProvider } from "@/client/contexts/editor" ;
914import { ThemeProvider } from "@/client/contexts/theme" ;
10- import { initWasm } from "@/utils/wasm" ;
11- import defaultExample from "@/examples/code/default.tf?raw" ;
1215import attachGPUExample from "@/examples/code/attach-gpu.tf?raw" ;
16+ import defaultExample from "@/examples/code/default.tf?raw" ;
17+ import { initWasm } from "@/utils/wasm" ;
1318
1419vi . mock ( "@/utils/wasm" , async ( ) => {
20+ const { getDynamicParametersOutput } = await import ( "@/utils/wasm" ) ;
1521 return {
1622 initWasm : vi
1723 . fn < typeof initWasm > ( async ( ) => {
@@ -22,7 +28,7 @@ vi.mock("@/utils/wasm", async () => {
2228 return "loaded" ;
2329 } )
2430 . mockResolvedValue ( "loaded" ) ,
25- getDynamicParametersOutput : vi . fn ( async ( ) => null ) ,
31+ getDynamicParametersOutput : vi . fn ( getDynamicParametersOutput ) ,
2632 } ;
2733} ) ;
2834
@@ -31,7 +37,7 @@ vi.mock("@monaco-editor/react", () => ({
3137 < textarea
3238 data-testid = "monaco-editor"
3339 value = { value }
34- onChange = { ( e ) =>
40+ onChange = { ( e ) => {
3541 onChange ?.( e . target . value , {
3642 changes : [ ] ,
3743 eol : "\n" ,
@@ -40,8 +46,8 @@ vi.mock("@monaco-editor/react", () => ({
4046 isRedoing : false ,
4147 isFlush : false ,
4248 isEolChange : false ,
43- } )
44- }
49+ } ) ;
50+ } }
4551 { ...props }
4652 />
4753 ) ,
@@ -73,6 +79,9 @@ describe("App - Initial State Setup", () => {
7379 delete window . go_preview ;
7480 vi . clearAllMocks ( ) ;
7581 } ) ;
82+ afterEach ( ( ) => {
83+ cleanup ( ) ;
84+ } ) ;
7685
7786 it ( "should show the loading modal while the wasm module is loading" , async ( ) => {
7887 render ( < TestApp /> ) ;
@@ -114,3 +123,4 @@ describe("App - Initial State Setup", () => {
114123 expect ( screen . findByDisplayValue ( attachGPUExample ) ) ;
115124 } ) ;
116125} ) ;
126+
0 commit comments