Spaces:
Runtime error
Runtime error
File size: 953 Bytes
46252cd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | import { ForbiddenException } from '@nestjs/common';
import { EngineRefusedError } from './engine-refused.error';
// A WhatsApp-side refusal (editing someone else's message, a settings write without admin rights)
// thrown as a generic Error surfaces as HTTP 500. EngineRefusedError extends ForbiddenException so
// NestJS maps it to 403 through the built-in handler (no global filter) — same mapping discipline
// as CallNotFoundError.
describe('EngineRefusedError', () => {
it('is a ForbiddenException -> HTTP 403 without a custom global filter', () => {
const err = new EngineRefusedError('admin rights required');
expect(err).toBeInstanceOf(ForbiddenException);
expect(err.getStatus()).toBe(403);
});
it('carries the refusal detail as the message', () => {
expect(new EngineRefusedError("only the account's own messages can be edited").message).toBe(
"only the account's own messages can be edited",
);
});
});
|