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 () => {
// setup the apps
await config.createApp("testing-auto-logs")
@ -344,19 +344,15 @@ describe("/applications", () => {
.expect(200)
// does exist in prod
await context.doInAppContext(config.getProdAppId(), async () => {
const logs = await config.getAutomationLogs()
expect(logs.data.length).toBe(1)
})
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
await context.doInAppContext(config.getAppId(), async () => {
const logs = await config.getAutomationLogs()
expect(logs.data.length).toBe(0)
})
const devLogs = await config.getAutomationLogs()
expect(devLogs.data.length).toBe(0)
})
})
})

View File

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