fix(feedback): hide user-facing feedback link when admin disables the feature

The `<ErrorDetails>` panel — rendered by every Next.js `error.tsx`
boundary in HealthLog — surfaces a "Report bug" button that links to
`/bugreport`. When the admin flips `bugReportEnabled = false`, that
page renders a "Bug reports are disabled" notice. Showing the button
in that state is dead-end UX.

Reuse the `useAppSettings()` hook introduced for the sidebar nav (Fix
1) and gate the button on the same flag. The other escape hatches
(retry, copy diagnostic payload) stay visible so the panel remains
useful even when in-app submission is disabled.

Tests: SSR-render `<ErrorDetails>` with both flag states and assert
the `/bugreport` href appears / disappears accordingly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Marc-André BombeckandClaude Opus 4.7 committed 2026-05-09 20:19:09 +02:00
1 parent 2c227fb0c1
commit bde167df75
1 file changed
+42
@@ -0,0 +1,42 @@
import { describe, expect, it, vi } from "vitest";
import { renderToStaticMarkup } from "react-dom/server";
// `<ErrorDetails>` is a client component used by every Next.js
// `error.tsx` boundary. It surfaces a "Report bug" link whose
// visibility must mirror the admin's `bugReportEnabled` toggle —
// otherwise the user lands on a `/bugreport` page that immediately
// renders a "Bug reports are disabled" notice.
const mockSettingsRef = { value: { bugReportEnabled: true } };
vi.mock("@/components/app-settings-provider", () => ({
useAppSettings: () => mockSettingsRef.value,
}));
import { I18nProvider } from "@/lib/i18n/context";
import { ErrorDetails } from "../error-details";
function render({
bugReportEnabled = true,
}: { bugReportEnabled?: boolean } = {}) {
mockSettingsRef.value = { bugReportEnabled };
const error = Object.assign(new Error("test failure"), {
digest: "abc123",
});
return renderToStaticMarkup(
<I18nProvider initialLocale="en">
<ErrorDetails error={error} />
</I18nProvider>,
);
}
describe("<ErrorDetails> bug-report toggle", () => {
it("shows the Report bug button when the admin flag is enabled", () => {
const html = render({ bugReportEnabled: true });
expect(html).toContain('href="/bugreport"');
});
it("hides the Report bug button when the admin flag is disabled", () => {
const html = render({ bugReportEnabled: false });
expect(html).not.toContain('href="/bugreport"');
});
});