feat: 同步管理端、用户端与后端业务,并接通线上 Web 接口
补齐平台订阅、外部登录、CRM 同步与用户端页面;Nginx 转发用户端接口,登录页使用 Google 与 Apple 标志。 Co-authored-by: Cursor <cursoragent@cursor.com>
这个提交包含在:
@@ -9,6 +9,7 @@ import {
|
||||
import {
|
||||
TeamQuotaService,
|
||||
DEFAULT_PLAN_PRICES,
|
||||
DEFAULT_PLAN_LIMITS,
|
||||
} from '../../../src/modules/team/service/quota';
|
||||
import type {
|
||||
PlanLimits,
|
||||
@@ -196,23 +197,23 @@ describe('Point 23: 企业多坐席配额用量预警与升级差价计算 单
|
||||
});
|
||||
});
|
||||
|
||||
it('3.2 当前用量已达上限时,抛出 RESOURCE_LIMIT_EXCEEDED 阻断异常', async () => {
|
||||
it('3.2 当前用量已达上限时,抛出 CoolCommException 且中文说明已达上限', async () => {
|
||||
await expect(
|
||||
quotaService.assertQuotaAvailable(101, 'seats', 1, {
|
||||
plan: 'free',
|
||||
currentUsed: 1,
|
||||
})
|
||||
).rejects.toThrow('RESOURCE_LIMIT_EXCEEDED');
|
||||
).rejects.toThrow(/已达上限/);
|
||||
});
|
||||
|
||||
it('3.3 增加批次数量 (additionalCount) 导致超限时,同样抛出 RESOURCE_LIMIT_EXCEEDED', async () => {
|
||||
it('3.3 增加批次数量 (additionalCount) 导致超限时,同样抛出已达上限', async () => {
|
||||
// 当前 8/10,增加 3 个 => 11 > 10,应拦截阻断
|
||||
await expect(
|
||||
quotaService.assertQuotaAvailable(101, 'seats', 3, {
|
||||
plan: 'pro',
|
||||
currentUsed: 8,
|
||||
})
|
||||
).rejects.toThrow('RESOURCE_LIMIT_EXCEEDED');
|
||||
).rejects.toThrow(/已达上限/);
|
||||
|
||||
// 增加 2 个 => 10 <= 10,刚好达标,不抛出
|
||||
await expect(
|
||||
@@ -223,7 +224,7 @@ describe('Point 23: 企业多坐席配额用量预警与升级差价计算 单
|
||||
).resolves.toBeDefined();
|
||||
});
|
||||
|
||||
it('3.4 异常类型必须为 CoolCommException', async () => {
|
||||
it('3.4 异常类型必须为 CoolCommException,名片超限文案含已达上限', async () => {
|
||||
try {
|
||||
await quotaService.assertQuotaAvailable(101, 'cards', 1, {
|
||||
plan: 'free',
|
||||
@@ -232,7 +233,129 @@ describe('Point 23: 企业多坐席配额用量预警与升级差价计算 单
|
||||
fail('应当抛出异常');
|
||||
} catch (err) {
|
||||
expect(err).toBeInstanceOf(CoolCommException);
|
||||
expect((err as CoolCommException).message).toContain('RESOURCE_LIMIT_EXCEEDED');
|
||||
expect((err as CoolCommException).message).toContain('已达上限');
|
||||
expect((err as CoolCommException).message).toContain('名片');
|
||||
}
|
||||
});
|
||||
|
||||
it('3.5 P33: Free 套餐名片配额用尽时阻断新增,文案为中文已达上限', async () => {
|
||||
await expect(
|
||||
quotaService.assertQuotaAvailable(101, 'cards', 1, {
|
||||
plan: 'free',
|
||||
currentUsed: 1,
|
||||
})
|
||||
).rejects.toMatchObject({
|
||||
message: '当前套餐名片配额已达上限,请升级套餐',
|
||||
});
|
||||
});
|
||||
|
||||
it('3.6 P33: Pro 套餐名片未超限时允许新增', async () => {
|
||||
await expect(
|
||||
quotaService.assertQuotaAvailable(101, 'cards', 1, {
|
||||
plan: 'pro',
|
||||
currentUsed: 4,
|
||||
})
|
||||
).resolves.toMatchObject({
|
||||
used: 4,
|
||||
limit: 5,
|
||||
exceeded: false,
|
||||
});
|
||||
});
|
||||
|
||||
it('3.7 R45: Free 名片上限必须来自套餐配置,按配置值放行', async () => {
|
||||
expect(DEFAULT_PLAN_LIMITS.free.cardsLimit).toBe(1);
|
||||
await expect(
|
||||
quotaService.assertQuotaAvailable(101, 'cards', 1, {
|
||||
plan: 'free',
|
||||
currentUsed: 0,
|
||||
})
|
||||
).resolves.toMatchObject({
|
||||
used: 0,
|
||||
limit: DEFAULT_PLAN_LIMITS.free.cardsLimit,
|
||||
exceeded: false,
|
||||
});
|
||||
});
|
||||
|
||||
it('3.8 R45: Free 套餐未配置 cardsLimit 时拒绝新增,不得当成无限', async () => {
|
||||
const original = DEFAULT_PLAN_LIMITS.free.cardsLimit;
|
||||
try {
|
||||
delete (DEFAULT_PLAN_LIMITS.free as { cardsLimit?: number }).cardsLimit;
|
||||
await expect(
|
||||
quotaService.assertQuotaAvailable(101, 'cards', 1, {
|
||||
plan: 'free',
|
||||
currentUsed: 0,
|
||||
})
|
||||
).rejects.toThrow(/未配置|未设置/);
|
||||
await expect(
|
||||
quotaService.assertQuotaAvailable(101, 'cards', 1, {
|
||||
plan: 'free',
|
||||
currentUsed: 0,
|
||||
})
|
||||
).rejects.toBeInstanceOf(CoolCommException);
|
||||
} finally {
|
||||
DEFAULT_PLAN_LIMITS.free.cardsLimit = original;
|
||||
}
|
||||
});
|
||||
|
||||
it('3.9 R45: Free 套餐 cardsLimit 为 NaN/Infinity 视为未设置上限,拒绝新增', async () => {
|
||||
const original = DEFAULT_PLAN_LIMITS.free.cardsLimit;
|
||||
try {
|
||||
DEFAULT_PLAN_LIMITS.free.cardsLimit = Number.NaN;
|
||||
await expect(
|
||||
quotaService.assertQuotaAvailable(101, 'cards', 1, {
|
||||
plan: 'free',
|
||||
currentUsed: 0,
|
||||
})
|
||||
).rejects.toThrow(/未配置|未设置/);
|
||||
|
||||
DEFAULT_PLAN_LIMITS.free.cardsLimit = Number.POSITIVE_INFINITY;
|
||||
await expect(
|
||||
quotaService.assertQuotaAvailable(101, 'cards', 1, {
|
||||
plan: 'free',
|
||||
currentUsed: 0,
|
||||
})
|
||||
).rejects.toThrow(/未配置|未设置/);
|
||||
} finally {
|
||||
DEFAULT_PLAN_LIMITS.free.cardsLimit = original;
|
||||
}
|
||||
});
|
||||
|
||||
it('3.10 R45: 未配置上限的拒绝文案不得冒充 P33 配额用尽文案', async () => {
|
||||
const original = DEFAULT_PLAN_LIMITS.free.cardsLimit;
|
||||
try {
|
||||
delete (DEFAULT_PLAN_LIMITS.free as { cardsLimit?: number }).cardsLimit;
|
||||
try {
|
||||
await quotaService.assertQuotaAvailable(101, 'cards', 1, {
|
||||
plan: 'free',
|
||||
currentUsed: 0,
|
||||
});
|
||||
fail('应当抛出异常');
|
||||
} catch (err) {
|
||||
expect(err).toBeInstanceOf(CoolCommException);
|
||||
expect((err as CoolCommException).message).not.toBe(
|
||||
'当前套餐名片配额已达上限,请升级套餐'
|
||||
);
|
||||
expect((err as CoolCommException).message).toMatch(/未配置|未设置/);
|
||||
}
|
||||
} finally {
|
||||
DEFAULT_PLAN_LIMITS.free.cardsLimit = original;
|
||||
}
|
||||
});
|
||||
|
||||
it('3.11 R45: checkQuota 在未配置上限时 exceeded=true、remaining=0,不得当成无限', async () => {
|
||||
const original = DEFAULT_PLAN_LIMITS.free.cardsLimit;
|
||||
try {
|
||||
delete (DEFAULT_PLAN_LIMITS.free as { cardsLimit?: number }).cardsLimit;
|
||||
const result = await quotaService.checkQuota(101, 'cards', {
|
||||
plan: 'free',
|
||||
currentUsed: 0,
|
||||
});
|
||||
expect(result.limit).toBe(0);
|
||||
expect(result.remaining).toBe(0);
|
||||
expect(result.exceeded).toBe(true);
|
||||
expect(result.percentage).toBe(100);
|
||||
} finally {
|
||||
DEFAULT_PLAN_LIMITS.free.cardsLimit = original;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
在新工单中引用
屏蔽一个用户