mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-07 18:26:17 +00:00
feat(studio): non-destructive crop + cross-project asset view
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
buildInsetClipPathSides,
|
||||
buildStrokeStyleUpdates,
|
||||
buildStrokeWidthStyleUpdates,
|
||||
getClipPathInsetPx,
|
||||
@@ -7,6 +8,7 @@ import {
|
||||
inferBoxShadowPreset,
|
||||
inferClipPathPreset,
|
||||
normalizePanelPxValue,
|
||||
parseInsetClipPathSides,
|
||||
setCssFilterFunctionPx,
|
||||
} from "./PropertyPanel";
|
||||
|
||||
@@ -49,6 +51,52 @@ describe("PropertyPanel style helpers", () => {
|
||||
expect(getClipPathInsetPx("circle(50% at 50% 50%)")).toBe(0);
|
||||
});
|
||||
|
||||
it("builds and parses 4-side inset clip paths without losing radius", () => {
|
||||
expect(buildInsetClipPathSides({ top: 10, right: 20, bottom: 30, left: 40 }, 6)).toBe(
|
||||
"inset(10px 20px 30px 40px round 6px)",
|
||||
);
|
||||
expect(parseInsetClipPathSides("inset(10px 20px 30px 40px round 6px)")).toEqual({
|
||||
top: 10,
|
||||
right: 20,
|
||||
bottom: 30,
|
||||
left: 40,
|
||||
radius: 6,
|
||||
});
|
||||
});
|
||||
|
||||
it("emits the single-value inset form when all sides are equal", () => {
|
||||
expect(buildInsetClipPathSides({ top: 12.5, right: 12.5, bottom: 12.5, left: 12.5 })).toBe(
|
||||
"inset(12.5px)",
|
||||
);
|
||||
expect(parseInsetClipPathSides("inset(12.5px)")).toEqual({
|
||||
top: 12.5,
|
||||
right: 12.5,
|
||||
bottom: 12.5,
|
||||
left: 12.5,
|
||||
radius: 0,
|
||||
});
|
||||
expect(getClipPathInsetPx("inset(12.5px 12.5px 12.5px 12.5px)")).toBe(12.5);
|
||||
});
|
||||
|
||||
it("accepts CSS shorthand inset values and rejects unsupported clip paths", () => {
|
||||
expect(parseInsetClipPathSides("inset(10px 20px)")).toEqual({
|
||||
top: 10,
|
||||
right: 20,
|
||||
bottom: 10,
|
||||
left: 20,
|
||||
radius: 0,
|
||||
});
|
||||
expect(parseInsetClipPathSides("inset(10px 20px 30px)")).toEqual({
|
||||
top: 10,
|
||||
right: 20,
|
||||
bottom: 30,
|
||||
left: 20,
|
||||
radius: 0,
|
||||
});
|
||||
expect(parseInsetClipPathSides("inset(10%)")).toBeNull();
|
||||
expect(parseInsetClipPathSides("circle(50% at 50% 50%)")).toBeNull();
|
||||
});
|
||||
|
||||
it("keeps stroke width and style edits visually effective", () => {
|
||||
expect(buildStrokeWidthStyleUpdates("3px", "none")).toEqual([
|
||||
["border-width", "3px"],
|
||||
|
||||
Reference in New Issue
Block a user