Files
hyperframes/packages/studio/src/components/editor/manualEditingAvailability.test.ts
T
Vance Ingalls a4167ede07 feat(studio): default the flat inspector on
Flip STUDIO_FLAT_INSPECTOR_ENABLED's default from false to true — the
bug-fix pass on the flat inspector is complete (right-aligned values,
Stroke width/style split, promote-badge overlap, Layout/Style section
gating for non-visual elements like audio). VITE_STUDIO_FLAT_INSPECTOR_ENABLED=false
still opts back into the legacy panel.

Updates the two tests that asserted the old false default: the flag's
own default test, and the "classic PropertyPanel input coverage" suite,
which relied on that default to reach the legacy panel and now mocks it
explicitly (mirroring the adjacent "flat" suite's existing pattern).
2026-07-17 00:37:39 -07:00

119 lines
3.8 KiB
TypeScript

import { afterEach, describe, expect, it, vi } from "vitest";
import { resolveStudioBooleanEnvFlag } from "./manualEditingAvailability";
async function loadAvailabilityWithEnv(env: Record<string, string | undefined>) {
vi.resetModules();
vi.unstubAllEnvs();
for (const [key, value] of Object.entries(env)) {
if (value !== undefined) vi.stubEnv(key, value);
}
return import("./manualEditingAvailability");
}
describe("manual editing availability", () => {
afterEach(() => {
vi.unstubAllEnvs();
vi.resetModules();
});
it("enables inspector selection and manual dragging by default", async () => {
const availability = await loadAvailabilityWithEnv({});
expect(availability.STUDIO_PREVIEW_MANUAL_EDITING_ENABLED).toBe(true);
expect(availability.STUDIO_PREVIEW_SELECTION_ENABLED).toBe(true);
expect(availability.STUDIO_INSPECTOR_PANELS_ENABLED).toBe(true);
});
it("disables preview selection when the inspector panel flag is explicitly off", async () => {
const availability = await loadAvailabilityWithEnv({
VITE_STUDIO_ENABLE_INSPECTOR_PANELS: "0",
});
expect(availability.STUDIO_INSPECTOR_PANELS_ENABLED).toBe(false);
expect(availability.STUDIO_PREVIEW_SELECTION_ENABLED).toBe(false);
});
it("enables feature flags with explicit truthy env values", () => {
expect(
resolveStudioBooleanEnvFlag(
{ VITE_STUDIO_ENABLE_PREVIEW_MANUAL_DRAGGING: "true" },
["VITE_STUDIO_ENABLE_PREVIEW_MANUAL_DRAGGING"],
false,
),
).toBe(true);
expect(
resolveStudioBooleanEnvFlag(
{ VITE_STUDIO_ENABLE_MOTION_PANEL: "1" },
["VITE_STUDIO_ENABLE_MOTION_PANEL"],
false,
),
).toBe(true);
});
it("disables feature flags with explicit falsy env values", () => {
expect(
resolveStudioBooleanEnvFlag(
{ VITE_STUDIO_ENABLE_PREVIEW_MANUAL_DRAGGING: "off" },
["VITE_STUDIO_ENABLE_PREVIEW_MANUAL_DRAGGING"],
true,
),
).toBe(false);
expect(
resolveStudioBooleanEnvFlag(
{ VITE_STUDIO_ENABLE_MOTION_PANEL: "0" },
["VITE_STUDIO_ENABLE_MOTION_PANEL"],
true,
),
).toBe(false);
});
it("supports legacy flag aliases after the preferred name", () => {
expect(
resolveStudioBooleanEnvFlag(
{ VITE_STUDIO_PREVIEW_MANUAL_EDITING_ENABLED: "yes" },
[
"VITE_STUDIO_ENABLE_PREVIEW_MANUAL_DRAGGING",
"VITE_STUDIO_PREVIEW_MANUAL_EDITING_ENABLED",
],
false,
),
).toBe(true);
expect(
resolveStudioBooleanEnvFlag(
{ VITE_STUDIO_MOTION_PANEL_ENABLED: "enabled" },
["VITE_STUDIO_ENABLE_MOTION_PANEL", "VITE_STUDIO_MOTION_PANEL_ENABLED"],
false,
),
).toBe(true);
});
it("lets preferred flag values override legacy aliases", () => {
expect(
resolveStudioBooleanEnvFlag(
{
VITE_STUDIO_ENABLE_INSPECTOR_PANELS: "off",
VITE_STUDIO_INSPECTOR_PANELS_ENABLED: "on",
},
["VITE_STUDIO_ENABLE_INSPECTOR_PANELS", "VITE_STUDIO_INSPECTOR_PANELS_ENABLED"],
true,
),
).toBe(false);
});
it("falls back for missing, empty, or unknown env values", () => {
expect(resolveStudioBooleanEnvFlag({}, ["MISSING"], false)).toBe(false);
expect(resolveStudioBooleanEnvFlag({ EMPTY: "" }, ["EMPTY"], true)).toBe(true);
expect(resolveStudioBooleanEnvFlag({ UNKNOWN: "maybe" }, ["UNKNOWN"], false)).toBe(false);
});
it("defaults the flat inspector flag to true and honors an explicit override", async () => {
const on = await loadAvailabilityWithEnv({});
expect(on.STUDIO_FLAT_INSPECTOR_ENABLED).toBe(true);
const off = await loadAvailabilityWithEnv({
VITE_STUDIO_FLAT_INSPECTOR_ENABLED: "false",
});
expect(off.STUDIO_FLAT_INSPECTOR_ENABLED).toBe(false);
});
});