PR comments.

This commit is contained in:
mike12345567 2023-06-27 10:01:06 +01:00
parent 3eff4d85d0
commit 47260f23bf
3 changed files with 15 additions and 15 deletions

View File

@ -325,7 +325,7 @@ describe("/applications", () => {
}) })
}) })
describe("app sync", () => { describe("POST /api/applications/:appId/sync", () => {
it("should not sync automation logs", async () => { it("should not sync automation logs", async () => {
// setup the apps // setup the apps
await config.createApp("testing-auto-logs") await config.createApp("testing-auto-logs")
@ -344,19 +344,15 @@ describe("/applications", () => {
.expect(200) .expect(200)
// does exist in prod // does exist in prod
await context.doInAppContext(config.getProdAppId(), async () => { const prodLogs = await config.getAutomationLogs()
const logs = await config.getAutomationLogs() expect(prodLogs.data.length).toBe(1)
expect(logs.data.length).toBe(1)
})
// delete prod app so we revert to dev log search // delete prod app so we revert to dev log search
await config.unpublish() await config.unpublish()
// doesn't exist in dev // doesn't exist in dev
await context.doInAppContext(config.getAppId(), async () => { const devLogs = await config.getAutomationLogs()
const logs = await config.getAutomationLogs() expect(devLogs.data.length).toBe(0)
expect(logs.data.length).toBe(0)
})
}) })
}) })
}) })

View File

@ -21,7 +21,7 @@ import {
basicScreen, basicScreen,
basicLayout, basicLayout,
basicWebhook, basicWebhook,
basicAutomationLog, basicAutomationResults,
} from "./structures" } from "./structures"
import { import {
constants, constants,
@ -728,15 +728,17 @@ class TestConfiguration {
return await context.doInAppContext(this.getProdAppId(), async () => { return await context.doInAppContext(this.getProdAppId(), async () => {
return await pro.sdk.automations.logs.storeLog( return await pro.sdk.automations.logs.storeLog(
automation, automation,
basicAutomationLog(automation._id!) basicAutomationResults(automation._id!)
) )
}) })
} }
async getAutomationLogs() { async getAutomationLogs() {
const now = new Date() return context.doInAppContext(this.appId, async () => {
return await pro.sdk.automations.logs.logSearch({ const now = new Date()
startDate: new Date(now.getTime() - 100000).toISOString(), return await pro.sdk.automations.logs.logSearch({
startDate: new Date(now.getTime() - 100000).toISOString(),
})
}) })
} }

View File

@ -243,7 +243,9 @@ export function collectAutomation(tableId?: string): Automation {
return automation as Automation return automation as Automation
} }
export function basicAutomationLog(automationId: string): AutomationResults { export function basicAutomationResults(
automationId: string
): AutomationResults {
return { return {
automationId, automationId,
status: AutomationStatus.SUCCESS, status: AutomationStatus.SUCCESS,