fix(#338): Disable QuickCaptureWidget in production with Coming Soon

- Show Coming Soon placeholder in production for both widget versions
- Widget available in development mode only
- Added tests verifying environment-based behavior
- Use runtime check for testability (isDevelopment function vs constant)

Refs #338

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Jason Woltje
2026-02-05 17:57:50 -06:00
parent 1c79da70a6
commit 10d4de5d69
4 changed files with 233 additions and 3 deletions

View File

@@ -3,8 +3,19 @@
import { useState } from "react";
import { Button } from "@mosaic/ui";
import { useRouter } from "next/navigation";
import { ComingSoon } from "@/components/ui/ComingSoon";
export function QuickCaptureWidget(): React.JSX.Element {
/**
* Check if we're in development mode (runtime check for testability)
*/
function isDevelopment(): boolean {
return process.env.NODE_ENV === "development";
}
/**
* Internal Quick Capture Widget implementation
*/
function QuickCaptureWidgetInternal(): React.JSX.Element {
const [idea, setIdea] = useState("");
const router = useRouter();
@@ -48,3 +59,27 @@ export function QuickCaptureWidget(): React.JSX.Element {
</div>
);
}
/**
* Quick Capture Widget (Dashboard version)
*
* In production: Shows Coming Soon placeholder
* In development: Full widget functionality
*/
export function QuickCaptureWidget(): React.JSX.Element {
// In production, show Coming Soon placeholder
if (!isDevelopment()) {
return (
<div className="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
<ComingSoon
feature="Quick Capture"
description="Quickly jot down ideas for later organization. This feature is currently under development."
className="!p-0 !min-h-0"
/>
</div>
);
}
// In development, show full widget functionality
return <QuickCaptureWidgetInternal />;
}

View File

@@ -0,0 +1,93 @@
/**
* QuickCaptureWidget (Dashboard) Component Tests
* Tests environment-based behavior
*/
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
import { render, screen } from "@testing-library/react";
import { QuickCaptureWidget } from "../QuickCaptureWidget";
// Mock next/navigation
vi.mock("next/navigation", () => ({
useRouter: (): { push: () => void } => ({
push: vi.fn(),
}),
}));
describe("QuickCaptureWidget (Dashboard)", (): void => {
beforeEach((): void => {
vi.clearAllMocks();
});
afterEach((): void => {
vi.unstubAllEnvs();
});
describe("Development mode", (): void => {
beforeEach((): void => {
vi.stubEnv("NODE_ENV", "development");
});
it("should render the widget form in development", (): void => {
render(<QuickCaptureWidget />);
// Should show the header
expect(screen.getByText("Quick Capture")).toBeInTheDocument();
// Should show the textarea
expect(screen.getByRole("textbox")).toBeInTheDocument();
// Should show the Save Note button
expect(screen.getByRole("button", { name: /save note/i })).toBeInTheDocument();
// Should show the Create Task button
expect(screen.getByRole("button", { name: /create task/i })).toBeInTheDocument();
// Should NOT show Coming Soon badge
expect(screen.queryByText("Coming Soon")).not.toBeInTheDocument();
});
it("should have a placeholder for the textarea", (): void => {
render(<QuickCaptureWidget />);
const textarea = screen.getByRole("textbox");
expect(textarea).toHaveAttribute("placeholder", "What's on your mind?");
});
});
describe("Production mode", (): void => {
beforeEach((): void => {
vi.stubEnv("NODE_ENV", "production");
});
it("should show Coming Soon placeholder in production", (): void => {
render(<QuickCaptureWidget />);
// Should show Coming Soon badge
expect(screen.getByText("Coming Soon")).toBeInTheDocument();
// Should show feature name
expect(screen.getByText("Quick Capture")).toBeInTheDocument();
// Should NOT show the textarea
expect(screen.queryByRole("textbox")).not.toBeInTheDocument();
// Should NOT show the buttons
expect(screen.queryByRole("button", { name: /save note/i })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: /create task/i })).not.toBeInTheDocument();
});
it("should show description in Coming Soon placeholder", (): void => {
render(<QuickCaptureWidget />);
expect(screen.getByText(/jot down ideas for later organization/i)).toBeInTheDocument();
});
});
describe("Test mode (non-development)", (): void => {
beforeEach((): void => {
vi.stubEnv("NODE_ENV", "test");
});
it("should show Coming Soon placeholder in test mode", (): void => {
render(<QuickCaptureWidget />);
// Test mode is not development, so should show Coming Soon
expect(screen.getByText("Coming Soon")).toBeInTheDocument();
expect(screen.queryByRole("textbox")).not.toBeInTheDocument();
});
});
});