Files
CRM_Montzar/apps/api/test/platform-admin-alert.test.ts
T
MahdiandCursor 463a1652a6 feat(platform): text admins when an account opens or a subscription ends
Signup and admin-created accounts notify platform managers, and an ended plan sends one SMS instead of repeating for old expirations.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-27 22:27:05 +03:30

41 lines
1.4 KiB
TypeScript

import assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import { newAccountSms, subscriptionEndedSms } from '../src/billing/platform-admin-alert';
describe('پیامک مدیران پنل ادمین', () => {
it('ثبت‌نام و ساخت از پنل را جدا می‌نویسد', () => {
const signup = newAccountSms({
source: 'signup',
organizationName: 'بی اس جی',
ownerName: 'رضا بهرامی',
mobile: '09120000000',
});
assert.match(signup, /حساب جدید \(ثبت‌نام\)/);
assert.match(signup, /بی اس جی/);
assert.match(signup, /09120000000/);
const admin = newAccountSms({
source: 'admin',
organizationName: 'کارگاه',
ownerName: 'علی',
mobile: null,
});
assert.match(admin, /پنل ادمین/);
assert.match(admin, /ندارد/);
});
it('پایان اشتراک پلن و تاریخ شمسی دارد', () => {
const text = subscriptionEndedSms({
organizationNames: ['الف', 'ب', 'ج', 'د'],
ownerName: 'مریم',
mobile: '09121111111',
planCode: 'monthly',
expiresAt: new Date('2026-10-27T12:00:00.000Z'),
});
assert.match(text, /پایان اشتراک/);
assert.match(text, /ماهانه/);
assert.match(text, /و 1 محیط دیگر/);
assert.match(text, /۱۴۰۵/);
});
});