fix: close documented platform polish gaps

This commit is contained in:
hectorzhao
2026-07-11 18:20:38 +08:00
parent 6236547871
commit 2ecbb920a6
25 changed files with 193 additions and 110 deletions
+12 -1
View File
@@ -279,7 +279,7 @@ describe('ChannelsService', () => {
};
await expect(service.createChannel({ ...channel, rateLimitPerSecond: 2001 })).rejects.toThrow('rateLimitPerSecond must be between 1 and 2000');
await expect(service.createChannel({ ...channel, config: { extensionDigits: 3 } })).rejects.toThrow('extensionDigits must be one of 0, 2, 4, or 6');
await expect(service.createChannel({ ...channel, config: { extensionDigits: 21 } })).rejects.toThrow('extensionDigits must be an integer between 0 and 20');
});
it('updates CMPP channel configuration without requiring password changes', async () => {
@@ -326,6 +326,17 @@ describe('ChannelsService', () => {
});
});
it('persists an arbitrary integer extension digit count within the supported range', async () => {
const prisma = createPrismaMock();
const service = new ChannelsService(prisma as never);
await service.updateChannel('channel-1', { config: { extensionDigits: 15 } });
expect(prisma.smsChannel.update).toHaveBeenCalledWith(expect.objectContaining({
data: expect.objectContaining({ config: expect.objectContaining({ extensionDigits: 15 }) }),
}));
});
it('rejects invalid channel update ports', async () => {
const prisma = createPrismaMock();
const service = new ChannelsService(prisma as never);
+2 -2
View File
@@ -1417,8 +1417,8 @@ function normalizeExtensionDigits(value: unknown) {
return 0;
}
const normalized = Number(value);
if (![0, 2, 4, 6].includes(normalized)) {
throw new BadRequestException('extensionDigits must be one of 0, 2, 4, or 6');
if (!Number.isInteger(normalized) || normalized < 0 || normalized > 20) {
throw new BadRequestException('extensionDigits must be an integer between 0 and 20');
}
return normalized;
}