diff --git a/apps/web/app/terminal.test.ts b/apps/web/app/terminal.test.ts index 27f376e..073bc8c 100644 --- a/apps/web/app/terminal.test.ts +++ b/apps/web/app/terminal.test.ts @@ -9,6 +9,14 @@ mock.module("next/navigation", () => ({ redirect, usePathname: () => "/options" })); +mock.module("next/navigation.js", () => ({ + default: { + redirect, + usePathname: () => "/options" + }, + redirect, + usePathname: () => "/options" +})); const { NAV_ITEMS, 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 9432604..c5d2694 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 @@ -3,7 +3,7 @@ - Fix Forgejo CI test mocks and Bun path handling + Fix Forgejo CI terminal test mock alias
Turn document
-

Fix Forgejo CI test mocks and Bun path handling

-

Tightened the CI-facing web tests and Bun resolution path so Forgejo can install dependencies, run the typecheck helper, and execute the web test suite without shell PATH surprises.

+

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.

- Created: 2026-05-30 01:42 EDT + Updated: 2026-05-30 01:48 EDT Beads: islandflow-3l6 - Validation: local typecheck + test suite passed + 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.

+

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.

+

Code diff

+
mock.module("next/navigation.js", () => ({
+  default: {
+    redirect,
+    usePathname: () => "/options"
+  },
+  redirect,
+  usePathname: () => "/options"
+}));
+

Related issues or PRs

+

islandflow-3l6

+
+

Summary

-

Forgejo was failing in two places: first because the CI shell could not reliably find bun when a helper script spawned it, and then because two web tests depended on Next.js navigation module shapes that did not hold up in the CI runtime. The fix makes the typecheck helper invoke the current Bun executable directly and adjusts the affected mocks to match the module forms used during test execution.

+

The remaining Forgejo failure was inside the web test suite, not the install or typecheck stages. The terminal test needed to mock the Next.js navigation module under both import paths, so the final change keeps the CI runner from tripping over a named export mismatch.

Changes Made

Context

-

The repo uses Bun-first tooling and Forgejo as the canonical remote. The CI workflow installs Bun by absolute path, but some helper scripts and package-level commands still assume a PATH-visible Bun binary. On the web side, the terminal and route tests were sensitive to how Bun resolved Next.js module mocks, so the failures only showed up in the CI-shaped run.

+

The repository already had the Bun executable path fix and the routes mock alias fix in place. The last failure surfaced only in the full CI-shaped test run, where Bun resolved the terminal module through next/navigation.js rather than the shorter specifier used in the local test path.

Important Implementation Details

Relevant Diff Snippets

-

Rendered with @pierre/diffs/ssr. The first fragment is the full rendered output for the routes test change. The second fragment reuses the same rendered markup shape for the terminal test change after stripping the duplicate style prelude so the page stays readable.

+

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

apps/web/app/routes.test.ts
-1+2
3 unmodified lines
4
5
6
7
8
9
10
3 unmodified lines
throw new Error(`NEXT_REDIRECT:${path}`);
});
-
mock.module("next/navigation", () => ({ redirect }));
-
describe("legacy page redirects", () => {
beforeEach(() => {
3 unmodified lines
4
5
6
7
8
9
10
11
3 unmodified lines
throw new Error(`NEXT_REDIRECT:${path}`);
});
-
mock.module("next/navigation", () => ({ default: { redirect }, redirect }));
mock.module("next/navigation.js", () => ({ default: { redirect }, redirect }));
-
describe("legacy page redirects", () => {
beforeEach(() => {
-
apps/web/app/terminal.test.ts
-3+13
1
2
3
4
5
6
42 unmodified lines
49
50
51
52
53
54
55
import { describe, expect, it } from "bun:test";
import { getSubscriptionKey as getLiveSubscriptionKey } from "@islandflow/types";
import {
NAV_ITEMS,
appendHistoryTail,
buildAlertContextPath,
42 unmodified lines
resolveAlertFlowPacket,
statusLabel,
toggleFilterValue
} from "./terminal";
-
const makeItem = (traceId: string, seq: number, ts: number) => ({
trace_id: traceId,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
42 unmodified lines
59
60
61
62
63
64
65
import { describe, expect, it, mock } from "bun:test";
import { getSubscriptionKey as getLiveSubscriptionKey } from "@islandflow/types";
-
const redirect = mock((path: string) => {
throw new Error(`NEXT_REDIRECT:${path}`);
});
-
mock.module("next/navigation", () => ({
redirect,
usePathname: () => "/options"
}));
-
const {
NAV_ITEMS,
appendHistoryTail,
buildAlertContextPath,
42 unmodified lines
resolveAlertFlowPacket,
statusLabel,
toggleFilterValue
} = await import("./terminal");
-
const makeItem = (traceId: string, seq: number, ts: number) => ({
trace_id: traceId,
+}
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,

Expected Impact for End-Users

-

Contributors should see Forgejo fail less often on environment-specific Bun lookup issues, and the web test suite should stay stable under the same runtime shape the CI runner uses. That means fewer false negatives and a clearer path from local validation to a green pipeline.

+

Forgejo should stop failing on the terminal test's CI-only module resolution mismatch, which reduces false negative pipeline runs and makes it easier to trust the branch when the suite passes.

Validation

Issues, Limitations, and Mitigations

-

The current fix addresses the CI failure path that was blocking the workflow. It does not change the wider Next.js testing strategy, so if more module-shape drift appears later, the same pattern may need to be applied to adjacent tests. The workflow path fix is intentionally narrow and should not affect local development outside the CI shell.

+

This fix is intentionally narrow. If another CI-only Next.js import path shows up later, the same pattern should be applied to the affected test file instead of broadening the mock surface globally. That keeps the failure signal honest and the test harness easy to reason about.

Follow-up Work