feat: optimize routing and operations views

This commit is contained in:
hectorzhao
2026-07-29 22:32:28 +08:00
parent 500f43f673
commit c0a4317a7e
21 changed files with 718 additions and 86 deletions
@@ -11,6 +11,8 @@ function createPrismaMock() {
phoneCarrierRule: {
findMany: jest.fn().mockResolvedValue([]),
count: jest.fn().mockResolvedValue(0),
create: jest.fn().mockImplementation(({ data }) => Promise.resolve({ id: 'rule-1', ...data })),
delete: jest.fn().mockResolvedValue({ id: 'rule-1' }),
},
sensitiveWord: {
findMany: jest.fn(),
@@ -210,6 +212,17 @@ describe('DictionariesService', () => {
expect(prisma.phoneCarrierRule.count).toHaveBeenCalledWith({ where: { OR: expect.any(Array) } });
});
it('invalidates the sending cache after carrier rule changes', async () => {
const prisma = createPrismaMock();
const phoneRoutingLookup = { invalidateCarrierRules: jest.fn() };
const service = new DictionariesService(prisma as never, phoneRoutingLookup as never);
await service.createPhoneCarrierRule({ carrier: 'mobile', pattern: '^138' });
await service.deletePhoneCarrierRule('rule-1');
expect(phoneRoutingLookup.invalidateCarrierRules).toHaveBeenCalledTimes(2);
});
it('creates and soft deletes blacklist and sensitive word entries with operation logs', async () => {
const prisma = createPrismaMock();
const service = new DictionariesService(prisma as never);