Use updated test data

This commit is contained in:
Adria Navarro 2024-11-05 16:08:24 +01:00
parent 01248508c4
commit b59b4e1736
2 changed files with 14 additions and 7 deletions

View File

@ -64,8 +64,7 @@
return true return true
} }
const memoTestData = memo(parseTestData($selectedAutomation.testData)) $: testData = testData || parseTestData($selectedAutomation.testData)
$: memoTestData.set(parseTestData($selectedAutomation.testData))
$: { $: {
// clone the trigger so we're not mutating the reference // clone the trigger so we're not mutating the reference
@ -84,7 +83,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) {
@ -111,10 +110,10 @@
} }
const testAutomation = async () => { const testAutomation = async () => {
// Ensure $memoTestData reactiveness is processed // Ensure testData reactiveness is processed
await tick() await tick()
try { try {
await automationStore.actions.test($selectedAutomation, $memoTestData) await automationStore.actions.test($selectedAutomation, testData)
$automationStore.showTestPanel = true $automationStore.showTestPanel = true
} catch (error) { } catch (error) {
notifications.error(error) notifications.error(error)
@ -152,7 +151,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}

View File

@ -529,7 +529,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) {