Merge pull request #14967 from Budibase/fix/automation-data-test-updates
Fix race conditions between automation test data and runs
This commit is contained in:
commit
a2c65f3b2a
|
@ -1,4 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
|
import { tick } from "svelte"
|
||||||
import {
|
import {
|
||||||
ModalContent,
|
ModalContent,
|
||||||
TextArea,
|
TextArea,
|
||||||
|
@ -8,7 +9,6 @@
|
||||||
import { automationStore, selectedAutomation } from "stores/builder"
|
import { automationStore, selectedAutomation } from "stores/builder"
|
||||||
import AutomationBlockSetup from "../../SetupPanel/AutomationBlockSetup.svelte"
|
import AutomationBlockSetup from "../../SetupPanel/AutomationBlockSetup.svelte"
|
||||||
import { cloneDeep } from "lodash/fp"
|
import { cloneDeep } from "lodash/fp"
|
||||||
import { memo } from "@budibase/frontend-core"
|
|
||||||
import { AutomationEventType } from "@budibase/types"
|
import { AutomationEventType } from "@budibase/types"
|
||||||
|
|
||||||
let failedParse = null
|
let failedParse = null
|
||||||
|
@ -63,8 +63,7 @@
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
const memoTestData = memo(parseTestData($selectedAutomation.data.testData))
|
$: testData = testData || parseTestData($selectedAutomation.data.testData)
|
||||||
$: memoTestData.set(parseTestData($selectedAutomation.data.testData))
|
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
// clone the trigger so we're not mutating the reference
|
// clone the trigger so we're not mutating the reference
|
||||||
|
@ -83,7 +82,7 @@
|
||||||
$: isError =
|
$: isError =
|
||||||
!isTriggerValid(trigger) ||
|
!isTriggerValid(trigger) ||
|
||||||
!(trigger.schema.outputs.required || []).every(
|
!(trigger.schema.outputs.required || []).every(
|
||||||
required => $memoTestData?.[required] || required !== "row"
|
required => testData?.[required] || required !== "row"
|
||||||
)
|
)
|
||||||
|
|
||||||
function parseTestJSON(e) {
|
function parseTestJSON(e) {
|
||||||
|
@ -110,11 +109,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const testAutomation = async () => {
|
const testAutomation = async () => {
|
||||||
|
// Ensure testData reactiveness is processed
|
||||||
|
await tick()
|
||||||
try {
|
try {
|
||||||
await automationStore.actions.test(
|
await automationStore.actions.test($selectedAutomation.data, testData)
|
||||||
$selectedAutomation.data,
|
|
||||||
$memoTestData
|
|
||||||
)
|
|
||||||
$automationStore.showTestPanel = true
|
$automationStore.showTestPanel = true
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
notifications.error(error)
|
notifications.error(error)
|
||||||
|
@ -152,7 +150,7 @@
|
||||||
{#if selectedValues}
|
{#if selectedValues}
|
||||||
<div class="tab-content-padding">
|
<div class="tab-content-padding">
|
||||||
<AutomationBlockSetup
|
<AutomationBlockSetup
|
||||||
testData={$memoTestData}
|
bind:testData
|
||||||
{schemaProperties}
|
{schemaProperties}
|
||||||
isTestModal
|
isTestModal
|
||||||
block={trigger}
|
block={trigger}
|
||||||
|
|
|
@ -503,7 +503,15 @@
|
||||||
row: { "Active": true, "Order Id" : 14, ... }
|
row: { "Active": true, "Order Id" : 14, ... }
|
||||||
})
|
})
|
||||||
*/
|
*/
|
||||||
const onChange = Utils.sequential(async update => {
|
const onChange = async update => {
|
||||||
|
if (isTestModal) {
|
||||||
|
testData = update
|
||||||
|
}
|
||||||
|
|
||||||
|
updateAutomation(update)
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateAutomation = Utils.sequential(async update => {
|
||||||
const request = cloneDeep(update)
|
const request = cloneDeep(update)
|
||||||
// Process app trigger updates
|
// Process app trigger updates
|
||||||
if (isTrigger && !isTestModal) {
|
if (isTrigger && !isTestModal) {
|
||||||
|
|
Loading…
Reference in New Issue