cmvr-wms/mobile-app/tests/assistant-notification.test.mjs

15 lines
1.4 KiB
JavaScript
Raw Normal View History

import test from 'node:test'
import assert from 'node:assert/strict'
import { draftReviewCount, draftNeedsRichNoticeReview } from '../src/core/assistant-display.ts'
test('broadcast review counts recipients so the existing twenty item confirmation guard applies', () => {
assert.equal(draftReviewCount({ action: 'notification.send', rows: [{ _notificationPreview: { recipientCount: 401, recipients: [{ id: 1 }] } }] }), 401)
assert.equal(draftReviewCount({ action: 'notification.send', rows: [{ _notificationPreview: { recipients: Array.from({ length: 21 }, (_, id) => ({ id })) } }] }), 21)
assert.equal(draftReviewCount({ action: 'notification.send', rows: [{ _notificationPreview: { recipientCount: 3 } }, { _notificationPreview: { recipientCount: 2 } }] }), 5)
assert.equal(draftReviewCount({ action: 'purchase.referencePrice', rows: [{ _referencePricePreview: [1, 2] }] }), 2)
})
test('image announcements require full graphical review on web, without blocking ordinary inbox drafts', () => {
assert.equal(draftNeedsRichNoticeReview({ action: 'notice.create', rows: [{ noticeContent: '<p>说明</p><img src="/static/assistant-guides/feedback-1.svg">' }] }), true)
assert.equal(draftNeedsRichNoticeReview({ action: 'notice.update', rows: [{ noticeContent: '<IMG src="/a.png">' }] }), true)
assert.equal(draftNeedsRichNoticeReview({ action: 'notification.send', rows: [{ content: '普通通知' }] }), false)
})