Skip to content

Commit 184ddd2

Browse files
committed
test(web): defer panel rendering without blocking module mocks
1 parent d2c2207 commit 184ddd2

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

‎apps/web/src/panels/pullRequest/PullRequestSidePanel.browser.test.tsx‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
type ScopedThreadRef,
1010
} from "@t3tools/contracts";
1111
import { DEFAULT_CLIENT_SETTINGS } from "@t3tools/contracts/settings";
12-
import { Suspense, type ComponentProps, type ReactElement, type ReactNode } from "react";
12+
import { use, Suspense, type ComponentProps, type ReactElement, type ReactNode } from "react";
1313
import { describe, expect, it, vi } from "vite-plus/test";
1414

1515
import { useComposerDraftStore } from "~/composerDraftStore";
@@ -71,6 +71,7 @@ vi.mock("~/hooks/useSettings", () => ({
7171
select(DEFAULT_CLIENT_SETTINGS),
7272
useEnvironmentSettings: () => undefined,
7373
}));
74+
vi.mock("~/commandPaletteBus", () => ({ isCommandPaletteOpen: () => false }));
7475
vi.mock("~/hooks/useLiveRefresh", () => ({ useLiveRefresh: () => {} }));
7576
vi.mock("~/hooks/useHandleNewThread", () => ({ useNewThreadHandler: () => vi.fn() }));
7677
vi.mock("~/state/sourceControlActions", () => ({
@@ -136,6 +137,7 @@ vi.mock("~/components/ui/menu", () => ({
136137
MenuGroup: Wrapper,
137138
MenuTrigger: Trigger,
138139
MenuItem: "button",
140+
MenuCheckboxItem: "button",
139141
MenuRadioGroup: Wrapper,
140142
MenuRadioItem: "button",
141143
MenuSeparator: () => null,
@@ -166,8 +168,13 @@ vi.mock("~/components/pullRequest/PullRequestGuideTab", () => ({
166168
PullRequestGuideTab: () => null,
167169
}));
168170
vi.mock("./PullRequestSidePanel", async (importOriginal) => {
169-
await bodyImport.promise;
170-
return importOriginal();
171+
const { default: Body } = await importOriginal<typeof import("./PullRequestSidePanel")>();
172+
return {
173+
default: function DeferredBody(props: ComponentProps<typeof Body>) {
174+
use(bodyImport.promise);
175+
return <Body {...props} />;
176+
},
177+
};
171178
});
172179

173180
import { RegisteredSidePanel } from "../bundledPanels";
@@ -286,7 +293,7 @@ const isLoading = (screen: Screen) =>
286293

287294
describe("pull request side panel", () => {
288295
// Runs first, while the body's code is still held back.
289-
it("shows the pull request loading state until its code arrives", async () => {
296+
it("shows the pull request loading state until its body is ready", async () => {
290297
resetFixture();
291298
await using screen = await renderScreen(null, { router: false });
292299
await renderFor(screen, refOn("environment-new"));

0 commit comments

Comments
 (0)