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.

Created: 2026-05-30 01:42 EDT Beads: islandflow-3l6 Validation: local typecheck + test suite passed

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.

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.

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.

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,

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.

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.

Follow-up Work