PromucFlow_constructor/app/client/src/sagas/PasteWidgetUtils/PasteWidgetUtils.test.ts

200 lines
5.8 KiB
TypeScript
Raw Normal View History

import type { FlattenedWidgetProps } from "WidgetProvider/constants";
fix: Refactor dynamic bindings in widgets during building block paste. (#34318) ## Description * This pull request refactors the function `handleButtonDynamicTriggerPathList` to `handleWidgetDynamicTriggerPathList` in order to make it more generic and handle dynamic trigger paths for all types of widgets. * Additionally, the pull request moves the function `handleIfParentIsListWidgetWhilePasting` out of `handleSpecificCasesWhilePasting` to handle compound cases where the parent of the current widget needs to be checked. * Improves the nested object value replacement logic in `PasteWidgetUtils`. Fixes #`Issue Number` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.Templates, @tag.Widget, @tag.Sanity" ### :mag: Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/9656587968> > Commit: 4b821787d7ab5ad302b458c726c632b1e43b49e4 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9656587968&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Templates, @tag.Widget, @tag.Sanity` <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Simplified handling of pasting widgets by consolidating functions. - Improved logic for handling widget pasting scenarios. - Reorganized function names for better clarity and consistency. - **Bug Fixes** - Enhanced the handling of widgets when their parent is a list widget during pasting. - **Tests** - Updated test cases to reflect changes in widget pasting logic and function names. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Jacques Ikot <jacquesikot@gmail.com>
2024-06-25 06:13:00 +00:00
import { klona } from "klona";
import {
accessNestedObjectValue,
handleJSONFormPropertiesListedInDynamicBindingPath,
fix: Refactor dynamic bindings in widgets during building block paste. (#34318) ## Description * This pull request refactors the function `handleButtonDynamicTriggerPathList` to `handleWidgetDynamicTriggerPathList` in order to make it more generic and handle dynamic trigger paths for all types of widgets. * Additionally, the pull request moves the function `handleIfParentIsListWidgetWhilePasting` out of `handleSpecificCasesWhilePasting` to handle compound cases where the parent of the current widget needs to be checked. * Improves the nested object value replacement logic in `PasteWidgetUtils`. Fixes #`Issue Number` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.Templates, @tag.Widget, @tag.Sanity" ### :mag: Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/9656587968> > Commit: 4b821787d7ab5ad302b458c726c632b1e43b49e4 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9656587968&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Templates, @tag.Widget, @tag.Sanity` <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Simplified handling of pasting widgets by consolidating functions. - Improved logic for handling widget pasting scenarios. - Reorganized function names for better clarity and consistency. - **Bug Fixes** - Enhanced the handling of widgets when their parent is a list widget during pasting. - **Tests** - Updated test cases to reflect changes in widget pasting logic and function names. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Jacques Ikot <jacquesikot@gmail.com>
2024-06-25 06:13:00 +00:00
handleWidgetDynamicBindingPathList,
handleWidgetDynamicPropertyPathList,
handleWidgetDynamicTriggerPathList,
} from ".";
describe("accessNestedObjectValue", () => {
it("1. should replace the old value with the new value in a nested object", () => {
const obj = {
foo: {
bar: {
baz: "oldValue",
},
},
};
const oldValue = "oldValue";
const newValue = "newValue";
accessNestedObjectValue(obj, "foo.bar.baz", oldValue, newValue);
expect(obj.foo.bar.baz).toEqual(newValue);
});
it("2. should not replace the value if it does not match the old value", () => {
const obj = {
foo: {
bar: {
baz: "value",
},
},
};
const oldValue = "oldValue";
const newValue = "newValue";
accessNestedObjectValue(obj, "foo.bar.baz", oldValue, newValue);
expect(obj.foo.bar.baz).toEqual("value");
});
it("3. should return undefined if the path does not exist in the object", () => {
const obj = {
foo: {
bar: {
baz: "value",
},
},
};
const oldValue = "oldValue";
const newValue = "newValue";
const result = accessNestedObjectValue(
obj,
"foo.bar.qux",
oldValue,
newValue,
);
expect(result).toBeUndefined();
});
fix: Update BuildingBlockSagas to handle nested object value replacement in queries (#34563) ## Description This pull request updates the BuildingBlockSagas module to handle nested object value replacement in queries. Previously, the module only replaced values at the top level of the object, but now it correctly handles nested values as well. This improves the accuracy and reliability of the queries. The changes include adding a new utility function, `accessNestedObjectValue`, which is used to access and update nested values in the `actionConfiguration` object. Additionally, the `updateWidgetsNameInNewQueries` function has been modified to use this utility function when replacing widget names in queries. Overall, these changes enhance the functionality of the BuildingBlockSagas module and ensure that queries are properly updated with the new widget names." Fixes #`Issue Number` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.Widget" ### :mag: Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/9698473149> > Commit: 6e82692e4cbf8d2e9630499006aa2e0f8adbfdd3 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9698473149&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Widget` <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Enhanced internal logic for updating nested object values in widget names. - **Tests** - Added new test case for handling `null` or `undefined` inputs in utility functions. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-06-28 03:17:45 +00:00
it("4. should work for null/undefined object", () => {
const obj = null;
const oldValue = "oldValue";
const newValue = "newValue";
const result = accessNestedObjectValue(
obj,
"foo.bar.qux",
oldValue,
newValue,
);
expect(result).toBeUndefined();
});
});
describe("handleJSONFormPropertiesListedInDynamicBindingPath", () => {
it("1. should replace the oldName with the newName in the dynamicBindingPathList of the widget", () => {
const widget = {
dynamicBindingPathList: [
{ key: "schema.__rootSchema__.property1" },
{ key: "defaultValue" },
{ key: "property3" },
],
defaultValue: "{{oldName.val}}",
schema: {
__rootSchema__: {
property1: "{{oldName.test}}",
},
},
};
const oldName = "oldName";
const newName = "newName";
handleJSONFormPropertiesListedInDynamicBindingPath(
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
widget as any as FlattenedWidgetProps,
oldName,
newName,
);
expect(widget.schema.__rootSchema__.property1).toEqual("{{newName.test}}");
expect(widget.defaultValue).toEqual("{{newName.val}}");
expect(widget.dynamicBindingPathList).toEqual([
{ key: "schema.__rootSchema__.property1" },
{ key: "defaultValue" },
{ key: "property3" },
]);
});
});
fix: Handles button binding during buildingblock pasting (#33674) ## Description This pull request adds the handleButtonDynamicTriggerPathList function to the BuildingBlockAdditionSagas.ts file. This function is responsible for handling the dynamic trigger path list for button widgets. It iterates over the widgetNameMap and updates the dynamicTriggerPathList of each button widget with the newWidgetName. Additionally, unit tests have been added to ensure the correct functionality of the handleButtonDynamicTriggerPathList function. This change improves the functionality of button widgets when pasting building block widgets. Fixes #33658 _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.Widget" ### :mag: Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/9268894716> > Commit: a675a5c8a752fea76c130e8bdc1b76e44453ee98 > Cypress dashboard url: <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9268894716&attempt=1" target="_blank">Click here!</a> <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No --------- Co-authored-by: Ashok Kumar M <35134347+marks0351@users.noreply.github.com>
2024-05-29 04:09:39 +00:00
fix: Refactor dynamic bindings in widgets during building block paste. (#34318) ## Description * This pull request refactors the function `handleButtonDynamicTriggerPathList` to `handleWidgetDynamicTriggerPathList` in order to make it more generic and handle dynamic trigger paths for all types of widgets. * Additionally, the pull request moves the function `handleIfParentIsListWidgetWhilePasting` out of `handleSpecificCasesWhilePasting` to handle compound cases where the parent of the current widget needs to be checked. * Improves the nested object value replacement logic in `PasteWidgetUtils`. Fixes #`Issue Number` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.Templates, @tag.Widget, @tag.Sanity" ### :mag: Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/9656587968> > Commit: 4b821787d7ab5ad302b458c726c632b1e43b49e4 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9656587968&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Templates, @tag.Widget, @tag.Sanity` <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Simplified handling of pasting widgets by consolidating functions. - Improved logic for handling widget pasting scenarios. - Reorganized function names for better clarity and consistency. - **Bug Fixes** - Enhanced the handling of widgets when their parent is a list widget during pasting. - **Tests** - Updated test cases to reflect changes in widget pasting logic and function names. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Jacques Ikot <jacquesikot@gmail.com>
2024-06-25 06:13:00 +00:00
describe("handleWidgetDynamicTriggerPathList", () => {
fix: Handles button binding during buildingblock pasting (#33674) ## Description This pull request adds the handleButtonDynamicTriggerPathList function to the BuildingBlockAdditionSagas.ts file. This function is responsible for handling the dynamic trigger path list for button widgets. It iterates over the widgetNameMap and updates the dynamicTriggerPathList of each button widget with the newWidgetName. Additionally, unit tests have been added to ensure the correct functionality of the handleButtonDynamicTriggerPathList function. This change improves the functionality of button widgets when pasting building block widgets. Fixes #33658 _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.Widget" ### :mag: Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/9268894716> > Commit: a675a5c8a752fea76c130e8bdc1b76e44453ee98 > Cypress dashboard url: <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9268894716&attempt=1" target="_blank">Click here!</a> <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No --------- Co-authored-by: Ashok Kumar M <35134347+marks0351@users.noreply.github.com>
2024-05-29 04:09:39 +00:00
const widget = {
dynamicTriggerPathList: [{ key: "onClick" }],
onClick: "{{oldName.val}}",
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
fix: Handles button binding during buildingblock pasting (#33674) ## Description This pull request adds the handleButtonDynamicTriggerPathList function to the BuildingBlockAdditionSagas.ts file. This function is responsible for handling the dynamic trigger path list for button widgets. It iterates over the widgetNameMap and updates the dynamicTriggerPathList of each button widget with the newWidgetName. Additionally, unit tests have been added to ensure the correct functionality of the handleButtonDynamicTriggerPathList function. This change improves the functionality of button widgets when pasting building block widgets. Fixes #33658 _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.Widget" ### :mag: Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/9268894716> > Commit: a675a5c8a752fea76c130e8bdc1b76e44453ee98 > Cypress dashboard url: <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9268894716&attempt=1" target="_blank">Click here!</a> <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No --------- Co-authored-by: Ashok Kumar M <35134347+marks0351@users.noreply.github.com>
2024-05-29 04:09:39 +00:00
} as any as FlattenedWidgetProps;
it("1. should replace old widget names with new widget names in dynamic trigger paths", () => {
const widgetNameMap = {
oldName: "newName",
};
const button = klona(widget);
fix: Refactor dynamic bindings in widgets during building block paste. (#34318) ## Description * This pull request refactors the function `handleButtonDynamicTriggerPathList` to `handleWidgetDynamicTriggerPathList` in order to make it more generic and handle dynamic trigger paths for all types of widgets. * Additionally, the pull request moves the function `handleIfParentIsListWidgetWhilePasting` out of `handleSpecificCasesWhilePasting` to handle compound cases where the parent of the current widget needs to be checked. * Improves the nested object value replacement logic in `PasteWidgetUtils`. Fixes #`Issue Number` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.Templates, @tag.Widget, @tag.Sanity" ### :mag: Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/9656587968> > Commit: 4b821787d7ab5ad302b458c726c632b1e43b49e4 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9656587968&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Templates, @tag.Widget, @tag.Sanity` <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Simplified handling of pasting widgets by consolidating functions. - Improved logic for handling widget pasting scenarios. - Reorganized function names for better clarity and consistency. - **Bug Fixes** - Enhanced the handling of widgets when their parent is a list widget during pasting. - **Tests** - Updated test cases to reflect changes in widget pasting logic and function names. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Jacques Ikot <jacquesikot@gmail.com>
2024-06-25 06:13:00 +00:00
handleWidgetDynamicTriggerPathList(widgetNameMap, button);
expect(button.onClick).toEqual("{{newName.val}}");
});
it("2. should do nothing if the widgetNameMap does not contain names in dynamic trigger paths", () => {
const widgetNameMap = {
oldWidget1: "newWidget1",
};
const button = klona(widget);
handleWidgetDynamicTriggerPathList(widgetNameMap, button);
expect(button.onClick).toEqual("{{oldName.val}}");
});
});
describe("handleWidgetDynamicBindingPathList", () => {
const widget = {
dynamicBindingPathList: [{ key: "onClick" }],
onClick: "{{oldName.val}}",
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
fix: Refactor dynamic bindings in widgets during building block paste. (#34318) ## Description * This pull request refactors the function `handleButtonDynamicTriggerPathList` to `handleWidgetDynamicTriggerPathList` in order to make it more generic and handle dynamic trigger paths for all types of widgets. * Additionally, the pull request moves the function `handleIfParentIsListWidgetWhilePasting` out of `handleSpecificCasesWhilePasting` to handle compound cases where the parent of the current widget needs to be checked. * Improves the nested object value replacement logic in `PasteWidgetUtils`. Fixes #`Issue Number` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.Templates, @tag.Widget, @tag.Sanity" ### :mag: Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/9656587968> > Commit: 4b821787d7ab5ad302b458c726c632b1e43b49e4 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9656587968&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Templates, @tag.Widget, @tag.Sanity` <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Simplified handling of pasting widgets by consolidating functions. - Improved logic for handling widget pasting scenarios. - Reorganized function names for better clarity and consistency. - **Bug Fixes** - Enhanced the handling of widgets when their parent is a list widget during pasting. - **Tests** - Updated test cases to reflect changes in widget pasting logic and function names. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Jacques Ikot <jacquesikot@gmail.com>
2024-06-25 06:13:00 +00:00
} as any as FlattenedWidgetProps;
it("1. should replace old widget names with new widget names in dynamic trigger paths", () => {
const widgetNameMap = {
oldName: "newName",
};
const button = klona(widget);
handleWidgetDynamicBindingPathList(widgetNameMap, button);
expect(button.onClick).toEqual("{{newName.val}}");
});
it("2. should do nothing if the widgetNameMap does not contain names in dynamic trigger paths", () => {
const widgetNameMap = {
oldWidget1: "newWidget1",
};
const button = klona(widget);
handleWidgetDynamicBindingPathList(widgetNameMap, button);
expect(button.onClick).toEqual("{{oldName.val}}");
});
});
describe("handleWidgetDynamicPropertyPathList", () => {
const widget = {
dynamicPropertyPathList: [{ key: "onClick" }],
onClick: "{{oldName.val}}",
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
fix: Refactor dynamic bindings in widgets during building block paste. (#34318) ## Description * This pull request refactors the function `handleButtonDynamicTriggerPathList` to `handleWidgetDynamicTriggerPathList` in order to make it more generic and handle dynamic trigger paths for all types of widgets. * Additionally, the pull request moves the function `handleIfParentIsListWidgetWhilePasting` out of `handleSpecificCasesWhilePasting` to handle compound cases where the parent of the current widget needs to be checked. * Improves the nested object value replacement logic in `PasteWidgetUtils`. Fixes #`Issue Number` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.Templates, @tag.Widget, @tag.Sanity" ### :mag: Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/9656587968> > Commit: 4b821787d7ab5ad302b458c726c632b1e43b49e4 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9656587968&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Templates, @tag.Widget, @tag.Sanity` <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Simplified handling of pasting widgets by consolidating functions. - Improved logic for handling widget pasting scenarios. - Reorganized function names for better clarity and consistency. - **Bug Fixes** - Enhanced the handling of widgets when their parent is a list widget during pasting. - **Tests** - Updated test cases to reflect changes in widget pasting logic and function names. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Jacques Ikot <jacquesikot@gmail.com>
2024-06-25 06:13:00 +00:00
} as any as FlattenedWidgetProps;
it("1. should replace old widget names with new widget names in dynamic trigger paths", () => {
const widgetNameMap = {
oldName: "newName",
};
const button = klona(widget);
handleWidgetDynamicPropertyPathList(widgetNameMap, button);
fix: Handles button binding during buildingblock pasting (#33674) ## Description This pull request adds the handleButtonDynamicTriggerPathList function to the BuildingBlockAdditionSagas.ts file. This function is responsible for handling the dynamic trigger path list for button widgets. It iterates over the widgetNameMap and updates the dynamicTriggerPathList of each button widget with the newWidgetName. Additionally, unit tests have been added to ensure the correct functionality of the handleButtonDynamicTriggerPathList function. This change improves the functionality of button widgets when pasting building block widgets. Fixes #33658 _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.Widget" ### :mag: Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/9268894716> > Commit: a675a5c8a752fea76c130e8bdc1b76e44453ee98 > Cypress dashboard url: <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9268894716&attempt=1" target="_blank">Click here!</a> <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No --------- Co-authored-by: Ashok Kumar M <35134347+marks0351@users.noreply.github.com>
2024-05-29 04:09:39 +00:00
expect(button.onClick).toEqual("{{newName.val}}");
});
it("2. should do nothing if the widgetNameMap does not contain names in dynamic trigger paths", () => {
const widgetNameMap = {
oldWidget1: "newWidget1",
};
const button = klona(widget);
fix: Refactor dynamic bindings in widgets during building block paste. (#34318) ## Description * This pull request refactors the function `handleButtonDynamicTriggerPathList` to `handleWidgetDynamicTriggerPathList` in order to make it more generic and handle dynamic trigger paths for all types of widgets. * Additionally, the pull request moves the function `handleIfParentIsListWidgetWhilePasting` out of `handleSpecificCasesWhilePasting` to handle compound cases where the parent of the current widget needs to be checked. * Improves the nested object value replacement logic in `PasteWidgetUtils`. Fixes #`Issue Number` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.Templates, @tag.Widget, @tag.Sanity" ### :mag: Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/9656587968> > Commit: 4b821787d7ab5ad302b458c726c632b1e43b49e4 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9656587968&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Templates, @tag.Widget, @tag.Sanity` <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Simplified handling of pasting widgets by consolidating functions. - Improved logic for handling widget pasting scenarios. - Reorganized function names for better clarity and consistency. - **Bug Fixes** - Enhanced the handling of widgets when their parent is a list widget during pasting. - **Tests** - Updated test cases to reflect changes in widget pasting logic and function names. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Jacques Ikot <jacquesikot@gmail.com>
2024-06-25 06:13:00 +00:00
handleWidgetDynamicPropertyPathList(widgetNameMap, button);
fix: Handles button binding during buildingblock pasting (#33674) ## Description This pull request adds the handleButtonDynamicTriggerPathList function to the BuildingBlockAdditionSagas.ts file. This function is responsible for handling the dynamic trigger path list for button widgets. It iterates over the widgetNameMap and updates the dynamicTriggerPathList of each button widget with the newWidgetName. Additionally, unit tests have been added to ensure the correct functionality of the handleButtonDynamicTriggerPathList function. This change improves the functionality of button widgets when pasting building block widgets. Fixes #33658 _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.Widget" ### :mag: Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/9268894716> > Commit: a675a5c8a752fea76c130e8bdc1b76e44453ee98 > Cypress dashboard url: <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9268894716&attempt=1" target="_blank">Click here!</a> <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No --------- Co-authored-by: Ashok Kumar M <35134347+marks0351@users.noreply.github.com>
2024-05-29 04:09:39 +00:00
expect(button.onClick).toEqual("{{oldName.val}}");
});
});