1- import { page , userEvent } from "@vitest/browser/context" ;
21import { http , HttpResponse } from "msw" ;
32import { setupWorker } from "msw/browser" ;
43import { afterAll , beforeAll , describe , expect , it , vi } from "vitest" ;
54import { render } from "vitest-browser-react" ;
5+ import { page , userEvent } from "vitest/browser" ;
66
77import {
88 createRouteHandler ,
@@ -86,7 +86,7 @@ afterAll(() => worker.stop());
8686
8787describe ( "UploadButton - basic" , ( ) => {
8888 it ( "fetches and displays route config" , async ( ) => {
89- const utils = render ( < UploadButton endpoint = "image" /> ) ;
89+ const utils = await render ( < UploadButton endpoint = "image" /> ) ;
9090 const label = utils . container . querySelector ( "label" ) ;
9191
9292 if ( ! label ) throw new Error ( "No label found" ) ;
@@ -106,7 +106,7 @@ describe("UploadButton - basic", () => {
106106 } ) ;
107107
108108 it ( "fetches and displays route config (with callback endpoint arg)" , async ( ) => {
109- const utils = render (
109+ const utils = await render (
110110 < UploadButton endpoint = { ( routeRegistry ) => routeRegistry . image } /> ,
111111 ) ;
112112 const label = utils . container . querySelector ( "label" ) ;
@@ -128,7 +128,7 @@ describe("UploadButton - basic", () => {
128128 } ) ;
129129
130130 it ( "shows plural when maxFileCount is > 1" , async ( ) => {
131- const utils = render ( < UploadButton endpoint = "multi" /> ) ;
131+ const utils = await render ( < UploadButton endpoint = "multi" /> ) ;
132132 const label = utils . container . querySelector ( "label" ) ;
133133
134134 if ( ! label ) throw new Error ( "No label found" ) ;
@@ -146,15 +146,15 @@ describe("UploadButton - basic", () => {
146146 it ( "picks up route config from global and skips fetch" , async ( ) => {
147147 ( window as any ) . __UPLOADTHING = extractRouterConfig ( testRouter ) ;
148148
149- render ( < UploadButton endpoint = "image" /> ) ;
149+ await render ( < UploadButton endpoint = "image" /> ) ;
150150 await expect . element ( page . getByText ( "Image (4MB)" ) ) . toBeVisible ( ) ;
151151 expect ( utGet ) . not . toHaveBeenCalled ( ) ;
152152
153153 delete ( window as any ) . __UPLOADTHING ;
154154 } ) ;
155155
156156 it ( "requests URLs when a file is selected" , async ( ) => {
157- const utils = render ( < UploadButton endpoint = "image" /> ) ;
157+ const utils = await render ( < UploadButton endpoint = "image" /> ) ;
158158 const label = utils . container . querySelector ( "label" ) ;
159159 await vi . waitFor ( ( ) =>
160160 expect ( label ) . toHaveAttribute ( "data-state" , "ready" ) ,
@@ -171,7 +171,7 @@ describe("UploadButton - basic", () => {
171171 {
172172 name : "foo.txt" ,
173173 type : "text/plain" ,
174- size : 18 ,
174+ size : 3 ,
175175 lastModified : expect . any ( Number ) ,
176176 } ,
177177 ] ,
@@ -182,7 +182,7 @@ describe("UploadButton - basic", () => {
182182 } ) ;
183183
184184 it ( "manual mode requires extra click" , async ( ) => {
185- const utils = render (
185+ const utils = await render (
186186 < UploadButton endpoint = "image" config = { { mode : "manual" } } /> ,
187187 ) ;
188188 const label = utils . container . querySelector ( "label" ) ;
@@ -209,7 +209,7 @@ describe("UploadButton - basic", () => {
209209
210210 // https://discord.com/channels/966627436387266600/1102510616326967306/1267098160468197409
211211 it . skip ( "disabled" , async ( ) => {
212- const utils = render ( < UploadButton endpoint = "image" disabled /> ) ;
212+ const utils = await render ( < UploadButton endpoint = "image" disabled /> ) ;
213213 const label = utils . container . querySelector ( "label" ) ;
214214 await vi . waitFor ( ( ) => expect ( label ) . toHaveTextContent ( "Choose File" ) ) ;
215215 expect ( label ) . toHaveAttribute ( "disabled" ) ;
@@ -218,7 +218,7 @@ describe("UploadButton - basic", () => {
218218
219219describe ( "UploadButton - lifecycle hooks" , ( ) => {
220220 it ( "onBeforeUploadBegin alters the requested files" , async ( ) => {
221- const utils = render (
221+ const utils = await render (
222222 < UploadButton
223223 endpoint = "image"
224224 onBeforeUploadBegin = { ( ) => {
@@ -245,7 +245,7 @@ describe("UploadButton - lifecycle hooks", () => {
245245
246246 it ( "onUploadBegin runs before uploading" , async ( ) => {
247247 const onUploadBegin = vi . fn ( ) ;
248- const utils = render (
248+ const utils = await render (
249249 < UploadButton endpoint = "multi" onUploadBegin = { onUploadBegin } /> ,
250250 ) ;
251251
@@ -265,7 +265,7 @@ describe("UploadButton - lifecycle hooks", () => {
265265
266266describe ( "UploadButton - Theming" , ( ) => {
267267 it ( "renders custom styles" , async ( ) => {
268- render (
268+ await render (
269269 < UploadButton
270270 endpoint = "image"
271271 appearance = { {
@@ -284,7 +284,7 @@ describe("UploadButton - Theming", () => {
284284
285285describe ( "UploadButton - Content Customization" , ( ) => {
286286 it ( "renders custom content" , async ( ) => {
287- render (
287+ await render (
288288 < UploadButton
289289 endpoint = "image"
290290 content = { {
0 commit comments