Skip to content

Commit 57c7cb6

Browse files
committed
🤖 tests: satisfy lint for mock-before-load suites
Keep the mock-before-load fixes in AppLoader auth and ProjectSidebar tests while switching the deferred loads to lint-annotated `require()` calls, which Bun test already uses elsewhere for post-mock module loading. --- _Generated with `mux` • Model: `openai:gpt-5.4` • Thinking: `xhigh` • Cost: `$447.91`_ <!-- mux-attribution: model=openai:gpt-5.4 thinking=xhigh costs=447.91 -->
1 parent 961b363 commit 57c7cb6

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

src/browser/components/AppLoader/AppLoader.auth.test.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import "../../../../tests/ui/dom";
22

33
import React from "react";
4+
import type { AppLoader as AppLoaderComponent } from "../AppLoader/AppLoader";
45
import { afterEach, beforeEach, describe, expect, mock, test } from "bun:test";
56
import { cleanup, render } from "@testing-library/react";
67
import { useTheme } from "../../contexts/ThemeContext";
@@ -101,13 +102,16 @@ function installAppLoaderModuleMocks() {
101102
}));
102103
}
103104

104-
let AppLoader: (typeof import("../AppLoader/AppLoader"))["AppLoader"];
105+
let AppLoader: typeof AppLoaderComponent;
105106

106107
describe("AppLoader", () => {
107-
beforeEach(async () => {
108+
beforeEach(() => {
108109
cleanupDom = installDom();
109110
installAppLoaderModuleMocks();
110-
({ AppLoader } = await import("../AppLoader/AppLoader"));
111+
// eslint-disable-next-line @typescript-eslint/no-require-imports -- module mocks must be registered before loading AppLoader in bun tests.
112+
({ AppLoader } = require("../AppLoader/AppLoader") as {
113+
AppLoader: typeof AppLoaderComponent;
114+
});
111115
});
112116

113117
afterEach(() => {

src/browser/components/ProjectSidebar/ProjectSidebar.test.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import "../../../../tests/ui/dom";
22

33
import { type PropsWithChildren } from "react";
4+
import type ProjectSidebarComponent from "./ProjectSidebar";
45
import { afterEach, beforeEach, describe, expect, mock, spyOn, test } from "bun:test";
56
import { cleanup, fireEvent, render, waitFor } from "@testing-library/react";
67
import * as MuxLogoDarkModule from "@/browser/assets/logos/mux-logo-dark.svg?react";
@@ -46,7 +47,7 @@ function TestWrapper(props: PropsWithChildren) {
4647

4748
const passthroughRef = <T,>(value: T): T => value;
4849

49-
let ProjectSidebar: (typeof import("./ProjectSidebar"))["default"];
50+
let ProjectSidebar: typeof ProjectSidebarComponent;
5051

5152
function installProjectSidebarModuleMocks() {
5253
void mock.module("react-dnd", () => ({
@@ -300,7 +301,7 @@ function createWorkspace(
300301
let cleanupDom: (() => void) | null = null;
301302

302303
describe("ProjectSidebar multi-project completed-subagent toggles", () => {
303-
beforeEach(async () => {
304+
beforeEach(() => {
304305
cleanupDom = installDom();
305306
window.localStorage.clear();
306307
window.localStorage.setItem(
@@ -309,7 +310,10 @@ describe("ProjectSidebar multi-project completed-subagent toggles", () => {
309310
);
310311
installProjectSidebarModuleMocks();
311312
installProjectSidebarTestDoubles();
312-
({ default: ProjectSidebar } = await import("./ProjectSidebar"));
313+
// eslint-disable-next-line @typescript-eslint/no-require-imports -- module mocks must be registered before loading ProjectSidebar in bun tests.
314+
({ default: ProjectSidebar } = require("./ProjectSidebar") as {
315+
default: typeof ProjectSidebarComponent;
316+
});
313317
});
314318

315319
afterEach(() => {

0 commit comments

Comments
 (0)