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:
@@ -3,7 +3,7 @@
|
||||
* Following TDD principles
|
||||
*/
|
||||
|
||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
||||
import { render, screen, waitFor } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { QuickCaptureWidget } from "../QuickCaptureWidget";
|
||||
@@ -13,6 +13,12 @@ global.fetch = vi.fn() as typeof global.fetch;
|
||||
describe("QuickCaptureWidget", (): void => {
|
||||
beforeEach((): void => {
|
||||
vi.clearAllMocks();
|
||||
// Set development mode by default for existing tests
|
||||
vi.stubEnv("NODE_ENV", "development");
|
||||
});
|
||||
|
||||
afterEach((): void => {
|
||||
vi.unstubAllEnvs();
|
||||
});
|
||||
|
||||
it("should render input field", (): void => {
|
||||
@@ -147,4 +153,48 @@ describe("QuickCaptureWidget", (): void => {
|
||||
expect(screen.getByText("Test note")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe("Environment-based behavior", (): void => {
|
||||
it("should show Coming Soon placeholder in production", (): void => {
|
||||
vi.stubEnv("NODE_ENV", "production");
|
||||
|
||||
render(<QuickCaptureWidget id="quick-capture-1" />);
|
||||
|
||||
// Should show Coming Soon badge
|
||||
expect(screen.getByText("Coming Soon")).toBeInTheDocument();
|
||||
// Should show feature name
|
||||
expect(screen.getByText("Quick Capture")).toBeInTheDocument();
|
||||
// Should show description
|
||||
expect(
|
||||
screen.getByText(/Quickly jot down ideas for later organization/i)
|
||||
).toBeInTheDocument();
|
||||
// Should NOT show the input field
|
||||
expect(screen.queryByRole("textbox")).not.toBeInTheDocument();
|
||||
// Should NOT show the submit button
|
||||
expect(screen.queryByRole("button")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("should show full widget in development mode", (): void => {
|
||||
vi.stubEnv("NODE_ENV", "development");
|
||||
|
||||
render(<QuickCaptureWidget id="quick-capture-1" />);
|
||||
|
||||
// Should show the input field
|
||||
expect(screen.getByRole("textbox")).toBeInTheDocument();
|
||||
// Should show the submit button
|
||||
expect(screen.getByRole("button", { name: /submit/i })).toBeInTheDocument();
|
||||
// Should NOT show Coming Soon badge
|
||||
expect(screen.queryByText("Coming Soon")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("should show Coming Soon placeholder in test mode (non-development)", (): void => {
|
||||
vi.stubEnv("NODE_ENV", "test");
|
||||
|
||||
render(<QuickCaptureWidget id="quick-capture-1" />);
|
||||
|
||||
// Test mode is not development, so should show Coming Soon
|
||||
expect(screen.getByText("Coming Soon")).toBeInTheDocument();
|
||||
expect(screen.queryByRole("textbox")).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user