fix(微信订阅): 字段名按微信真实模板校准,不再靠猜编号;phrase 只截断不补齐

This commit is contained in:
2026-10-24 10:18:57 +08:00
parent c51b7c660a
commit dc2565da34
8 changed files with 701 additions and 49 deletions
+5 -5
View File
@@ -28,10 +28,10 @@ test('thing 型:20 字以内原样,超了截 19 字 + 省略号(正好 20
assert.ok(long.startsWith(clamped.slice(0, 19)))
})
test('phrase 型:5 个以内纯汉字——“已排期”会被补成全角 5 字,不是原样发出去', () => {
const padded = clampField('phrase5', '已排期')
assert.equal(len(padded), 5)
assert.ok(padded.startsWith('已排期'))
test('phrase 型:5 个以内纯汉字——短的原样发(不补全角空格),超了截到 5', () => {
// 「已排期」3 个汉字本来就合规,绝不能补成 "已排期  "(U+3000 不是汉字,会 47003)
assert.equal(clampField('phrase5', '已排期'), '已排期')
assert.equal(clampField('phrase5', '已排期').includes(' '), false)
// 刚好 5 个汉字原样保留
assert.equal(clampField('phrase5', '已排期播放'), '已排期播放')
@@ -106,7 +106,7 @@ test('SONG_SELECTED 的内置字段映射:每个字段名后缀都要跟发出
assert.equal(out.date4, '2026-02-14')
assert.match(out.time1, /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}$/)
assert.equal(out.character_string3, '1')
assert.equal(len(out.phrase5), 5) // “已排期” 3 字 → 补齐到 5 字,避开 47003
assert.equal(out.phrase5, '已排期') // 3 个汉字本来就合规,不补全角空格
// 不能有任何字段是空值:空值同样会被微信拒
for (const key of Object.keys(out)) assert.ok(out[key].length > 0, key + ' 不能为空')
})