PromucFlow_constructor/app/client/src/utils/AppsmithUtils.test.ts

130 lines
3.5 KiB
TypeScript
Raw Normal View History

fix: Include port number while constructing blob url in camera widget and plugin action execution (#22458) ## Description While creating a blob URL we should consider the port number where the Appsmith is running. This PR adds the port number to the blob URL. Fixes https://github.com/appsmithorg/appsmith/issues/22387 ## Type of change > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Provide instructions, so we can reproduce. > Please also list any relevant details for your test configuration. > Delete anything that is not important - Manual - Cypress ### Test Plan > Add Testsmith test cases links that relate to this PR ### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test
2023-04-19 18:29:56 +00:00
import {
areArraysEqual,
createBlobUrl,
chore: Address misc one click binding feedbacks (#24735) ## Description Fixes miscellaneous feedback in the one-click binding feature. - Order of queries - show select queries on top and order by last executed query - Converting from JS to dropdown should be possible for the following cases - {{Query.data}} - Improve query names to be generated using the data table or collection we use - undefined table data value should show an error on the property pane - Download option should be disabled when table is generated using one click binding - Remove the insert binding option from the dropdown #### PR fixes following issue(s) Fixes https://github.com/appsmithorg/appsmith/issues/24605 > if no issue exists, please create an issue and ask the maintainers about this first > > #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### Type of change > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Breaking change (fix or feature that would cause existing functionality to not work as expected) - Chore (housekeeping or task changes that don't impact user perception) - This change requires a documentation update > > > ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [x] Manual - [x] Jest - [x] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
2023-06-29 13:53:25 +00:00
DataType,
fix: Include port number while constructing blob url in camera widget and plugin action execution (#22458) ## Description While creating a blob URL we should consider the port number where the Appsmith is running. This PR adds the port number to the blob URL. Fixes https://github.com/appsmithorg/appsmith/issues/22387 ## Type of change > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Provide instructions, so we can reproduce. > Please also list any relevant details for your test configuration. > Delete anything that is not important - Manual - Cypress ### Test Plan > Add Testsmith test cases links that relate to this PR ### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test
2023-04-19 18:29:56 +00:00
getCamelCaseString,
chore: Address misc one click binding feedbacks (#24735) ## Description Fixes miscellaneous feedback in the one-click binding feature. - Order of queries - show select queries on top and order by last executed query - Converting from JS to dropdown should be possible for the following cases - {{Query.data}} - Improve query names to be generated using the data table or collection we use - undefined table data value should show an error on the property pane - Download option should be disabled when table is generated using one click binding - Remove the insert binding option from the dropdown #### PR fixes following issue(s) Fixes https://github.com/appsmithorg/appsmith/issues/24605 > if no issue exists, please create an issue and ask the maintainers about this first > > #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### Type of change > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Breaking change (fix or feature that would cause existing functionality to not work as expected) - Chore (housekeeping or task changes that don't impact user perception) - This change requires a documentation update > > > ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [x] Manual - [x] Jest - [x] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
2023-06-29 13:53:25 +00:00
getDatatype,
fix: Include port number while constructing blob url in camera widget and plugin action execution (#22458) ## Description While creating a blob URL we should consider the port number where the Appsmith is running. This PR adds the port number to the blob URL. Fixes https://github.com/appsmithorg/appsmith/issues/22387 ## Type of change > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Provide instructions, so we can reproduce. > Please also list any relevant details for your test configuration. > Delete anything that is not important - Manual - Cypress ### Test Plan > Add Testsmith test cases links that relate to this PR ### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test
2023-04-19 18:29:56 +00:00
parseBlobUrl,
} from "utils/AppsmithUtils";
import { isURL } from "./TypeHelpers";
feat: Switch Group widget (#7590) * Feat: Switch Group Widget -- The first MVP of the widget * feat: Switch Group Widget -- Follow the same config and implementation as the other group widgets * feat: Switch Group Widget -- Elaborate the help text for defaultSelectedValues * feat: Switch Group Widget -- Add a widget icon * feat: Switch Group Widget -- Remove unnecessary property control at ItemsControl.tsx -- Refactor some code snippets for higher code quality -- Add basic cypress test cases * fix: icon for the widget optimised & replaced * feat: Switch Group Widget -- Add a unit test for defaultSelectedValuesValidation * feat: Switch Group Widget -- Make the validation type for defaultSelectedValues property to ValidationTypes.ARRAY -- Remove original validation function and its unit test * feat: Switch Group Widget -- Fix on typo -- Fix on formatting issue -- Change the help text for isRequired property * feat: Switch Group Widget -- Revert help text for isRequired property to the original one * feat: Switch Group Widget -- Set strict property to true on defaultSelectedValues * feat: Switch group widget -- Refactor utility function, getCamelCaseString -- Add the corresponding test case * feat: Switch group widget -- Implement options property as a plain JS field -- Reimplement update logic for selectedValues when options changes -- Add a new utility function for checking equality of object arrays -- Add a unit test for the above function -- Rewrite the corresponding Cypress test cases * feat: Switch Group Widget -- Remove isArrayEqual utility function and directly use functions from lodash * feat: Swtich Group Widget -- Make selectedValues as a derived property * feat: Switch Group Widget -- Replace the widget icon * feat: Switch Group Widget -- Rewrite a test case for onSelectionChange property * feat: Switch Group Widget -- Remove redundant calls for openPropertyPane * feat: Switch Group Widget -- Remove closePropertyPane call from afterEach hook * feat: Switch Group Widget -- Change the selector for every switch element in onSelectionChange test case * feat: Switch Group Widget -- Fix on failed Cypress test case, adding closePropertyPane command to onSelectionChange * feat: Switch Group Widget -- Remove template literal from a selector * feat: Switch Group Widget -- Make click on onSelectionChange test case forced * feat: Switch Group Widget -- Fix on crash issue when editing on Options property * feat: Switch Group Widget -- Add the widget icon to show in entity explorer * feat: Switch Group Widget -- Fix on blue color on mouse down -- Add a new property for alignment Co-authored-by: somangshu <somangshu.goswami1508@gmail.com>
2021-12-09 12:02:47 +00:00
describe("getCamelCaseString", () => {
it("Should return a string in camelCase", () => {
const inputs = ["abcd", "ab12cd", "开关", "😃 😃 😃"];
const expected = ["abcd", "ab12Cd", "", ""];
inputs.forEach((input, index) => {
const result = getCamelCaseString(input);
expect(result).toStrictEqual(expected[index]);
});
});
});
perf: Widget re-rendering refactor (#14485) * initial commit * props hoc * changes * removed ignores and withWidgetProps * added extra props to canvasStructure * widget props changes * list widget changes * reintroduced widget props hook and other refactors * remove warnings * added deepequal for childWidgets selector * fix global hotkeys and tabs widget jest test * fix main container test fix * fixed view mode width * fix form widget values * minor fix * fix skeleton * form widget validity fix * jest test fix * fixed tests: GlobalHotkeys, Tabs, CanvasSelectectionArena and fixed main container rendering * minor fix * minor comments * reverted commented code * simplified structure, selective redux state updates and other inconsistencies * fix junit test cases * stop form widget from force rendering children * fix test case * random commit to re run tests * update isFormValid prop only if it exists * detangling circular dependency * fixing cypress tests * cleaned up code * clean up man cnavas props and fix jest cases * fix rendering order of child widgets for canvas * fix dropdown reset spec * adding comments * cleaning up unwanted code * fix multiselect widget on deploy * adressing review comments * addressing minor review comment changes * destructuring modal widget child and fix test case * fix communityIssues cypress spec * rewrite isVisible logic to match previous behaviour * merging widget props with component props before checking isVisible * adressing review comments for modal widget's isVisible Co-authored-by: rahulramesha <rahul@appsmith.com>
2022-08-19 10:10:36 +00:00
describe("test areArraysEqual", () => {
it("test areArraysEqual method", () => {
const OGArray = ["test1", "test2", "test3"];
let testArray: string[] = [];
expect(areArraysEqual(OGArray, testArray)).toBe(false);
testArray = ["test1", "test3"];
expect(areArraysEqual(OGArray, testArray)).toBe(false);
testArray = ["test1", "test2", "test3"];
expect(areArraysEqual(OGArray, testArray)).toBe(true);
testArray = ["test1", "test3", "test2"];
expect(areArraysEqual(OGArray, testArray)).toBe(true);
});
});
describe("isURL", () => {
test("returns true for valid URLs", () => {
expect(isURL("http://example.com")).toBe(true);
expect(isURL("https://www.google.com/search?q=javascript")).toBe(true);
expect(isURL("https://en.wikipedia.org/wiki/Regular_expression")).toBe(
true,
);
expect(
isURL("https://www.example.com/path(withparentheses)/file.html"),
).toBe(true);
expect(
isURL("https://www.example.com/path[withparentheses]/file_(1)[2].html"),
).toBe(true);
});
test("returns false for invalid URLs", () => {
expect(isURL("http://localhost:3000")).toBe(false);
expect(isURL("not a URL")).toBe(false);
expect(isURL("ftp:/example.com")).toBe(false);
expect(isURL("http://example.")).toBe(false);
expect(isURL("http://localhost:port")).toBe(false);
expect(isURL("notAURL")).toBe(false);
expect(isURL("httpsnotAURL")).toBe(false);
});
});
fix: Include port number while constructing blob url in camera widget and plugin action execution (#22458) ## Description While creating a blob URL we should consider the port number where the Appsmith is running. This PR adds the port number to the blob URL. Fixes https://github.com/appsmithorg/appsmith/issues/22387 ## Type of change > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Provide instructions, so we can reproduce. > Please also list any relevant details for your test configuration. > Delete anything that is not important - Manual - Cypress ### Test Plan > Add Testsmith test cases links that relate to this PR ### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test
2023-04-19 18:29:56 +00:00
describe("createBlobUrl", () => {
beforeEach(() => {
URL.createObjectURL = jest
.fn()
.mockReturnValue(`blob:${window.location.origin}/123-123-123-123-123`);
});
it("should test that it created correct blob URL", () => {
expect(createBlobUrl(new Blob(), "base64")).toMatch(
/blob:[a-z0-9-]*\?type=base64/,
);
expect(createBlobUrl(new Blob(), "raw")).toMatch(
/blob:[a-z0-9-]*\?type=raw/,
);
});
});
describe("parseBlobUrl", () => {
it("should test that it created correct blob URL", () => {
expect(parseBlobUrl("blob:123-123?type=base")).toEqual([
`blob:${window.location.origin}/123-123`,
"base",
]);
expect(parseBlobUrl("blob:123-123?type=raw")).toEqual([
`blob:${window.location.origin}/123-123`,
"raw",
]);
});
});
chore: Address misc one click binding feedbacks (#24735) ## Description Fixes miscellaneous feedback in the one-click binding feature. - Order of queries - show select queries on top and order by last executed query - Converting from JS to dropdown should be possible for the following cases - {{Query.data}} - Improve query names to be generated using the data table or collection we use - undefined table data value should show an error on the property pane - Download option should be disabled when table is generated using one click binding - Remove the insert binding option from the dropdown #### PR fixes following issue(s) Fixes https://github.com/appsmithorg/appsmith/issues/24605 > if no issue exists, please create an issue and ask the maintainers about this first > > #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### Type of change > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Breaking change (fix or feature that would cause existing functionality to not work as expected) - Chore (housekeeping or task changes that don't impact user perception) - This change requires a documentation update > > > ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [x] Manual - [x] Jest - [x] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
2023-06-29 13:53:25 +00:00
describe("getDatatype - should test the datatypes", () => {
it("1. String", () => {
expect(getDatatype("test")).toBe(DataType.STRING);
});
it("2. Number", () => {
[1, NaN].forEach((d) => {
expect(getDatatype(d)).toBe(DataType.NUMBER);
});
});
it("3. Boolean", () => {
[true, false].forEach((d) => {
expect(getDatatype(d)).toBe(DataType.BOOLEAN);
});
});
it("4. Object", () => {
expect(getDatatype({})).toBe(DataType.OBJECT);
});
it("5. Array", () => {
expect(getDatatype([])).toBe(DataType.ARRAY);
});
it("6. Rest of the types", () => {
expect(getDatatype(null)).toBe(DataType.NULL);
expect(getDatatype(undefined)).toBe(DataType.UNDEFINED);
});
});