chore(tests): remove deprecated test files for schedule and webhook triggers

This commit is contained in:
zhsama
2025-10-28 22:42:29 +08:00
parent 71b1af69c5
commit 720480d05e
9 changed files with 0 additions and 1882 deletions

View File

@ -1,106 +0,0 @@
/**
* Webhook Trigger Node Default Tests
*
* Tests for webhook trigger node default configuration and field validation.
* Tests core checkValid functionality following project patterns.
*/
import nodeDefault from '../default'
import type { WebhookTriggerNodeType } from '../types'
// Simple mock translation function
const mockT = (key: string, params?: any) => {
const translations: Record<string, string> = {
'workflow.nodes.triggerWebhook.validation.webhookUrlRequired': 'Webhook URL is required',
'workflow.nodes.triggerWebhook.validation.invalidParameterType': `Invalid parameter type ${params?.type} for ${params?.name}`,
}
if (key.includes('fieldRequired')) return `${params?.field} is required`
return translations[key] || key
}
describe('Webhook Trigger Node Default', () => {
describe('Basic Configuration', () => {
it('should have correct default values for all backend fields', () => {
const defaultValue = nodeDefault.defaultValue
// Core webhook configuration
expect(defaultValue.webhook_url).toBe('')
expect(defaultValue.method).toBe('POST')
expect(defaultValue.content_type).toBe('application/json')
// Response configuration fields
expect(defaultValue.async_mode).toBe(true)
expect(defaultValue.status_code).toBe(200)
expect(defaultValue.response_body).toBe('')
// Parameter arrays
expect(Array.isArray(defaultValue.headers)).toBe(true)
expect(Array.isArray(defaultValue.params)).toBe(true)
expect(Array.isArray(defaultValue.body)).toBe(true)
expect(Array.isArray(defaultValue.variables)).toBe(true)
// Initial arrays should be empty
expect(defaultValue.headers).toHaveLength(0)
expect(defaultValue.params).toHaveLength(0)
expect(defaultValue.body).toHaveLength(0)
expect(defaultValue.variables).toHaveLength(1)
const rawVariable = defaultValue.variables?.[0]
expect(rawVariable?.variable).toBe('_webhook_raw')
expect(rawVariable?.label).toBe('raw')
expect(rawVariable?.value_type).toBe('object')
})
it('should have correct metadata for trigger node', () => {
expect(nodeDefault.metaData).toBeDefined()
expect(nodeDefault.metaData.type).toBe('trigger-webhook')
expect(nodeDefault.metaData.sort).toBe(3)
expect(nodeDefault.metaData.isStart).toBe(true)
})
})
describe('Validation - checkValid', () => {
it('should require webhook_url to be configured', () => {
const payload = nodeDefault.defaultValue as WebhookTriggerNodeType
const result = nodeDefault.checkValid(payload, mockT)
expect(result.isValid).toBe(false)
expect(result.errorMessage).toContain('required')
})
it('should validate successfully when webhook_url is provided', () => {
const payload = {
...nodeDefault.defaultValue,
webhook_url: 'https://example.com/webhook',
} as WebhookTriggerNodeType
const result = nodeDefault.checkValid(payload, mockT)
expect(result.isValid).toBe(true)
expect(result.errorMessage).toBe('')
})
it('should handle response configuration fields when webhook_url is provided', () => {
const payload = {
...nodeDefault.defaultValue,
webhook_url: 'https://example.com/webhook',
status_code: 404,
response_body: '{"error": "Not found"}',
} as WebhookTriggerNodeType
const result = nodeDefault.checkValid(payload, mockT)
expect(result.isValid).toBe(true)
})
it('should handle async_mode field correctly when webhook_url is provided', () => {
const payload = {
...nodeDefault.defaultValue,
webhook_url: 'https://example.com/webhook',
async_mode: false,
} as WebhookTriggerNodeType
const result = nodeDefault.checkValid(payload, mockT)
expect(result.isValid).toBe(true)
})
})
})

View File

@ -1,81 +0,0 @@
import {
createParameterTypeOptions,
getAvailableParameterTypes,
isValidParameterType,
normalizeParameterType,
} from './parameter-type-utils'
describe('Parameter Type Utils', () => {
describe('isValidParameterType', () => {
it('should validate specific array types', () => {
expect(isValidParameterType('array[string]')).toBe(true)
expect(isValidParameterType('array[number]')).toBe(true)
expect(isValidParameterType('array[boolean]')).toBe(true)
expect(isValidParameterType('array[object]')).toBe(true)
})
it('should validate basic types', () => {
expect(isValidParameterType('string')).toBe(true)
expect(isValidParameterType('number')).toBe(true)
expect(isValidParameterType('boolean')).toBe(true)
expect(isValidParameterType('object')).toBe(true)
expect(isValidParameterType('file')).toBe(true)
})
it('should reject invalid types', () => {
expect(isValidParameterType('array')).toBe(false)
expect(isValidParameterType('invalid')).toBe(false)
expect(isValidParameterType('array[invalid]')).toBe(false)
})
})
describe('normalizeParameterType', () => {
it('should normalize valid types', () => {
expect(normalizeParameterType('string')).toBe('string')
expect(normalizeParameterType('array[string]')).toBe('array[string]')
})
it('should migrate legacy array type', () => {
expect(normalizeParameterType('array')).toBe('array[string]')
})
it('should default to string for invalid types', () => {
expect(normalizeParameterType('invalid')).toBe('string')
})
})
describe('getAvailableParameterTypes', () => {
it('should return only string for non-request body', () => {
const types = getAvailableParameterTypes('application/json', false)
expect(types).toEqual(['string'])
})
it('should return all types for application/json', () => {
const types = getAvailableParameterTypes('application/json', true)
expect(types).toContain('string')
expect(types).toContain('number')
expect(types).toContain('boolean')
expect(types).toContain('array[string]')
expect(types).toContain('array[number]')
expect(types).toContain('array[boolean]')
expect(types).toContain('array[object]')
expect(types).toContain('object')
})
it('should include file type for multipart/form-data', () => {
const types = getAvailableParameterTypes('multipart/form-data', true)
expect(types).toContain('file')
})
})
describe('createParameterTypeOptions', () => {
it('should create options with display names', () => {
const options = createParameterTypeOptions('application/json', true)
const stringOption = options.find(opt => opt.value === 'string')
const arrayStringOption = options.find(opt => opt.value === 'array[string]')
expect(stringOption?.name).toBe('String')
expect(arrayStringOption?.name).toBe('Array[String]')
})
})
})