fix: added default value for switch view type (#15215)

This commit is contained in:
Ayush Pahwa 2022-07-15 12:45:08 +05:30 committed by GitHub
parent af2e55ef31
commit 458715f0ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 78 additions and 15 deletions

View File

@ -388,6 +388,9 @@ describe("json/form viewTypes test", () => {
viewType: ViewTypes.JSON,
componentData: "value2",
},
node6: {
viewType: ViewTypes.COMPONENT,
},
},
},
},
@ -403,6 +406,9 @@ describe("json/form viewTypes test", () => {
viewType: ViewTypes.JSON,
componentData: "value2",
},
node6: {
viewType: ViewTypes.COMPONENT,
},
},
},
},
@ -422,20 +428,8 @@ describe("json/form viewTypes test", () => {
viewType: ViewTypes.JSON,
componentData: "value2",
},
},
},
},
{
actionConfiguration: {
formData: {
node1: { data: "value1" },
node3: { data: "value1" },
node2: { data: "value1", viewType: ViewTypes.JSON },
node4: { data: "value1", viewType: ViewTypes.COMPONENT },
node5: {
data: "value1",
viewType: ViewTypes.JSON,
componentData: "value2",
node6: {
viewType: ViewTypes.COMPONENT,
},
},
},
@ -452,6 +446,9 @@ describe("json/form viewTypes test", () => {
viewType: ViewTypes.JSON,
componentData: "value2",
},
node6: {
viewType: ViewTypes.COMPONENT,
},
},
},
},
@ -467,6 +464,27 @@ describe("json/form viewTypes test", () => {
viewType: ViewTypes.JSON,
componentData: "value2",
},
node6: {
viewType: ViewTypes.COMPONENT,
},
},
},
},
{
actionConfiguration: {
formData: {
node1: { data: "value1" },
node3: { data: "value1" },
node2: { data: "value1", viewType: ViewTypes.JSON },
node4: { data: "value1", viewType: ViewTypes.COMPONENT },
node5: {
data: "value1",
viewType: ViewTypes.JSON,
componentData: "value2",
},
node6: {
viewType: ViewTypes.COMPONENT,
},
},
},
},
@ -494,6 +512,9 @@ describe("json/form viewTypes test", () => {
viewType: ViewTypes.JSON,
componentData: "value2",
},
node6: {
viewType: ViewTypes.COMPONENT,
},
},
},
};
@ -514,6 +535,9 @@ describe("json/form viewTypes test", () => {
viewType: ViewTypes.JSON,
componentData: "value2",
},
node6: {
viewType: ViewTypes.COMPONENT,
},
},
},
},
@ -533,6 +557,9 @@ describe("json/form viewTypes test", () => {
viewType: ViewTypes.JSON,
componentData: "value2",
},
node6: {
viewType: ViewTypes.COMPONENT,
},
},
},
},
@ -553,6 +580,9 @@ describe("json/form viewTypes test", () => {
viewType: ViewTypes.JSON,
componentData: "value2",
},
node6: {
viewType: ViewTypes.COMPONENT,
},
},
},
},
@ -569,6 +599,9 @@ describe("json/form viewTypes test", () => {
componentData: "value2",
jsonData: "value1",
},
node6: {
viewType: ViewTypes.COMPONENT,
},
},
},
},
@ -588,6 +621,32 @@ describe("json/form viewTypes test", () => {
viewType: ViewTypes.JSON,
componentData: "value2",
},
node6: {
viewType: ViewTypes.COMPONENT,
},
},
},
},
{
actionConfiguration: {
formData: {
node1: { data: "value1" },
node2: { data: "value1", viewType: ViewTypes.JSON },
node3: { data: "value1" },
node4: {
data: "value1",
viewType: ViewTypes.COMPONENT,
},
node5: {
data: "value1",
viewType: ViewTypes.JSON,
componentData: "value2",
},
node6: {
viewType: ViewTypes.JSON,
data: "",
componentData: "",
},
},
},
},
@ -613,6 +672,10 @@ describe("json/form viewTypes test", () => {
path: "actionConfiguration.formData.node3.data",
viewType: ViewTypes.JSON,
},
{
path: "actionConfiguration.formData.node6.data",
viewType: ViewTypes.COMPONENT,
},
];
testCases.forEach((testCase, index) => {
const formName = `testForm-${index}`;

View File

@ -148,7 +148,7 @@ export const switchViewType = (
);
const jsonData = get(values, pathForJsonData);
const componentData = get(values, pathForComponentData);
const currentData = get(values, configProperty);
const currentData = get(values, configProperty, "");
const stringifiedCurrentData = JSON.stringify(currentData, null, "\t");
if (newViewType === ViewTypes.JSON) {