diff --git a/packages/server/src/api/routes/tests/application.spec.ts b/packages/server/src/api/routes/tests/application.spec.ts index 207d25d508..fa5cb0a983 100644 --- a/packages/server/src/api/routes/tests/application.spec.ts +++ b/packages/server/src/api/routes/tests/application.spec.ts @@ -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) }) }) }) diff --git a/packages/server/src/tests/utilities/TestConfiguration.ts b/packages/server/src/tests/utilities/TestConfiguration.ts index 26f70ec845..2078bf765a 100644 --- a/packages/server/src/tests/utilities/TestConfiguration.ts +++ b/packages/server/src/tests/utilities/TestConfiguration.ts @@ -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(), + }) }) } diff --git a/packages/server/src/tests/utilities/structures.ts b/packages/server/src/tests/utilities/structures.ts index 02c62b85ba..0a9a9d5a68 100644 --- a/packages/server/src/tests/utilities/structures.ts +++ b/packages/server/src/tests/utilities/structures.ts @@ -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,