Remove old automation test flag mechanism from Redis.

This commit is contained in:
Sam Rose 2025-01-20 17:30:36 +00:00
parent 2caa9776d3
commit 99cf4feb07
No known key found for this signature in database
2 changed files with 17 additions and 33 deletions

View File

@ -2,7 +2,6 @@ import * as triggers from "../../automations/triggers"
import { sdk as coreSdk } from "@budibase/shared-core"
import { DocumentType } from "../../db/utils"
import { updateTestHistory, removeDeprecated } from "../../automations/utils"
import { withTestFlag } from "../../utilities/redis"
import { context, cache, events, db as dbCore } from "@budibase/backend-core"
import { automations, features } from "@budibase/pro"
import {
@ -246,17 +245,15 @@ export async function test(
const { request, appId } = ctx
const { body } = request
ctx.body = await withTestFlag(automation._id!, async () => {
const occurredAt = new Date().getTime()
await updateTestHistory(appId, automation, { ...body, occurredAt })
const user = sdk.users.getUserContextBindings(ctx.user)
return await triggers.externalTrigger(
ctx.body = await triggers.externalTrigger(
automation,
{ ...prepareTestInput(body), appId, user },
{ getResponses: true }
)
})
await events.automation.tested(automation)
}
@ -271,7 +268,7 @@ export async function testStep(
ctx.throw(404, `Automation ${ctx.params.id} not found`)
}
const step = automation.definition.steps.find(s => s.stepId === stepId)
const step = automation.definition.steps.find(s => s.id === stepId)
if (!step) {
ctx.throw(404, `Step ${stepId} not found on automation ${id}`)
}
@ -290,16 +287,10 @@ export async function testStep(
ctx.throw(400, `Step ${stepId} is not a valid step`)
}
const output = await withTestFlag(
automation._id!,
async () =>
await fn({
ctx.body = await fn({
inputs: body.inputs,
context: await enrichBaseContext(body.context),
appId: ctx.appId,
emitter: new NoopEmitter(),
})
)
ctx.body = output
}

View File

@ -82,11 +82,7 @@ async function queueRelevantRowAutomations(
// don't queue events which are for dev apps, only way to test automations is
// running tests on them, in production the test flag will never
// be checked due to lazy evaluation (first always false)
if (
!env.ALLOW_DEV_AUTOMATIONS &&
isDevAppID(event.appId) &&
!(await checkTestFlag(automation._id!))
) {
if (!env.ALLOW_DEV_AUTOMATIONS && isDevAppID(event.appId)) {
continue
}
@ -170,10 +166,7 @@ export async function externalTrigger(
throw new Error("Automation is disabled")
}
if (
sdk.automations.isAppAction(automation) &&
!(await checkTestFlag(automation._id!))
) {
if (sdk.automations.isAppAction(automation) && !isDevAppID(params.appId)) {
// values are likely to be submitted as strings, so we shall convert to correct type
const coercedFields: any = {}
const fields = automation.definition.trigger.inputs.fields