Merge pull request #11033 from Budibase/fix/BUDI-7188
Don't sync automation logs from prod to dev app
This commit is contained in:
commit
a3ebcb2896
|
@ -57,6 +57,9 @@ class Replication {
|
|||
appReplicateOpts() {
|
||||
return {
|
||||
filter: (doc: any) => {
|
||||
if (doc._id && doc._id.startsWith(DocumentType.AUTOMATION_LOG)) {
|
||||
return false
|
||||
}
|
||||
return doc._id !== DocumentType.APP_METADATA
|
||||
},
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ jest.mock("../../../utilities/redis", () => ({
|
|||
import { clearAllApps, checkBuilderEndpoint } from "./utilities/TestFunctions"
|
||||
import * as setup from "./utilities"
|
||||
import { AppStatus } from "../../../db/utils"
|
||||
import { events, utils } from "@budibase/backend-core"
|
||||
import { events, utils, context } from "@budibase/backend-core"
|
||||
import env from "../../../environment"
|
||||
|
||||
jest.setTimeout(15000)
|
||||
|
@ -324,4 +324,35 @@ describe("/applications", () => {
|
|||
expect(events.app.unpublished).toBeCalledTimes(1)
|
||||
})
|
||||
})
|
||||
|
||||
describe("POST /api/applications/:appId/sync", () => {
|
||||
it("should not sync automation logs", async () => {
|
||||
// setup the apps
|
||||
await config.createApp("testing-auto-logs")
|
||||
const automation = await config.createAutomation()
|
||||
await config.publish()
|
||||
await context.doInAppContext(config.getProdAppId(), () => {
|
||||
return config.createAutomationLog(automation)
|
||||
})
|
||||
|
||||
// do the sync
|
||||
const appId = config.getAppId()
|
||||
await request
|
||||
.post(`/api/applications/${appId}/sync`)
|
||||
.set(config.defaultHeaders())
|
||||
.expect("Content-Type", /json/)
|
||||
.expect(200)
|
||||
|
||||
// does exist in prod
|
||||
const prodLogs = await config.getAutomationLogs()
|
||||
expect(prodLogs.data.length).toBe(1)
|
||||
|
||||
// delete prod app so we revert to dev log search
|
||||
await config.unpublish()
|
||||
|
||||
// doesn't exist in dev
|
||||
const devLogs = await config.getAutomationLogs()
|
||||
expect(devLogs.data.length).toBe(0)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -21,6 +21,7 @@ import {
|
|||
basicScreen,
|
||||
basicLayout,
|
||||
basicWebhook,
|
||||
basicAutomationResults,
|
||||
} from "./structures"
|
||||
import {
|
||||
constants,
|
||||
|
@ -48,6 +49,7 @@ import {
|
|||
Table,
|
||||
SearchFilters,
|
||||
UserRoles,
|
||||
Automation,
|
||||
} from "@budibase/types"
|
||||
import { BUILTIN_ROLE_IDS } from "@budibase/backend-core/src/security/roles"
|
||||
|
||||
|
@ -720,6 +722,26 @@ class TestConfiguration {
|
|||
return { datasource, query: basedOnQuery }
|
||||
}
|
||||
|
||||
// AUTOMATION LOG
|
||||
|
||||
async createAutomationLog(automation: Automation) {
|
||||
return await context.doInAppContext(this.getProdAppId(), async () => {
|
||||
return await pro.sdk.automations.logs.storeLog(
|
||||
automation,
|
||||
basicAutomationResults(automation._id!)
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
async getAutomationLogs() {
|
||||
return context.doInAppContext(this.appId, async () => {
|
||||
const now = new Date()
|
||||
return await pro.sdk.automations.logs.logSearch({
|
||||
startDate: new Date(now.getTime() - 100000).toISOString(),
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// QUERY
|
||||
|
||||
async previewQuery(
|
||||
|
|
|
@ -9,6 +9,8 @@ import {
|
|||
import {
|
||||
Automation,
|
||||
AutomationActionStepId,
|
||||
AutomationResults,
|
||||
AutomationStatus,
|
||||
AutomationStep,
|
||||
AutomationStepType,
|
||||
AutomationTrigger,
|
||||
|
@ -241,6 +243,23 @@ export function collectAutomation(tableId?: string): Automation {
|
|||
return automation as Automation
|
||||
}
|
||||
|
||||
export function basicAutomationResults(
|
||||
automationId: string
|
||||
): AutomationResults {
|
||||
return {
|
||||
automationId,
|
||||
status: AutomationStatus.SUCCESS,
|
||||
trigger: "trigger",
|
||||
steps: [
|
||||
{
|
||||
stepId: AutomationActionStepId.SERVER_LOG,
|
||||
inputs: {},
|
||||
outputs: {},
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
export function basicRow(tableId: string) {
|
||||
return {
|
||||
name: "Test Contact",
|
||||
|
|
Loading…
Reference in New Issue