update tests, lint

This commit is contained in:
Charles Driesler
2024-05-30 13:03:23 +01:00
parent fb7a095967
commit d34bae6f5e
2 changed files with 25 additions and 1 deletions
@@ -218,7 +218,7 @@ export const triggerAutomationMutation = graphql(`
export const createTestAutomationMutation = graphql(`
mutation CreateTestAutomation(
$projectId: ID!,
$projectId: ID!
$input: ProjectTestAutomationCreateInput!
) {
projectMutations {
@@ -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<string, BaseTriggerManifest> = {}
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<string, BaseTriggerManifest> = {}
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<T>[],
@@ -234,6 +256,8 @@ const { FF_AUTOMATE_MODULE_ENABLED } = Environment.getFeatureFlags()
const triggered: Record<string, VersionCreatedTriggerManifest> = {}
const versionId = cryptoRandomString({ length: 10 })
await onModelVersionCreate({
getAutomation: async () => ({} as AutomationRecord),
getAutomationRevision: async () => ({} as AutomationRevisionRecord),
getTriggers: async <
T extends AutomationTriggerType = AutomationTriggerType
>() => storedTriggers as AutomationTriggerDefinitionRecord<T>[],