diff --git a/apps/web/app/terminal.test.ts b/apps/web/app/terminal.test.ts index 073bc8c..062ea35 100644 --- a/apps/web/app/terminal.test.ts +++ b/apps/web/app/terminal.test.ts @@ -5,17 +5,29 @@ const redirect = mock((path: string) => { throw new Error(`NEXT_REDIRECT:${path}`); }); -mock.module("next/navigation", () => ({ - redirect, - usePathname: () => "/options" -})); -mock.module("next/navigation.js", () => ({ +const nextNavigationMock = { default: { redirect, usePathname: () => "/options" }, redirect, usePathname: () => "/options" +}; + +const nextNavigationResolved = import.meta.resolve("next/navigation"); +const nextNavigationJsResolved = import.meta.resolve("next/navigation.js"); + +mock.module("next/navigation", () => ({ + ...nextNavigationMock +})); +mock.module("next/navigation.js", () => ({ + ...nextNavigationMock +})); +mock.module(nextNavigationResolved, () => ({ + ...nextNavigationMock +})); +mock.module(nextNavigationJsResolved, () => ({ + ...nextNavigationMock })); const { diff --git a/docs/turns/2026-05-30-fix-forgejo-ci-test-mocks.html b/docs/turns/2026-05-30-fix-forgejo-ci-test-mocks.html index c5d2694..4931497 100644 --- a/docs/turns/2026-05-30-fix-forgejo-ci-test-mocks.html +++ b/docs/turns/2026-05-30-fix-forgejo-ci-test-mocks.html @@ -122,32 +122,43 @@
Turn document

Fix Forgejo CI terminal test mock alias

-

The final CI-only failure was a Next.js module-shape mismatch in the terminal test. I added the missing next/navigation.js alias so Forgejo can resolve the same named exports the full Bun test run expects.

+

The remaining Forgejo-only failure was a Next.js module-shape mismatch in the terminal test. I taught the test harness to mock both the bare next/navigation specifier and the resolved next/navigation.js path so Forgejo can import the same named exports the local suite already accepts.

- Updated: 2026-05-30 01:48 EDT + Updated: 2026-05-30 01:53 EDT Beads: islandflow-3l6 Validation: targeted terminal test + full Bun suite passed
-

New Changes as of 2026-05-30 01:48 EDT

-

This update is the last missing piece after the earlier Bun PATH and redirect-mock fixes. Forgejo was still loading next/navigation.js directly in the terminal test, so Bun threw before the test body could run.

+

New Changes as of 2026-05-30 01:53 EDT

+

This update builds on the earlier Bun PATH and redirect-mock fixes. Forgejo was still resolving the Next.js navigation module through the explicit .js path, so the test harness now mocks both the specifier and the resolved path before the terminal module loads.

Summary of changes

Why this change was made

-

The previous mock covered next/navigation, but the full CI run resolved the explicit .js entry point. Without the alias, Bun reported a missing named export and aborted the test file.

+

The previous mock covered the string specifier, but Forgejo's Bun runtime still resolved the explicit .js entry point in the test job. Without the resolved-path aliases, Bun reported a missing named export and aborted the file before the assertions could run.

Code diff

-
mock.module("next/navigation.js", () => ({
+        
const nextNavigationMock = {
   default: {
     redirect,
     usePathname: () => "/options"
   },
   redirect,
   usePathname: () => "/options"
+};
+
+const nextNavigationResolved = import.meta.resolve("next/navigation");
+const nextNavigationJsResolved = import.meta.resolve("next/navigation.js");
+
+mock.module(nextNavigationResolved, () => ({
+  ...nextNavigationMock
+}));
+mock.module(nextNavigationJsResolved, () => ({
+  ...nextNavigationMock
 }));

Related issues or PRs

islandflow-3l6

@@ -183,7 +194,7 @@

Relevant Diff Snippets

-

Rendered with @pierre/diffs/ssr from the current working tree. It shows the new next/navigation.js alias in the terminal test.

+

Rendered with @pierre/diffs/ssr from the current working tree. It shows the shared Next.js navigation mock plus the explicit resolved-path aliases that keep Forgejo aligned with the local Bun runtime.

apps/web/app/terminal.test.ts
+8
8 unmodified lines
9
10
11
12
13
14
8 unmodified lines
redirect,
usePathname: () => "/options"
}));
-
const {
NAV_ITEMS,
8 unmodified lines
9
10
11
12
13
14
15
16
17
18
19
20
21
22
8 unmodified lines
redirect,
usePathname: () => "/options"
}));
mock.module("next/navigation.js", () => ({
default: {
redirect,
usePathname: () => "/options"
},
redirect,
usePathname: () => "/options"
}));
-
const {
NAV_ITEMS,
+}
apps/web/app/terminal.test.ts
-5+17
4 unmodified lines
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
4 unmodified lines
throw new Error(`NEXT_REDIRECT:${path}`);
});
+
mock.module("next/navigation", () => ({
redirect,
usePathname: () => "/options"
}));
mock.module("next/navigation.js", () => ({
default: {
redirect,
usePathname: () => "/options"
},
redirect,
usePathname: () => "/options"
}));
+
const {
4 unmodified lines
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
4 unmodified lines
throw new Error(`NEXT_REDIRECT:${path}`);
});
+
const nextNavigationMock = {
default: {
redirect,
usePathname: () => "/options"
},
redirect,
usePathname: () => "/options"
};
+
const nextNavigationResolved = import.meta.resolve("next/navigation");
const nextNavigationJsResolved = import.meta.resolve("next/navigation.js");
+
mock.module("next/navigation", () => ({
...nextNavigationMock
}));
mock.module("next/navigation.js", () => ({
...nextNavigationMock
}));
mock.module(nextNavigationResolved, () => ({
...nextNavigationMock
}));
mock.module(nextNavigationJsResolved, () => ({
...nextNavigationMock
}));
+
const {
@@ -278,4 +293,4 @@
- \ No newline at end of file +