n8n/packages/workflow/test/errors/policy-refusal.test.ts
Guillaume Jacquart 9191cf3fb0
fix(core): Apply the credential type policy to credential tests and probes (#39927)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 19:16:11 +00:00

25 lines
780 B
TypeScript

import { hasPolicyRefusalMarker } from '../../src/errors';
describe('hasPolicyRefusalMarker', () => {
it('recognises an error that carries the marker as an own property', () => {
const refusal = Object.assign(new Error('Blocked'), { isPolicyRefusal: true });
expect(hasPolicyRefusalMarker(refusal)).toBe(true);
});
it('does not recognise an inherited marker', () => {
const inherited = Object.create({ isPolicyRefusal: true }) as object;
expect(hasPolicyRefusalMarker(inherited)).toBe(false);
});
it.each([
['an ordinary error', new Error('boom')],
['a non-true marker', { isPolicyRefusal: 'yes' }],
['null', null],
['undefined', undefined],
])('does not recognise %s', (_label, value) => {
expect(hasPolicyRefusalMarker(value)).toBe(false);
});
});