From d34bae6f5ee2f09ae861c9ce36aa4eb7e77463f1 Mon Sep 17 00:00:00 2001 From: Charles Driesler Date: Thu, 30 May 2024 13:03:23 +0100 Subject: [PATCH] update tests, lint --- .../lib/projects/graphql/mutations.ts | 2 +- .../modules/automate/tests/trigger.spec.ts | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/packages/frontend-2/lib/projects/graphql/mutations.ts b/packages/frontend-2/lib/projects/graphql/mutations.ts index ff8415c47..216ebd072 100644 --- a/packages/frontend-2/lib/projects/graphql/mutations.ts +++ b/packages/frontend-2/lib/projects/graphql/mutations.ts @@ -218,7 +218,7 @@ export const triggerAutomationMutation = graphql(` export const createTestAutomationMutation = graphql(` mutation CreateTestAutomation( - $projectId: ID!, + $projectId: ID! $input: ProjectTestAutomationCreateInput! ) { projectMutations { diff --git a/packages/server/modules/automate/tests/trigger.spec.ts b/packages/server/modules/automate/tests/trigger.spec.ts index 3476268ae..5316d249a 100644 --- a/packages/server/modules/automate/tests/trigger.spec.ts +++ b/packages/server/modules/automate/tests/trigger.spec.ts @@ -11,6 +11,7 @@ import { } from '@/modules/automate/services/trigger' import { AutomationRecord, + AutomationRevisionRecord, AutomationRunStatuses, AutomationTriggerDefinitionRecord, AutomationTriggerType, @@ -159,6 +160,25 @@ const { FF_AUTOMATE_MODULE_ENABLED } = Environment.getFeatureFlags() it('No trigger no run', async () => { const triggered: Record = {} await onModelVersionCreate({ + getAutomation: async () => ({} as AutomationRecord), + getAutomationRevision: async () => ({} as AutomationRevisionRecord), + getTriggers: async () => [], + triggerFunction: async ({ manifest, revisionId }) => { + triggered[revisionId] = manifest + return { automationRunId: cryptoRandomString({ length: 10 }) } + } + })({ + modelId: cryptoRandomString({ length: 10 }), + versionId: cryptoRandomString({ length: 10 }), + projectId: cryptoRandomString({ length: 10 }) + }) + expect(Object.keys(triggered)).length(0) + }) + it('Does not trigger test automations', async () => { + const triggered: Record = {} + await onModelVersionCreate({ + getAutomation: async () => ({ isTestAutomation: true } as AutomationRecord), + getAutomationRevision: async () => ({} as AutomationRevisionRecord), getTriggers: async () => [], triggerFunction: async ({ manifest, revisionId }) => { triggered[revisionId] = manifest @@ -191,6 +211,8 @@ const { FF_AUTOMATE_MODULE_ENABLED } = Environment.getFeatureFlags() const projectId = cryptoRandomString({ length: 10 }) await onModelVersionCreate({ + getAutomation: async () => ({} as AutomationRecord), + getAutomationRevision: async () => ({} as AutomationRevisionRecord), getTriggers: async < T extends AutomationTriggerType = AutomationTriggerType >() => storedTriggers as AutomationTriggerDefinitionRecord[], @@ -234,6 +256,8 @@ const { FF_AUTOMATE_MODULE_ENABLED } = Environment.getFeatureFlags() const triggered: Record = {} const versionId = cryptoRandomString({ length: 10 }) await onModelVersionCreate({ + getAutomation: async () => ({} as AutomationRecord), + getAutomationRevision: async () => ({} as AutomationRevisionRecord), getTriggers: async < T extends AutomationTriggerType = AutomationTriggerType >() => storedTriggers as AutomationTriggerDefinitionRecord[],