2022-04-12 10:50:01 +00:00
|
|
|
import * as generators from "utils/generators";
|
2021-09-09 15:10:22 +00:00
|
|
|
import { RenderModes } from "constants/WidgetConstants";
|
2021-05-18 13:54:40 +00:00
|
|
|
import {
|
|
|
|
|
migrateChartDataFromArrayToObject,
|
2021-05-18 18:29:39 +00:00
|
|
|
migrateToNewLayout,
|
2021-05-18 13:54:40 +00:00
|
|
|
migrateInitialValues,
|
2021-08-03 06:38:01 +00:00
|
|
|
migrateToNewMultiSelect,
|
2021-09-09 15:10:22 +00:00
|
|
|
} from "./DSLMigrations";
|
2021-05-18 18:29:39 +00:00
|
|
|
import {
|
|
|
|
|
buildChildren,
|
2021-05-28 02:58:02 +00:00
|
|
|
widgetCanvasFactory,
|
2021-05-18 18:29:39 +00:00
|
|
|
buildDslWithChildren,
|
|
|
|
|
} from "test/factories/WidgetFactoryUtils";
|
|
|
|
|
import { cloneDeep } from "lodash";
|
2023-09-06 12:15:04 +00:00
|
|
|
import { GRID_DENSITY_MIGRATION_V1 } from "WidgetProvider/constants";
|
2022-04-01 14:57:03 +00:00
|
|
|
import {
|
|
|
|
|
extractCurrentDSL,
|
|
|
|
|
getDraggingSpacesFromBlocks,
|
2022-04-13 14:57:44 +00:00
|
|
|
getMousePositionsOnCanvas,
|
2022-04-01 14:57:03 +00:00
|
|
|
} from "./WidgetPropsUtils";
|
2023-09-11 15:55:11 +00:00
|
|
|
import type { WidgetDraggingBlock } from "layoutSystems/common/CanvasArenas/ArenaTypes";
|
2023-04-10 07:02:31 +00:00
|
|
|
import { ASSETS_CDN_URL } from "constants/ThirdPartyConstants";
|
2021-04-26 10:35:59 +00:00
|
|
|
|
|
|
|
|
describe("WidgetProps tests", () => {
|
2022-04-01 14:57:03 +00:00
|
|
|
it("should convert WidgetDraggingBlocks to occupied Spaces", () => {
|
|
|
|
|
const draggingBlocks: WidgetDraggingBlock[] = [
|
|
|
|
|
{
|
|
|
|
|
left: 100,
|
|
|
|
|
top: 100,
|
|
|
|
|
width: 210,
|
|
|
|
|
height: 220,
|
|
|
|
|
widgetId: "1",
|
|
|
|
|
isNotColliding: true,
|
|
|
|
|
columnWidth: 10,
|
|
|
|
|
rowHeight: 10,
|
2023-03-04 07:25:54 +00:00
|
|
|
type: "",
|
2022-04-01 14:57:03 +00:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
left: 310,
|
|
|
|
|
top: 120,
|
|
|
|
|
width: 70,
|
|
|
|
|
height: 80,
|
|
|
|
|
widgetId: "2",
|
|
|
|
|
isNotColliding: true,
|
|
|
|
|
columnWidth: 10,
|
|
|
|
|
rowHeight: 10,
|
2023-03-04 07:25:54 +00:00
|
|
|
type: "",
|
2022-04-01 14:57:03 +00:00
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
const draggingSpaces = [
|
|
|
|
|
{
|
|
|
|
|
left: 10,
|
|
|
|
|
top: 10,
|
|
|
|
|
right: 31,
|
|
|
|
|
bottom: 32,
|
|
|
|
|
id: "1",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
left: 31,
|
|
|
|
|
top: 12,
|
|
|
|
|
right: 38,
|
|
|
|
|
bottom: 20,
|
|
|
|
|
id: "2",
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
const snapColumnSpace = 10,
|
|
|
|
|
snapRowSpace = 10;
|
|
|
|
|
|
|
|
|
|
expect(
|
|
|
|
|
getDraggingSpacesFromBlocks(
|
|
|
|
|
draggingBlocks,
|
|
|
|
|
snapColumnSpace,
|
|
|
|
|
snapRowSpace,
|
|
|
|
|
),
|
|
|
|
|
).toEqual(draggingSpaces);
|
|
|
|
|
});
|
2022-04-13 14:57:44 +00:00
|
|
|
it("getMousePositionsOnCanvas should Return Mouse Position relative to Canvas", () => {
|
|
|
|
|
const gridProps = {
|
|
|
|
|
parentColumnSpace: 10,
|
|
|
|
|
parentRowSpace: 10,
|
|
|
|
|
maxGridColumns: 64,
|
|
|
|
|
};
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### 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
- [ ] 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
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] 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
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
const mouseEvent = {
|
2022-04-13 14:57:44 +00:00
|
|
|
offsetX: 500,
|
|
|
|
|
offsetY: 600,
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### 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
- [ ] 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
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] 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
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
} as unknown as MouseEvent;
|
2022-04-13 14:57:44 +00:00
|
|
|
expect(getMousePositionsOnCanvas(mouseEvent, gridProps)).toEqual({
|
|
|
|
|
id: "mouse",
|
|
|
|
|
top: 59,
|
|
|
|
|
left: 49,
|
|
|
|
|
bottom: 60,
|
|
|
|
|
right: 50,
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
it("getMousePositionsOnCanvas should even return negative Mouse Position relative to Canvas", () => {
|
|
|
|
|
const gridProps = {
|
|
|
|
|
parentColumnSpace: 10,
|
|
|
|
|
parentRowSpace: 10,
|
|
|
|
|
maxGridColumns: 64,
|
|
|
|
|
};
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### 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
- [ ] 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
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] 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
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
const mouseEvent = {
|
2022-04-13 14:57:44 +00:00
|
|
|
offsetX: 2,
|
|
|
|
|
offsetY: 5,
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### 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
- [ ] 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
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] 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
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
} as unknown as MouseEvent;
|
2022-04-13 14:57:44 +00:00
|
|
|
expect(getMousePositionsOnCanvas(mouseEvent, gridProps)).toEqual({
|
|
|
|
|
id: "mouse",
|
|
|
|
|
top: -1,
|
|
|
|
|
left: -1,
|
|
|
|
|
bottom: 0,
|
|
|
|
|
right: 0,
|
|
|
|
|
});
|
|
|
|
|
});
|
2021-04-26 10:35:59 +00:00
|
|
|
it("it checks if array to object migration functions for chart widget ", () => {
|
|
|
|
|
const input = {
|
2021-09-09 15:10:22 +00:00
|
|
|
type: "CANVAS_WIDGET",
|
2021-04-26 10:35:59 +00:00
|
|
|
widgetId: "0",
|
|
|
|
|
widgetName: "canvas",
|
|
|
|
|
parentColumnSpace: 1,
|
|
|
|
|
parentRowSpace: 1,
|
|
|
|
|
leftColumn: 0,
|
|
|
|
|
rightColumn: 0,
|
|
|
|
|
topRow: 0,
|
|
|
|
|
bottomRow: 0,
|
|
|
|
|
version: 17,
|
|
|
|
|
isLoading: false,
|
|
|
|
|
renderMode: RenderModes.CANVAS,
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
widgetId: "some-random-id",
|
|
|
|
|
widgetName: "chart1",
|
|
|
|
|
parentColumnSpace: 1,
|
|
|
|
|
parentRowSpace: 1,
|
|
|
|
|
leftColumn: 0,
|
|
|
|
|
rightColumn: 0,
|
|
|
|
|
topRow: 0,
|
|
|
|
|
bottomRow: 0,
|
|
|
|
|
version: 17,
|
|
|
|
|
isLoading: false,
|
|
|
|
|
renderMode: RenderModes.CANVAS,
|
2021-09-09 15:10:22 +00:00
|
|
|
type: "CHART_WIDGET",
|
2021-04-26 10:35:59 +00:00
|
|
|
chartData: [
|
|
|
|
|
{
|
|
|
|
|
seriesName: "seris1",
|
|
|
|
|
data: [{ x: 1, y: 2 }],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// mocking implementation of our generateReactKey function
|
|
|
|
|
const generatorReactKeyMock = jest.spyOn(generators, "generateReactKey");
|
|
|
|
|
generatorReactKeyMock.mockImplementation(() => "some-random-key");
|
|
|
|
|
|
|
|
|
|
const result = migrateChartDataFromArrayToObject(input);
|
|
|
|
|
|
|
|
|
|
const output = {
|
2021-09-09 15:10:22 +00:00
|
|
|
type: "CANVAS_WIDGET",
|
2021-04-26 10:35:59 +00:00
|
|
|
widgetId: "0",
|
|
|
|
|
widgetName: "canvas",
|
|
|
|
|
parentColumnSpace: 1,
|
|
|
|
|
parentRowSpace: 1,
|
|
|
|
|
leftColumn: 0,
|
|
|
|
|
rightColumn: 0,
|
|
|
|
|
topRow: 0,
|
|
|
|
|
bottomRow: 0,
|
|
|
|
|
version: 17,
|
|
|
|
|
isLoading: false,
|
|
|
|
|
renderMode: RenderModes.CANVAS,
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
widgetId: "some-random-id",
|
|
|
|
|
widgetName: "chart1",
|
|
|
|
|
parentColumnSpace: 1,
|
|
|
|
|
parentRowSpace: 1,
|
|
|
|
|
leftColumn: 0,
|
|
|
|
|
rightColumn: 0,
|
|
|
|
|
topRow: 0,
|
|
|
|
|
bottomRow: 0,
|
|
|
|
|
version: 17,
|
|
|
|
|
isLoading: false,
|
|
|
|
|
renderMode: RenderModes.CANVAS,
|
2021-09-09 15:10:22 +00:00
|
|
|
type: "CHART_WIDGET",
|
2021-04-26 10:35:59 +00:00
|
|
|
dynamicBindingPathList: [],
|
|
|
|
|
chartData: {
|
|
|
|
|
"some-random-key": {
|
|
|
|
|
seriesName: "seris1",
|
|
|
|
|
data: [{ x: 1, y: 2 }],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
expect(result).toStrictEqual(output);
|
|
|
|
|
});
|
2021-05-18 18:29:39 +00:00
|
|
|
it("Grid density migration - Main container widgets", () => {
|
|
|
|
|
const dsl: any = buildDslWithChildren([{ type: "TABS_WIDGET" }]);
|
|
|
|
|
const newMigratedDsl: any = migrateToNewLayout(cloneDeep(dsl));
|
|
|
|
|
expect(dsl.children[0].topRow * GRID_DENSITY_MIGRATION_V1).toBe(
|
|
|
|
|
newMigratedDsl.children[0].topRow,
|
|
|
|
|
);
|
|
|
|
|
expect(dsl.children[0].bottomRow * GRID_DENSITY_MIGRATION_V1).toBe(
|
|
|
|
|
newMigratedDsl.children[0].bottomRow,
|
|
|
|
|
);
|
|
|
|
|
expect(dsl.children[0].rightColumn * GRID_DENSITY_MIGRATION_V1).toBe(
|
|
|
|
|
newMigratedDsl.children[0].rightColumn,
|
|
|
|
|
);
|
|
|
|
|
expect(dsl.children[0].leftColumn * GRID_DENSITY_MIGRATION_V1).toBe(
|
|
|
|
|
newMigratedDsl.children[0].leftColumn,
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("Grid density migration - widgets inside a container", () => {
|
|
|
|
|
const childrenInsideContainer = buildChildren([
|
|
|
|
|
{ type: "SWITCH_WIDGET" },
|
|
|
|
|
{ type: "FORM_WIDGET" },
|
|
|
|
|
{ type: "CONTAINER_WIDGET" },
|
|
|
|
|
]);
|
|
|
|
|
const dslWithContainer: any = buildDslWithChildren([
|
|
|
|
|
{ type: "CONTAINER_WIDGET", children: childrenInsideContainer },
|
|
|
|
|
]);
|
|
|
|
|
const newMigratedDsl: any = migrateToNewLayout(cloneDeep(dslWithContainer));
|
|
|
|
|
// Container migrated checks
|
|
|
|
|
const containerWidget = dslWithContainer.children[0];
|
|
|
|
|
const migratedContainer = newMigratedDsl.children[0];
|
|
|
|
|
expect(containerWidget.topRow * GRID_DENSITY_MIGRATION_V1).toBe(
|
|
|
|
|
migratedContainer.topRow,
|
|
|
|
|
);
|
|
|
|
|
expect(containerWidget.bottomRow * GRID_DENSITY_MIGRATION_V1).toBe(
|
|
|
|
|
migratedContainer.bottomRow,
|
|
|
|
|
);
|
|
|
|
|
expect(containerWidget.rightColumn * GRID_DENSITY_MIGRATION_V1).toBe(
|
|
|
|
|
migratedContainer.rightColumn,
|
|
|
|
|
);
|
|
|
|
|
expect(containerWidget.leftColumn * GRID_DENSITY_MIGRATION_V1).toBe(
|
|
|
|
|
migratedContainer.leftColumn,
|
|
|
|
|
);
|
|
|
|
|
// Children inside container miragted
|
|
|
|
|
|
|
|
|
|
containerWidget.children.forEach((eachChild: any, index: any) => {
|
|
|
|
|
const migratedChild = migratedContainer.children[index];
|
|
|
|
|
expect(eachChild.topRow * GRID_DENSITY_MIGRATION_V1).toBe(
|
|
|
|
|
migratedChild.topRow,
|
|
|
|
|
);
|
|
|
|
|
expect(eachChild.bottomRow * GRID_DENSITY_MIGRATION_V1).toBe(
|
|
|
|
|
migratedChild.bottomRow,
|
|
|
|
|
);
|
|
|
|
|
expect(eachChild.rightColumn * GRID_DENSITY_MIGRATION_V1).toBe(
|
|
|
|
|
migratedChild.rightColumn,
|
|
|
|
|
);
|
|
|
|
|
expect(eachChild.leftColumn * GRID_DENSITY_MIGRATION_V1).toBe(
|
|
|
|
|
migratedChild.leftColumn,
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
});
|
2021-04-26 10:35:59 +00:00
|
|
|
});
|
2021-05-18 13:54:40 +00:00
|
|
|
|
|
|
|
|
describe("Initial value migration test", () => {
|
|
|
|
|
const containerWidget = {
|
|
|
|
|
widgetName: "MainContainer",
|
|
|
|
|
backgroundColor: "none",
|
|
|
|
|
rightColumn: 1118,
|
|
|
|
|
snapColumns: 16,
|
|
|
|
|
detachFromLayout: true,
|
|
|
|
|
widgetId: "0",
|
|
|
|
|
topRow: 0,
|
|
|
|
|
bottomRow: 560,
|
|
|
|
|
snapRows: 33,
|
|
|
|
|
isLoading: false,
|
|
|
|
|
parentRowSpace: 1,
|
2021-09-09 15:10:22 +00:00
|
|
|
type: "CANVAS_WIDGET",
|
2021-05-18 13:54:40 +00:00
|
|
|
renderMode: RenderModes.CANVAS,
|
|
|
|
|
canExtend: true,
|
|
|
|
|
version: 18,
|
|
|
|
|
minHeight: 600,
|
|
|
|
|
parentColumnSpace: 1,
|
|
|
|
|
dynamicTriggerPathList: [],
|
|
|
|
|
dynamicBindingPathList: [],
|
|
|
|
|
leftColumn: 0,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
it("Input widget", () => {
|
|
|
|
|
const input = {
|
|
|
|
|
...containerWidget,
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
widgetName: "Input1",
|
|
|
|
|
rightColumn: 8,
|
|
|
|
|
widgetId: "ra3vyy3nt2",
|
|
|
|
|
topRow: 1,
|
|
|
|
|
bottomRow: 2,
|
|
|
|
|
parentRowSpace: 40,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
label: "",
|
2021-09-09 15:10:22 +00:00
|
|
|
type: "INPUT_WIDGET",
|
2021-05-18 13:54:40 +00:00
|
|
|
version: 1,
|
|
|
|
|
parentId: "0",
|
|
|
|
|
isLoading: false,
|
|
|
|
|
parentColumnSpace: 67.375,
|
|
|
|
|
leftColumn: 3,
|
|
|
|
|
inputType: "TEXT",
|
|
|
|
|
renderMode: RenderModes.CANVAS,
|
|
|
|
|
resetOnSubmit: false,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
const output = {
|
|
|
|
|
...containerWidget,
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
widgetName: "Input1",
|
|
|
|
|
rightColumn: 8,
|
|
|
|
|
widgetId: "ra3vyy3nt2",
|
|
|
|
|
topRow: 1,
|
|
|
|
|
bottomRow: 2,
|
|
|
|
|
parentRowSpace: 40,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
label: "",
|
|
|
|
|
type: "INPUT_WIDGET",
|
|
|
|
|
version: 1,
|
|
|
|
|
parentId: "0",
|
|
|
|
|
isLoading: false,
|
|
|
|
|
parentColumnSpace: 67.375,
|
|
|
|
|
renderMode: "CANVAS",
|
|
|
|
|
leftColumn: 3,
|
|
|
|
|
inputType: "TEXT",
|
|
|
|
|
// will not override existing property
|
|
|
|
|
resetOnSubmit: false,
|
|
|
|
|
// following properties get added
|
|
|
|
|
isRequired: false,
|
|
|
|
|
isDisabled: false,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
expect(migrateInitialValues(input)).toEqual(output);
|
|
|
|
|
});
|
|
|
|
|
|
2022-02-02 14:15:07 +00:00
|
|
|
it("SELECT_WIDGET", () => {
|
2021-05-18 13:54:40 +00:00
|
|
|
const input = {
|
|
|
|
|
...containerWidget,
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
widgetName: "Select1",
|
|
|
|
|
rightColumn: 6,
|
2021-08-03 06:38:01 +00:00
|
|
|
selectionType: "SINGLE_SELECT",
|
2021-05-18 13:54:40 +00:00
|
|
|
widgetId: "1e3ytl2pl9",
|
|
|
|
|
topRow: 3,
|
|
|
|
|
bottomRow: 4,
|
|
|
|
|
parentRowSpace: 40,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
label: "",
|
2022-02-02 14:15:07 +00:00
|
|
|
isRequired: false,
|
|
|
|
|
isDisabled: false,
|
|
|
|
|
type: "SELECT_WIDGET",
|
2021-05-18 13:54:40 +00:00
|
|
|
version: 1,
|
|
|
|
|
parentId: "0",
|
|
|
|
|
isLoading: false,
|
|
|
|
|
defaultOptionValue: "GREEN",
|
|
|
|
|
parentColumnSpace: 67.375,
|
|
|
|
|
renderMode: RenderModes.CANVAS,
|
|
|
|
|
leftColumn: 1,
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
label: "Blue",
|
|
|
|
|
value: "BLUE",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "Green",
|
|
|
|
|
value: "GREEN",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "Red",
|
|
|
|
|
value: "RED",
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const output = {
|
|
|
|
|
...containerWidget,
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
widgetName: "Select1",
|
|
|
|
|
rightColumn: 6,
|
|
|
|
|
widgetId: "1e3ytl2pl9",
|
|
|
|
|
topRow: 3,
|
|
|
|
|
bottomRow: 4,
|
|
|
|
|
parentRowSpace: 40,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
label: "",
|
2021-08-03 06:38:01 +00:00
|
|
|
selectionType: "SINGLE_SELECT",
|
2022-02-02 14:15:07 +00:00
|
|
|
type: "SELECT_WIDGET",
|
2021-05-18 13:54:40 +00:00
|
|
|
version: 1,
|
|
|
|
|
parentId: "0",
|
|
|
|
|
isLoading: false,
|
|
|
|
|
defaultOptionValue: "GREEN",
|
|
|
|
|
parentColumnSpace: 67.375,
|
|
|
|
|
renderMode: "CANVAS",
|
|
|
|
|
leftColumn: 1,
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
label: "Blue",
|
|
|
|
|
value: "BLUE",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "Green",
|
|
|
|
|
value: "GREEN",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "Red",
|
|
|
|
|
value: "RED",
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
isRequired: false,
|
|
|
|
|
isDisabled: false,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
expect(migrateInitialValues(input)).toEqual(output);
|
|
|
|
|
});
|
|
|
|
|
|
2021-08-03 06:38:01 +00:00
|
|
|
it("MULTI_SELECT_WIDGET", () => {
|
|
|
|
|
const input = {
|
|
|
|
|
...containerWidget,
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
widgetName: "Select2",
|
|
|
|
|
rightColumn: 59,
|
|
|
|
|
isFilterable: true,
|
|
|
|
|
widgetId: "zvgz9h4fh4",
|
|
|
|
|
topRow: 10,
|
|
|
|
|
bottomRow: 14,
|
|
|
|
|
parentRowSpace: 10,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
label: "",
|
2021-09-09 15:10:22 +00:00
|
|
|
type: "DROP_DOWN_WIDGET",
|
2021-08-03 06:38:01 +00:00
|
|
|
version: 1,
|
|
|
|
|
parentId: "0y8sg136kg",
|
|
|
|
|
isLoading: false,
|
|
|
|
|
defaultOptionValue: "GREEN",
|
|
|
|
|
selectionType: "MULTI_SELECT",
|
|
|
|
|
parentColumnSpace: 8.35546875,
|
|
|
|
|
dynamicTriggerPathList: [],
|
|
|
|
|
leftColumn: 39,
|
|
|
|
|
dynamicBindingPathList: [],
|
|
|
|
|
renderMode: RenderModes.CANVAS,
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
label: "Blue",
|
|
|
|
|
value: "BLUE",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "Green",
|
|
|
|
|
value: "GREEN",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "Red",
|
|
|
|
|
value: "RED",
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const output = {
|
|
|
|
|
...containerWidget,
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
renderMode: RenderModes.CANVAS,
|
2021-09-09 15:10:22 +00:00
|
|
|
type: "MULTI_SELECT_WIDGET",
|
2021-08-03 06:38:01 +00:00
|
|
|
widgetName: "Select2",
|
|
|
|
|
rightColumn: 59,
|
|
|
|
|
widgetId: "zvgz9h4fh4",
|
|
|
|
|
topRow: 10,
|
|
|
|
|
bottomRow: 14,
|
|
|
|
|
parentRowSpace: 10,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
label: "",
|
|
|
|
|
version: 1,
|
|
|
|
|
parentId: "0y8sg136kg",
|
|
|
|
|
isLoading: false,
|
|
|
|
|
defaultOptionValue: "GREEN",
|
|
|
|
|
parentColumnSpace: 8.35546875,
|
|
|
|
|
dynamicTriggerPathList: [],
|
|
|
|
|
leftColumn: 39,
|
|
|
|
|
dynamicBindingPathList: [],
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
label: "Blue",
|
|
|
|
|
value: "BLUE",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "Green",
|
|
|
|
|
value: "GREEN",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "Red",
|
|
|
|
|
value: "RED",
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
expect(migrateToNewMultiSelect(input)).toEqual(output);
|
|
|
|
|
});
|
|
|
|
|
|
2021-05-18 13:54:40 +00:00
|
|
|
it("DATE_PICKER_WIDGET2", () => {
|
|
|
|
|
const input = {
|
|
|
|
|
...containerWidget,
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
widgetName: "DatePicker1",
|
|
|
|
|
defaultDate: "2021-05-12T06:50:51.743Z",
|
|
|
|
|
rightColumn: 7,
|
|
|
|
|
dateFormat: "YYYY-MM-DD HH:mm",
|
|
|
|
|
widgetId: "5jbfazqnca",
|
|
|
|
|
topRow: 2,
|
|
|
|
|
bottomRow: 3,
|
|
|
|
|
parentRowSpace: 40,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
datePickerType: "DATE_PICKER",
|
|
|
|
|
label: "",
|
2021-09-09 15:10:22 +00:00
|
|
|
type: "DATE_PICKER_WIDGET2",
|
2021-05-18 13:54:40 +00:00
|
|
|
renderMode: RenderModes.CANVAS,
|
|
|
|
|
version: 2,
|
|
|
|
|
parentId: "0",
|
|
|
|
|
isLoading: false,
|
|
|
|
|
parentColumnSpace: 67.375,
|
|
|
|
|
leftColumn: 2,
|
|
|
|
|
isDisabled: false,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const output = {
|
|
|
|
|
...containerWidget,
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
widgetName: "DatePicker1",
|
|
|
|
|
defaultDate: "2021-05-12T06:50:51.743Z",
|
|
|
|
|
rightColumn: 7,
|
|
|
|
|
dateFormat: "YYYY-MM-DD HH:mm",
|
|
|
|
|
widgetId: "5jbfazqnca",
|
|
|
|
|
topRow: 2,
|
|
|
|
|
bottomRow: 3,
|
|
|
|
|
parentRowSpace: 40,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
datePickerType: "DATE_PICKER",
|
|
|
|
|
label: "",
|
2021-09-09 15:10:22 +00:00
|
|
|
type: "DATE_PICKER_WIDGET2",
|
2021-05-18 13:54:40 +00:00
|
|
|
renderMode: RenderModes.CANVAS,
|
|
|
|
|
version: 2,
|
|
|
|
|
parentId: "0",
|
|
|
|
|
isLoading: false,
|
|
|
|
|
parentColumnSpace: 67.375,
|
|
|
|
|
leftColumn: 2,
|
|
|
|
|
isDisabled: false,
|
|
|
|
|
// following properties get added
|
|
|
|
|
isRequired: false,
|
|
|
|
|
minDate: "2001-01-01 00:00",
|
|
|
|
|
maxDate: "2041-12-31 23:59",
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
expect(migrateInitialValues(input)).toEqual(output);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("SWITCH_WIDGET", () => {
|
|
|
|
|
const input = {
|
|
|
|
|
...containerWidget,
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
widgetName: "Switch1",
|
|
|
|
|
rightColumn: 5,
|
|
|
|
|
widgetId: "4ksqurxmwn",
|
|
|
|
|
topRow: 2,
|
|
|
|
|
bottomRow: 3,
|
|
|
|
|
parentRowSpace: 40,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
label: "Label",
|
2021-09-09 15:10:22 +00:00
|
|
|
type: "SWITCH_WIDGET",
|
2021-05-18 13:54:40 +00:00
|
|
|
renderMode: RenderModes.CANVAS,
|
|
|
|
|
defaultSwitchState: true,
|
|
|
|
|
version: 1,
|
|
|
|
|
alignWidget: "LEFT",
|
|
|
|
|
parentId: "0",
|
|
|
|
|
isLoading: false,
|
|
|
|
|
parentColumnSpace: 67.375,
|
|
|
|
|
leftColumn: 3,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const output = {
|
|
|
|
|
...containerWidget,
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
widgetName: "Switch1",
|
|
|
|
|
rightColumn: 5,
|
|
|
|
|
widgetId: "4ksqurxmwn",
|
|
|
|
|
topRow: 2,
|
|
|
|
|
bottomRow: 3,
|
|
|
|
|
parentRowSpace: 40,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
label: "Label",
|
2021-09-09 15:10:22 +00:00
|
|
|
type: "SWITCH_WIDGET",
|
2021-05-18 13:54:40 +00:00
|
|
|
renderMode: RenderModes.CANVAS,
|
|
|
|
|
defaultSwitchState: true,
|
|
|
|
|
version: 1,
|
|
|
|
|
alignWidget: "LEFT",
|
|
|
|
|
parentId: "0",
|
|
|
|
|
isLoading: false,
|
|
|
|
|
parentColumnSpace: 67.375,
|
|
|
|
|
leftColumn: 3,
|
|
|
|
|
// following properties get added
|
|
|
|
|
isDisabled: false,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
expect(migrateInitialValues(input)).toEqual(output);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("Video widget", () => {
|
|
|
|
|
const input = {
|
|
|
|
|
...containerWidget,
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
widgetName: "Video1",
|
|
|
|
|
rightColumn: 9,
|
|
|
|
|
dynamicPropertyPathList: [],
|
|
|
|
|
widgetId: "ti5b5f5hvq",
|
|
|
|
|
topRow: 3,
|
|
|
|
|
bottomRow: 10,
|
|
|
|
|
parentRowSpace: 40,
|
|
|
|
|
isVisible: true,
|
2021-09-09 15:10:22 +00:00
|
|
|
type: "VIDEO_WIDGET",
|
2021-05-18 13:54:40 +00:00
|
|
|
renderMode: RenderModes.CANVAS,
|
|
|
|
|
version: 1,
|
|
|
|
|
onPlay: "",
|
2023-04-10 07:02:31 +00:00
|
|
|
url: `${ASSETS_CDN_URL}/widgets/bird.mp4`,
|
2021-05-18 13:54:40 +00:00
|
|
|
parentId: "0",
|
|
|
|
|
isLoading: false,
|
|
|
|
|
parentColumnSpace: 67.375,
|
|
|
|
|
leftColumn: 2,
|
|
|
|
|
autoPlay: false,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
const output = {
|
|
|
|
|
...containerWidget,
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
widgetName: "Video1",
|
|
|
|
|
rightColumn: 9,
|
|
|
|
|
dynamicPropertyPathList: [],
|
|
|
|
|
widgetId: "ti5b5f5hvq",
|
|
|
|
|
topRow: 3,
|
|
|
|
|
bottomRow: 10,
|
|
|
|
|
parentRowSpace: 40,
|
|
|
|
|
isVisible: true,
|
2021-09-09 15:10:22 +00:00
|
|
|
type: "VIDEO_WIDGET",
|
2021-05-18 13:54:40 +00:00
|
|
|
renderMode: RenderModes.CANVAS,
|
|
|
|
|
version: 1,
|
|
|
|
|
onPlay: "",
|
2023-04-10 07:02:31 +00:00
|
|
|
url: `${ASSETS_CDN_URL}/widgets/bird.mp4`,
|
2021-05-18 13:54:40 +00:00
|
|
|
parentId: "0",
|
|
|
|
|
isLoading: false,
|
|
|
|
|
parentColumnSpace: 67.375,
|
|
|
|
|
leftColumn: 2,
|
|
|
|
|
autoPlay: false,
|
|
|
|
|
// following properties get added
|
|
|
|
|
isRequired: false,
|
|
|
|
|
isDisabled: false,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
expect(migrateInitialValues(input)).toEqual(output);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("CHECKBOX_WIDGET", () => {
|
|
|
|
|
const input = {
|
|
|
|
|
...containerWidget,
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
widgetName: "Checkbox1",
|
|
|
|
|
rightColumn: 8,
|
|
|
|
|
widgetId: "djxhhl1p7t",
|
|
|
|
|
topRow: 4,
|
|
|
|
|
bottomRow: 5,
|
|
|
|
|
parentRowSpace: 40,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
label: "Label",
|
2021-09-09 15:10:22 +00:00
|
|
|
type: "CHECKBOX_WIDGET",
|
2021-05-18 13:54:40 +00:00
|
|
|
renderMode: RenderModes.CANVAS,
|
|
|
|
|
version: 1,
|
|
|
|
|
alignWidget: "LEFT",
|
|
|
|
|
parentId: "0",
|
|
|
|
|
isLoading: false,
|
|
|
|
|
parentColumnSpace: 67.375,
|
|
|
|
|
leftColumn: 5,
|
|
|
|
|
defaultCheckedState: true,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
const output = {
|
|
|
|
|
...containerWidget,
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
widgetName: "Checkbox1",
|
|
|
|
|
rightColumn: 8,
|
|
|
|
|
widgetId: "djxhhl1p7t",
|
|
|
|
|
topRow: 4,
|
|
|
|
|
bottomRow: 5,
|
|
|
|
|
parentRowSpace: 40,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
label: "Label",
|
2021-09-09 15:10:22 +00:00
|
|
|
type: "CHECKBOX_WIDGET",
|
2021-05-18 13:54:40 +00:00
|
|
|
renderMode: RenderModes.CANVAS,
|
|
|
|
|
version: 1,
|
|
|
|
|
alignWidget: "LEFT",
|
|
|
|
|
parentId: "0",
|
|
|
|
|
isLoading: false,
|
|
|
|
|
parentColumnSpace: 67.375,
|
|
|
|
|
leftColumn: 5,
|
|
|
|
|
defaultCheckedState: true,
|
|
|
|
|
// following properties get added
|
|
|
|
|
isDisabled: false,
|
|
|
|
|
isRequired: false,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
expect(migrateInitialValues(input)).toEqual(output);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("RADIO_GROUP_WIDGET", () => {
|
|
|
|
|
const input = {
|
|
|
|
|
...containerWidget,
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
widgetName: "RadioGroup1",
|
|
|
|
|
rightColumn: 5,
|
|
|
|
|
widgetId: "4ixyqnw2no",
|
|
|
|
|
topRow: 3,
|
|
|
|
|
bottomRow: 5,
|
|
|
|
|
parentRowSpace: 40,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
label: "",
|
2021-09-09 15:10:22 +00:00
|
|
|
type: "RADIO_GROUP_WIDGET",
|
2021-05-18 13:54:40 +00:00
|
|
|
renderMode: RenderModes.CANVAS,
|
|
|
|
|
version: 1,
|
|
|
|
|
parentId: "0",
|
|
|
|
|
isLoading: false,
|
|
|
|
|
defaultOptionValue: "Y",
|
|
|
|
|
parentColumnSpace: 67.375,
|
|
|
|
|
leftColumn: 2,
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
label: "Yes",
|
|
|
|
|
value: "Y",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "No",
|
|
|
|
|
value: "N",
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
const output = {
|
|
|
|
|
...containerWidget,
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
widgetName: "RadioGroup1",
|
|
|
|
|
rightColumn: 5,
|
|
|
|
|
widgetId: "4ixyqnw2no",
|
|
|
|
|
topRow: 3,
|
|
|
|
|
bottomRow: 5,
|
|
|
|
|
parentRowSpace: 40,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
label: "",
|
2021-09-09 15:10:22 +00:00
|
|
|
type: "RADIO_GROUP_WIDGET",
|
2021-05-18 13:54:40 +00:00
|
|
|
renderMode: RenderModes.CANVAS,
|
|
|
|
|
version: 1,
|
|
|
|
|
parentId: "0",
|
|
|
|
|
isLoading: false,
|
|
|
|
|
defaultOptionValue: "Y",
|
|
|
|
|
parentColumnSpace: 67.375,
|
|
|
|
|
leftColumn: 2,
|
|
|
|
|
options: [
|
|
|
|
|
{
|
|
|
|
|
label: "Yes",
|
|
|
|
|
value: "Y",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "No",
|
|
|
|
|
value: "N",
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
// following properties get added
|
|
|
|
|
isDisabled: false,
|
|
|
|
|
isRequired: false,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
expect(migrateInitialValues(input)).toEqual(output);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("FILE_PICKER_WIDGET", () => {
|
|
|
|
|
const input = {
|
|
|
|
|
...containerWidget,
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
widgetName: "FilePicker1",
|
|
|
|
|
rightColumn: 5,
|
|
|
|
|
isDefaultClickDisabled: true,
|
|
|
|
|
widgetId: "fzajyy8qft",
|
|
|
|
|
topRow: 4,
|
|
|
|
|
bottomRow: 5,
|
|
|
|
|
parentRowSpace: 40,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
label: "Select Files",
|
|
|
|
|
maxFileSize: 5,
|
2021-09-09 15:10:22 +00:00
|
|
|
type: "FILE_PICKER_WIDGET",
|
2021-05-18 13:54:40 +00:00
|
|
|
renderMode: RenderModes.CANVAS,
|
|
|
|
|
version: 1,
|
|
|
|
|
fileDataType: "Base64",
|
|
|
|
|
parentId: "0",
|
|
|
|
|
isLoading: false,
|
|
|
|
|
parentColumnSpace: 67.375,
|
|
|
|
|
leftColumn: 1,
|
|
|
|
|
files: [],
|
|
|
|
|
maxNumFiles: 1,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const output = {
|
|
|
|
|
...containerWidget,
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
widgetName: "FilePicker1",
|
|
|
|
|
rightColumn: 5,
|
|
|
|
|
isDefaultClickDisabled: true,
|
|
|
|
|
widgetId: "fzajyy8qft",
|
|
|
|
|
topRow: 4,
|
|
|
|
|
bottomRow: 5,
|
|
|
|
|
parentRowSpace: 40,
|
|
|
|
|
isVisible: true,
|
|
|
|
|
label: "Select Files",
|
|
|
|
|
maxFileSize: 5,
|
2021-09-09 15:10:22 +00:00
|
|
|
type: "FILE_PICKER_WIDGET",
|
2021-05-18 13:54:40 +00:00
|
|
|
renderMode: RenderModes.CANVAS,
|
|
|
|
|
version: 1,
|
|
|
|
|
fileDataType: "Base64",
|
|
|
|
|
parentId: "0",
|
|
|
|
|
isLoading: false,
|
|
|
|
|
parentColumnSpace: 67.375,
|
|
|
|
|
leftColumn: 1,
|
|
|
|
|
files: [],
|
|
|
|
|
maxNumFiles: 1,
|
|
|
|
|
// following properties get added
|
|
|
|
|
isDisabled: false,
|
|
|
|
|
isRequired: false,
|
|
|
|
|
allowedFileTypes: [],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
expect(migrateInitialValues(input)).toEqual(output);
|
|
|
|
|
});
|
2021-05-28 02:58:02 +00:00
|
|
|
it("", () => {
|
|
|
|
|
const tabsWidgetDSL: any = (version = 1) => {
|
|
|
|
|
const children: any = buildChildren([
|
|
|
|
|
{
|
|
|
|
|
version,
|
|
|
|
|
type: "TABS_WIDGET",
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
type: "CANVAS_WIDGET",
|
|
|
|
|
tabId: "tab1212332",
|
|
|
|
|
tabName: "Newly Added Tab",
|
|
|
|
|
widgetId: "o9ody00ep7",
|
|
|
|
|
parentId: "jd83uvbkmp",
|
|
|
|
|
detachFromLayout: true,
|
|
|
|
|
children: [],
|
|
|
|
|
parentRowSpace: 1,
|
|
|
|
|
parentColumnSpace: 1,
|
|
|
|
|
// leftColumn: 0,
|
|
|
|
|
// rightColumn: 592, // Commenting these coz they are not provided for a newly added tab in the Tabs widget version 2
|
|
|
|
|
// bottomRow: 280,
|
|
|
|
|
topRow: 0,
|
|
|
|
|
isLoading: false,
|
|
|
|
|
widgetName: "Canvas1",
|
|
|
|
|
renderMode: "CANVAS",
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
]);
|
|
|
|
|
const dsl: any = widgetCanvasFactory.build({
|
|
|
|
|
children,
|
|
|
|
|
});
|
|
|
|
|
return {
|
|
|
|
|
data: {
|
|
|
|
|
layouts: [{ dsl }],
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
};
|
2023-04-07 13:51:35 +00:00
|
|
|
const migratedDslV2: any = extractCurrentDSL(tabsWidgetDSL()).dsl;
|
2021-05-28 02:58:02 +00:00
|
|
|
expect(migratedDslV2.children[0].children[0].leftColumn).toBeNaN();
|
2023-04-07 13:51:35 +00:00
|
|
|
const migratedDslV3: any = extractCurrentDSL(tabsWidgetDSL(2)).dsl;
|
2021-05-28 02:58:02 +00:00
|
|
|
expect(migratedDslV3.children[0].version).toBe(3);
|
|
|
|
|
expect(migratedDslV3.children[0].children[0].leftColumn).not.toBeNaN();
|
|
|
|
|
expect(migratedDslV3.children[0].children[0].leftColumn).toBe(0);
|
|
|
|
|
});
|
2021-05-18 13:54:40 +00:00
|
|
|
});
|