diff --git a/app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_Edit_spec.js b/app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_Edit_spec.js index aa86b788a3..32f675a51f 100644 --- a/app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_Edit_spec.js +++ b/app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_Edit_spec.js @@ -96,7 +96,7 @@ describe( force: true, }) .type( - "https://www.facebook.com/users/{{Button2.text}}?key=test&val={{Button2.text}}", + "http://host.docker.internal:5001/{{Button2.text}}?key=test&val={{Button2.text}}", { force: true, parseSpecialCharSequences: false }, ) .wait(3000) @@ -106,7 +106,7 @@ describe( .type("{enter}", { parseSpecialCharSequences: true }); cy.validateEvaluatedValue( - "https://www.facebook.com/users/Cancel?key=test&val=Cancel", + "http://host.docker.internal:5001/Cancel?key=test&val=Cancel", ); }); }, diff --git a/app/client/src/PluginActionEditor/components/PluginActionForm/PluginActionForm.tsx b/app/client/src/PluginActionEditor/components/PluginActionForm/PluginActionForm.tsx index db91b29b3a..66ab320a30 100644 --- a/app/client/src/PluginActionEditor/components/PluginActionForm/PluginActionForm.tsx +++ b/app/client/src/PluginActionEditor/components/PluginActionForm/PluginActionForm.tsx @@ -2,13 +2,18 @@ import React from "react"; import APIEditorForm from "./components/APIEditorForm"; import { Flex } from "@appsmith/ads"; import { useChangeActionCall } from "./hooks/useChangeActionCall"; +import { usePluginActionContext } from "../../PluginActionContext"; +import { UIComponentTypes } from "api/PluginApi"; const PluginActionForm = () => { useChangeActionCall(); + const { plugin } = usePluginActionContext(); return ( - + {plugin.uiComponent === UIComponentTypes.ApiEditorForm ? ( + + ) : null} ); }; diff --git a/app/client/src/PluginActionEditor/components/PluginActionForm/components/CommonEditorForm/hooks/useGetFormActionValues.ts b/app/client/src/PluginActionEditor/components/PluginActionForm/components/CommonEditorForm/hooks/useGetFormActionValues.ts index 1078d18282..da75a1482a 100644 --- a/app/client/src/PluginActionEditor/components/PluginActionForm/components/CommonEditorForm/hooks/useGetFormActionValues.ts +++ b/app/client/src/PluginActionEditor/components/PluginActionForm/components/CommonEditorForm/hooks/useGetFormActionValues.ts @@ -18,7 +18,7 @@ function useGetFormActionValues() { // In an unlikely scenario where form is not initialised, // return empty values to avoid form ui issues - if (!isAPIAction(formValues)) { + if (!formValues || !isAPIAction(formValues)) { return { actionHeaders: [], actionParams: [], diff --git a/app/client/src/PluginActionEditor/components/PluginActionResponse/PluginActionResponse.tsx b/app/client/src/PluginActionEditor/components/PluginActionResponse/PluginActionResponse.tsx index f20a395d4c..9359c8130f 100644 --- a/app/client/src/PluginActionEditor/components/PluginActionResponse/PluginActionResponse.tsx +++ b/app/client/src/PluginActionEditor/components/PluginActionResponse/PluginActionResponse.tsx @@ -57,7 +57,7 @@ function PluginActionResponse() { expandedHeight={`${ActionExecutionResizerHeight}px`} isCollapsed={!open} onSelect={updateSelectedResponseTab} - selectedTabKey={selectedTab || tabs[0].key} + selectedTabKey={selectedTab || tabs[0]?.key} tabs={tabs} /> diff --git a/app/client/src/widgets/BaseInputWidget/component/index.test.tsx b/app/client/src/widgets/BaseInputWidget/component/index.test.tsx new file mode 100644 index 0000000000..cde15763ba --- /dev/null +++ b/app/client/src/widgets/BaseInputWidget/component/index.test.tsx @@ -0,0 +1,53 @@ +import React from "react"; +import { render } from "@testing-library/react"; +import "@testing-library/jest-dom/extend-expect"; +import BaseInputComponent, { type BaseInputComponentProps } from "./index"; +import { ThemeProvider } from "styled-components"; +import { lightTheme } from "selectors/themeSelectors"; + +const renderBaseInputComponent = ( + props: Partial = {}, +) => { + const defaultProps: BaseInputComponentProps = { + value: "", + inputType: "TEXT", + inputHTMLType: "TEXT", + disabled: false, + isLoading: false, + compactMode: false, + isInvalid: false, + label: "Salary", + showError: false, + onValueChange: jest.fn(), + onFocusChange: jest.fn(), + widgetId: "test-widget", + rtl: true, + }; + + return render( + + + , + ); +}; + +describe("BaseInputComponent TestCases", () => { + test("1. Icon should be visible and aligned to the right when the input type is a number", () => { + const { container } = renderBaseInputComponent({ + inputType: "NUMBER", + inputHTMLType: "NUMBER", + value: "123", + onStep: jest.fn(), + rtl: false, + shouldUseLocale: true, + iconName: "add", + iconAlign: "right", + }); + + const numericInputIcon = container.getElementsByClassName( + "bp3-icon bp3-icon-add", + )[0]; + + expect(numericInputIcon).toBeInTheDocument(); + }); +}); diff --git a/app/client/src/widgets/BaseInputWidget/component/index.tsx b/app/client/src/widgets/BaseInputWidget/component/index.tsx index d898b5b73e..cbb7b21599 100644 --- a/app/client/src/widgets/BaseInputWidget/component/index.tsx +++ b/app/client/src/widgets/BaseInputWidget/component/index.tsx @@ -565,6 +565,7 @@ class BaseInputComponent extends React.Component< onKeyUp={this.onKeyUp} onValueChange={this.onNumberChange} placeholder={this.props.placeholder} + rightElement={this.getRightIcon()} stepSize={this.props.stepSize} value={this.props.value} {...conditionalProps} diff --git a/app/client/src/workers/Evaluation/handlers/jsLibrary.ts b/app/client/src/workers/Evaluation/handlers/jsLibrary.ts index bdf704f2ba..ce81c2d7bf 100644 --- a/app/client/src/workers/Evaluation/handlers/jsLibrary.ts +++ b/app/client/src/workers/Evaluation/handlers/jsLibrary.ts @@ -128,39 +128,31 @@ export async function installLibrary( // Find keys add that were installed to the global scope. const keysAfterInstallation = Object.keys(self); - const differentiatingKeys = difference( + let differentiatingKeys = difference( keysAfterInstallation, envKeysBeforeInstallation, ); - if ( - differentiatingKeys.length > 0 && - differentiatingKeys.includes("default") - ) { - // Changing default export to library specific name - const uniqueName = generateUniqueAccessor( - url, - takenAccessors, - takenNamesMap, - ); + // Changing default export to library specific name, if default exported + const uniqueName = generateUniqueAccessor( + url, + takenAccessors, + takenNamesMap, + ); - // mapping default functionality to library name accessor - self[uniqueName] = self["default"]; - // deleting the reference of default key from the self object - delete self["default"]; - // mapping all the references of differentiating keys from the self object to the self[uniqueName] key object - differentiatingKeys.map((key) => { - if (key !== "default") { - self[uniqueName][key] = self[key]; - // deleting the references from the self object - delete self[key]; - } - }); - // pushing the uniqueName to the accessor array - accessors.push(uniqueName); - } else { - accessors.push(...differentiatingKeys); - } + movetheDefaultExportedLibraryToAccessorKey( + differentiatingKeys, + uniqueName, + ); + + // Following the same process which was happening earlier + const keysAfterDefaultOperation = Object.keys(self); + + differentiatingKeys = difference( + keysAfterDefaultOperation, + envKeysBeforeInstallation, + ); + accessors.push(...differentiatingKeys); /** * Check the list of installed library to see if their values have changed. @@ -308,7 +300,18 @@ export async function loadLibraries( try { self.importScripts(url); const keysAfter = Object.keys(self); - const defaultAccessors = difference(keysAfter, keysBefore); + let defaultAccessors = difference(keysAfter, keysBefore); + + // Changing default export to library accessors name which was saved when it was installed, if default export present + movetheDefaultExportedLibraryToAccessorKey( + defaultAccessors, + accessors[0], + ); + + // Following the same process which was happening earlier + const keysAfterDefaultOperation = Object.keys(self); + + defaultAccessors = difference(keysAfterDefaultOperation, keysBefore); /** * Installing 2 different version of lodash tries to add the same accessor on the self object. Let take version a & b for example. @@ -447,3 +450,24 @@ export function flattenModule(module: Record) { return libModule; } + +// This function will update the self keys only when the diffAccessors has default included in it. +function movetheDefaultExportedLibraryToAccessorKey( + diffAccessors: string[], + uniqAccessor: string, +) { + if (diffAccessors.length > 0 && diffAccessors.includes("default")) { + // mapping default functionality to library name accessor + self[uniqAccessor] = self["default"]; + // deleting the reference of default key from the self object + delete self["default"]; + // mapping all the references of differentiating keys from the self object to the self[uniqAccessor] key object + diffAccessors.map((key) => { + if (key !== "default") { + self[uniqAccessor][key] = self[key]; + // deleting the references from the self object + delete self[key]; + } + }); + } +}