mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-11 23:00:03 +00:00
* ci: run fallow audit in lefthook pre-commit Mirrors the same `fallow audit --base ... --fail-on-issues` check that runs in CI, but locally against HEAD so issues surface at commit time instead of after the push round-trip. Scoped to `packages/**` source files via the glob — non-code edits (README, docs, top-level configs) skip the hook entirely. Measured locally: ~5s in parallel with the existing lint/format/typecheck checks. Doesn't extend wall-clock time because typecheck (~11s) is the long pole, and lefthook runs commands in parallel. The default `--gate new-only` means inherited findings don't block the commit — same gate behavior as CI, so local pre-commit and PR audit agree. * refactor: delete orphan declarations flagged by fallow After fallow's auto-fix de-exports unused symbols, oxlint surfaces them as no-unused-vars. This PR deletes those orphan declarations outright. Biggest cleanup: studio/src/icons/SystemIcons.tsx shrinks from 132 to 57 lines — 33 unused icon wrappers and their phosphor-icon imports deleted. Other deletions across 14 more files covering paired getter/setters, helper functions, dead env constants, internal components with no callers, and cascading unused imports. Cascade-causing files held back for follow-up PRs: renderOrchestrator barrel of captureCost re-exports, telemetry/portUtils/remote barrels, Button.tsx + ui/index.ts (would orphan whole file), studioMotion type re-exports. Test plan: typecheck clean across 8 packages, oxlint + oxfmt clean, fallow audit exit 0 (remaining findings inherited), cli + studio vitest suites pass.
110 lines
3.5 KiB
TypeScript
110 lines
3.5 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 while motion stays opt-in", 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);
|
|
expect(availability.STUDIO_MOTION_PANEL_ENABLED).toBe(false);
|
|
});
|
|
|
|
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);
|
|
});
|
|
});
|