1
0
Эх сурвалжийг харах

fix(tui): wait for diff request in tests (#40670)

Kit Langton 1 долоо хоног өмнө
parent
commit
6f4c199629

+ 2 - 1
packages/tui/test/cli/tui/diff-viewer.test.tsx

@@ -147,12 +147,12 @@ async function renderDiffViewer(vcsDiff: unknown[], height = 20, initialRoute?:
   const config = createTuiResolvedConfig()
   const config = createTuiResolvedConfig()
   const transport = createFetch((url) => {
   const transport = createFetch((url) => {
     if (url.pathname !== "/api/vcs/diff") return
     if (url.pathname !== "/api/vcs/diff") return
-    if (fail) return json({ message: "boom" }, { status: 500 })
     vcsDiffInput = {
     vcsDiffInput = {
       location: { directory: url.searchParams.get("location[directory]") },
       location: { directory: url.searchParams.get("location[directory]") },
       mode: url.searchParams.get("mode"),
       mode: url.searchParams.get("mode"),
       context: url.searchParams.get("context"),
       context: url.searchParams.get("context"),
     }
     }
+    if (fail) return json({ message: "boom" }, { status: 500 })
     return json({
     return json({
       location: { directory: "/repo/session", project: { id: "project-1", directory: "/repo/session" } },
       location: { directory: "/repo/session", project: { id: "project-1", directory: "/repo/session" } },
       data: vcsDiff,
       data: vcsDiff,
@@ -238,6 +238,7 @@ async function renderDiffViewer(vcsDiff: unknown[], height = 20, initialRoute?:
 
 
   const app = await testRender(() => <Harness />, { width: 80, height })
   const app = await testRender(() => <Harness />, { width: 80, height })
   await waitForCommand(app, commands, "diff.close")
   await waitForCommand(app, commands, "diff.close")
+  await app.waitFor(() => vcsDiffInput !== undefined)
   return {
   return {
     app,
     app,
     commands,
     commands,