Try/catch automation Create Row relationship (#9924)
* Try/catch * Increase height of automation test output * Unit tests * lint
This commit is contained in:
parent
33a9c8d215
commit
a8f873fff3
|
@ -73,14 +73,14 @@
|
|||
<Tabs noHorizPadding selected="Input">
|
||||
<Tab title="Input">
|
||||
<TextArea
|
||||
minHeight="80px"
|
||||
minHeight="160px"
|
||||
disabled
|
||||
value={textArea(filteredResults?.[idx]?.inputs, "No input")}
|
||||
/>
|
||||
</Tab>
|
||||
<Tab title="Output">
|
||||
<TextArea
|
||||
minHeight="100px"
|
||||
minHeight="160px"
|
||||
disabled
|
||||
value={textArea(filteredResults?.[idx]?.outputs, "No output")}
|
||||
/>
|
||||
|
@ -98,8 +98,9 @@
|
|||
|
||||
<style>
|
||||
.container {
|
||||
padding: 0 30px 0 30px;
|
||||
padding: 0 30px 30px 30px;
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.tabs {
|
||||
|
|
|
@ -52,14 +52,18 @@ export function cleanInputValues(inputs: Record<string, any>, schema: any) {
|
|||
}
|
||||
}
|
||||
}
|
||||
//Check if input field should be a relationship and cast to array
|
||||
//Check if input field for Update Row should be a relationship and cast to array
|
||||
for (let key in inputs.row) {
|
||||
if (
|
||||
inputs.schema?.[key]?.type === "link" &&
|
||||
inputs.row[key] &&
|
||||
typeof inputs.row[key] === "string"
|
||||
) {
|
||||
inputs.row[key] = JSON.parse(inputs.row[key])
|
||||
try {
|
||||
inputs.row[key] = JSON.parse(inputs.row[key])
|
||||
} catch (e) {
|
||||
//Link is not an array or object, so continue
|
||||
}
|
||||
}
|
||||
}
|
||||
return inputs
|
||||
|
|
|
@ -62,4 +62,72 @@ describe("automationUtils", () => {
|
|||
).toThrow()
|
||||
})
|
||||
})
|
||||
|
||||
describe("cleanInputValues", () => {
|
||||
it("should handle array relationship fields from read binding", () => {
|
||||
const schema = {
|
||||
relationship: {
|
||||
type: "link",
|
||||
constraints: {
|
||||
type: "array",
|
||||
presence: false,
|
||||
},
|
||||
fieldName: "Users",
|
||||
name: "relationship",
|
||||
relationshipType: "many-to-many",
|
||||
tableId: "ta_users",
|
||||
sortable: false,
|
||||
},
|
||||
}
|
||||
expect(
|
||||
automationUtils.cleanInputValues(
|
||||
{
|
||||
row: {
|
||||
relationship: `[{"_id": "ro_ta_users_us_3"}]`,
|
||||
},
|
||||
schema,
|
||||
},
|
||||
schema
|
||||
)
|
||||
).toEqual({
|
||||
row: {
|
||||
relationship: [{ _id: "ro_ta_users_us_3" }],
|
||||
},
|
||||
schema,
|
||||
})
|
||||
})
|
||||
|
||||
it("should handle single string relationship field", () => {
|
||||
const schema = {
|
||||
relationship: {
|
||||
type: "link",
|
||||
constraints: {
|
||||
type: "array",
|
||||
presence: false,
|
||||
},
|
||||
fieldName: "Users",
|
||||
name: "relationship",
|
||||
relationshipType: "many-to-many",
|
||||
tableId: "ta_users",
|
||||
sortable: false,
|
||||
},
|
||||
}
|
||||
expect(
|
||||
automationUtils.cleanInputValues(
|
||||
{
|
||||
row: {
|
||||
relationship: `ro_ta_users_us_3`,
|
||||
},
|
||||
schema,
|
||||
},
|
||||
schema
|
||||
)
|
||||
).toEqual({
|
||||
row: {
|
||||
relationship: "ro_ta_users_us_3",
|
||||
},
|
||||
schema,
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue