mirror of
https://github.com/n8n-io/n8n.git
synced 2026-08-28 17:22:01 +08:00
59 lines
2.2 KiB
TypeScript
59 lines
2.2 KiB
TypeScript
import { NodeOperationError } from 'n8n-workflow';
|
|
|
|
import { Confluence } from '../Confluence.node';
|
|
import { mockExecuteCtx } from './shared';
|
|
|
|
describe('Confluence Node', () => {
|
|
const node = new Confluence();
|
|
|
|
const operationOptions = (resource: string) =>
|
|
node.description.properties.find(
|
|
(p) => p.name === 'operation' && p.displayOptions?.show?.resource?.includes(resource),
|
|
)?.options;
|
|
|
|
it('should stay hidden and off the AI-tool surface while operations land', () => {
|
|
expect(node.description.hidden).toBe(true);
|
|
expect(node.description.properties.length).toBeGreaterThan(0);
|
|
expect(node.description.usableAsTool).toBeUndefined();
|
|
});
|
|
|
|
it('should expose the attachment, page and search resources with their operations', () => {
|
|
const resource = node.description.properties.find((p) => p.name === 'resource');
|
|
expect(resource?.options).toEqual([
|
|
expect.objectContaining({ value: 'attachment' }),
|
|
expect.objectContaining({ value: 'page' }),
|
|
expect.objectContaining({ value: 'search' }),
|
|
]);
|
|
|
|
expect(operationOptions('attachment')).toEqual([expect.objectContaining({ value: 'getMany' })]);
|
|
expect(operationOptions('page')).toEqual([
|
|
expect.objectContaining({ value: 'append' }),
|
|
expect.objectContaining({ value: 'create' }),
|
|
expect.objectContaining({ value: 'delete' }),
|
|
expect.objectContaining({ value: 'get' }),
|
|
expect.objectContaining({ value: 'getManyByLabel' }),
|
|
expect.objectContaining({ value: 'update' }),
|
|
]);
|
|
expect(operationOptions('search')).toEqual([expect.objectContaining({ value: 'query' })]);
|
|
});
|
|
|
|
it('should reference the confluenceCloudOAuth2Api credential by name', () => {
|
|
expect(node.description.credentials).toEqual([
|
|
{ name: 'confluenceCloudOAuth2Api', required: true },
|
|
]);
|
|
});
|
|
|
|
it('should register under the confluence name', () => {
|
|
expect(node.description.name).toBe('confluence');
|
|
expect(node.description.displayName).toBe('Confluence');
|
|
expect(node.description.version).toBe(1);
|
|
});
|
|
|
|
it('should throw a NodeOperationError when executed without an operation', async () => {
|
|
const promise = node.execute.call(mockExecuteCtx({}));
|
|
|
|
await expect(promise).rejects.toThrow(NodeOperationError);
|
|
await expect(promise).rejects.toThrow('The operation ":" is not supported');
|
|
});
|
|
});
|