This commit is contained in:
Your Name
2026-09-01 10:42:16 +08:00
parent 456dd667df
commit 5bd5eae62d
358 changed files with 2276 additions and 495 deletions
@@ -4,7 +4,7 @@ import ts from '../../admin/node_modules/typescript/lib/typescript.js'
const source = fs.readFileSync(new URL('../../admin/src/views/first_visit/wecom_promotion/components/promotion-automation.ts', import.meta.url), 'utf8')
const compiled = ts.transpileModule(source, { compilerOptions: { target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.ESNext } }).outputText
const { defaultAutomationConfig, cloneAutomationConfig, validateAutomationConfig, validateCustomTagName, validateWelcomeMessage, welcomeScheduleOverlap, previewTemplate } = await import(`data:text/javascript;base64,${Buffer.from(compiled).toString('base64')}`)
const { defaultAutomationConfig, cloneAutomationConfig, serializeAutomationConfig, validateAutomationConfig, validateCustomTagName, validateWelcomeMessage, welcomeScheduleOverlap, previewTemplate } = await import(`data:text/javascript;base64,${Buffer.from(compiled).toString('base64')}`)
const defaults = defaultAutomationConfig()
assert.equal(validateAutomationConfig(defaults, [1]), '')
@@ -19,6 +19,16 @@ assert.equal(validateAutomationConfig(configured, [1]), '')
const copy = cloneAutomationConfig(configured)
assert.equal(copy.backup_userids, undefined)
assert.equal(copy.reception_schedule[0].member_userids, undefined)
assert.deepEqual(
Object.fromEntries(Object.entries(serializeAutomationConfig({
...copy,
tags_enabled: true,
remark_enabled: false,
description_enabled: true,
welcome_schedule_enabled: false
})).filter(([key]) => key.endsWith('_enabled'))),
{ tags_enabled: 1, remark_enabled: 0, description_enabled: 1, welcome_schedule_enabled: 0 }
)
copy.reception_schedule[0].weekdays.push(2)
assert.deepEqual(configured.reception_schedule[0].weekdays, [1])
assert.match(validateAutomationConfig({ ...configured, backup_member_admin_ids: [] }, [1]), /备用/)