fix: modal rename update references (#34855)
This commit is contained in:
parent
a4c394c995
commit
3767a62763
90
app/client/src/widgets/ModalWidget/widget/index.test.tsx
Normal file
90
app/client/src/widgets/ModalWidget/widget/index.test.tsx
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
import ModalWidget from ".";
|
||||
|
||||
describe("Modal Widget default Props check", () => {
|
||||
it("Check for icon and close button to have dynamicTriggerPathList as onClick key for modal references to update on rename", () => {
|
||||
const defaultModalProps = ModalWidget.getDefaults();
|
||||
|
||||
const modalWidgetCanvasChild: any = {
|
||||
type: "CANVAS_WIDGET",
|
||||
widgetName: "Canvas1",
|
||||
displayName: "Canvas",
|
||||
children: [
|
||||
{
|
||||
type: "TEXT_WIDGET",
|
||||
widgetName: "Text1",
|
||||
displayName: "Text",
|
||||
key: "41j4j00agt",
|
||||
widgetId: "TEXT_WIDGET_ID",
|
||||
parentId: "CANVAS_WIDGET_ID",
|
||||
children: [],
|
||||
},
|
||||
{
|
||||
type: "ICON_BUTTON_WIDGET",
|
||||
widgetName: "IconButton1",
|
||||
displayName: "Icon button",
|
||||
widgetId: "ICON_BUTTON_WIDGET_ID",
|
||||
parentId: "CANVAS_WIDGET_ID",
|
||||
children: [],
|
||||
},
|
||||
{
|
||||
type: "BUTTON_WIDGET",
|
||||
text: "Close",
|
||||
widgetName: "Button1",
|
||||
key: "8eyy97tgkp",
|
||||
widgetId: "BUTTON_WIDGET_ID",
|
||||
parentId: "CANVAS_WIDGET_ID",
|
||||
children: [],
|
||||
},
|
||||
{
|
||||
type: "BUTTON_WIDGET",
|
||||
text: "Confirm",
|
||||
widgetName: "Button2",
|
||||
key: "8eyy97tgkp",
|
||||
widgetId: "BUTTON_WIDGET_ID_2",
|
||||
parentId: "CANVAS_WIDGET_ID",
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
widgetId: "CANVAS_WIDGET_ID",
|
||||
parentId: "MODAL_WIDGET_ID",
|
||||
};
|
||||
|
||||
const modalWidget: any = {
|
||||
type: "MODAL_WIDGET",
|
||||
widgetName: "Modal1",
|
||||
children: [],
|
||||
displayName: "Modal",
|
||||
widgetId: "MODAL_WIDGET_ID",
|
||||
parentId: "0",
|
||||
dynamicHeight: "AUTO_HEIGHT",
|
||||
};
|
||||
|
||||
const iconData =
|
||||
defaultModalProps.blueprint.view[0].props.blueprint.operations[0].fn(
|
||||
modalWidgetCanvasChild,
|
||||
{},
|
||||
modalWidget,
|
||||
);
|
||||
|
||||
const closeButtonData =
|
||||
defaultModalProps.blueprint.view[0].props.blueprint.operations[1].fn(
|
||||
modalWidgetCanvasChild,
|
||||
{},
|
||||
modalWidget,
|
||||
);
|
||||
|
||||
expect(iconData).not.toBeUndefined();
|
||||
expect(iconData![1].propertyName).toContain("dynamicTriggerPathList");
|
||||
expect((iconData![1].propertyValue[0] as { key: string }).key).toContain(
|
||||
"onClick",
|
||||
);
|
||||
|
||||
expect(closeButtonData).not.toBeUndefined();
|
||||
expect(closeButtonData![1].propertyName).toContain(
|
||||
"dynamicTriggerPathList",
|
||||
);
|
||||
expect(
|
||||
(closeButtonData![1].propertyValue[0] as { key: string }).key,
|
||||
).toContain("onClick");
|
||||
});
|
||||
});
|
||||
|
|
@ -180,6 +180,11 @@ export class ModalWidget extends BaseWidget<ModalWidgetProps, WidgetState> {
|
|||
propertyName: "onClick",
|
||||
propertyValue: `{{closeModal(${parent.widgetName}.name);}}`,
|
||||
},
|
||||
{
|
||||
widgetId: iconChild.widgetId,
|
||||
propertyName: "dynamicTriggerPathList",
|
||||
propertyValue: [{ key: "onClick" }],
|
||||
},
|
||||
];
|
||||
}
|
||||
},
|
||||
|
|
@ -206,6 +211,11 @@ export class ModalWidget extends BaseWidget<ModalWidgetProps, WidgetState> {
|
|||
propertyName: "onClick",
|
||||
propertyValue: `{{closeModal(${parent.widgetName}.name);}}`,
|
||||
},
|
||||
{
|
||||
widgetId: cancelBtnChild.widgetId,
|
||||
propertyName: "dynamicTriggerPathList",
|
||||
propertyValue: [{ key: "onClick" }],
|
||||
},
|
||||
];
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user