Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
Add a failing test and a code comment for a weird bug
Andrey Okonetchnikov3f5a0d0799dd
diff --git a/app/designer/features/props-panel/use-props-logic.test.ts b/app/designer/features/props-panel/use-props-logic.test.tsindex f43bb9debd..efe3a3ccb8 100644--- a/app/designer/features/props-panel/use-props-logic.test.ts+++ b/app/designer/features/props-panel/use-props-logic.test.ts@@ -37,6 +37,29 @@ describe("usePropsLogic", () => {});});+ test.only("should return different default props for different instances", () => {+ const { result: res1 } = renderHook(() =>+ usePropsLogic({+ selectedInstanceData: getSelectedInstanceData("Heading", []),+ publish: jest.fn(),+ })+ );+ const { result: res2 } = renderHook(() =>+ usePropsLogic({+ selectedInstanceData: getSelectedInstanceData("Button", []),+ publish: jest.fn(),+ })+ );+ expect(res1.current.userProps[0]).not.toMatchObject({+ prop: "type",+ value: "button",+ });+ expect(res2.current.userProps[0]).toMatchObject({+ prop: "type",+ value: "button",+ });+ });+test("should return props with defaultValue set", () => {const { result } = renderHook(() =>usePropsLogic({diff --git a/app/designer/features/props-panel/use-props-logic.ts b/app/designer/features/props-panel/use-props-logic.tsindex b476b51d64..fefe4c59b7 100644--- a/app/designer/features/props-panel/use-props-logic.ts+++ b/app/designer/features/props-panel/use-props-logic.ts@@ -34,6 +34,8 @@ const getRequiredProps = (}));};+// TODO: This returns same props for all instances.+// See the failing test in use-props-logic.test.tsconst getPropsWithDefaultValue = (selectedInstanceData: SelectedInstanceData): UserProp[] => {