mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 04:39:34 +00:00
fix(plugin-workflow-request): fix error message for test request node (#5443)
* fix(plugin-workflow-request): fix error message for test request node * fix(plugin-workflow-request): fix type
This commit is contained in:
parent
486f76fa46
commit
50056439d9
@ -19,7 +19,7 @@ import { MockServer } from '@nocobase/test';
|
|||||||
import PluginWorkflow, { EXECUTION_STATUS, JOB_STATUS, Processor } from '@nocobase/plugin-workflow';
|
import PluginWorkflow, { EXECUTION_STATUS, JOB_STATUS, Processor } from '@nocobase/plugin-workflow';
|
||||||
import { getApp, sleep } from '@nocobase/plugin-workflow-test';
|
import { getApp, sleep } from '@nocobase/plugin-workflow-test';
|
||||||
|
|
||||||
import RequestInstruction, { RequestConfig } from '../RequestInstruction';
|
import RequestInstruction, { RequestInstructionConfig } from '../RequestInstruction';
|
||||||
|
|
||||||
const HOST = 'localhost';
|
const HOST = 'localhost';
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ describe('workflow > instructions > request', () => {
|
|||||||
url: api.URL_DATA,
|
url: api.URL_DATA,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
params: [{ name: 'id', value: '{{$context.data.id}}' }],
|
params: [{ name: 'id', value: '{{$context.data.id}}' }],
|
||||||
} as RequestConfig,
|
} as RequestInstructionConfig,
|
||||||
});
|
});
|
||||||
|
|
||||||
await PostRepo.create({ values: { title: 't1' } });
|
await PostRepo.create({ values: { title: 't1' } });
|
||||||
@ -175,7 +175,7 @@ describe('workflow > instructions > request', () => {
|
|||||||
url: api.URL_DATA,
|
url: api.URL_DATA,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
onlyData: true,
|
onlyData: true,
|
||||||
} as RequestConfig,
|
} as RequestInstructionConfig,
|
||||||
});
|
});
|
||||||
|
|
||||||
await PostRepo.create({ values: { title: 't1' } });
|
await PostRepo.create({ values: { title: 't1' } });
|
||||||
@ -195,7 +195,7 @@ describe('workflow > instructions > request', () => {
|
|||||||
config: {
|
config: {
|
||||||
url: api.URL_DATA,
|
url: api.URL_DATA,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
} as RequestConfig,
|
} as RequestInstructionConfig,
|
||||||
});
|
});
|
||||||
|
|
||||||
await PostRepo.create({ values: { title: 't1' } });
|
await PostRepo.create({ values: { title: 't1' } });
|
||||||
@ -218,7 +218,7 @@ describe('workflow > instructions > request', () => {
|
|||||||
url: api.URL_TIMEOUT,
|
url: api.URL_TIMEOUT,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
timeout: 250,
|
timeout: 250,
|
||||||
} as RequestConfig,
|
} as RequestInstructionConfig,
|
||||||
});
|
});
|
||||||
|
|
||||||
await PostRepo.create({ values: { title: 't1' } });
|
await PostRepo.create({ values: { title: 't1' } });
|
||||||
@ -248,7 +248,7 @@ describe('workflow > instructions > request', () => {
|
|||||||
method: 'GET',
|
method: 'GET',
|
||||||
timeout: 250,
|
timeout: 250,
|
||||||
ignoreFail: true,
|
ignoreFail: true,
|
||||||
} as RequestConfig,
|
} as RequestInstructionConfig,
|
||||||
});
|
});
|
||||||
|
|
||||||
await PostRepo.create({ values: { title: 't1' } });
|
await PostRepo.create({ values: { title: 't1' } });
|
||||||
@ -272,7 +272,7 @@ describe('workflow > instructions > request', () => {
|
|||||||
config: {
|
config: {
|
||||||
url: api.URL_400,
|
url: api.URL_400,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
} as RequestConfig,
|
} as RequestInstructionConfig,
|
||||||
});
|
});
|
||||||
|
|
||||||
await PostRepo.create({ values: { title: 't1' } });
|
await PostRepo.create({ values: { title: 't1' } });
|
||||||
@ -291,7 +291,7 @@ describe('workflow > instructions > request', () => {
|
|||||||
config: {
|
config: {
|
||||||
url: api.URL_400_MESSAGE,
|
url: api.URL_400_MESSAGE,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
} as RequestConfig,
|
} as RequestInstructionConfig,
|
||||||
});
|
});
|
||||||
|
|
||||||
await PostRepo.create({ values: { title: 't1' } });
|
await PostRepo.create({ values: { title: 't1' } });
|
||||||
@ -311,7 +311,7 @@ describe('workflow > instructions > request', () => {
|
|||||||
config: {
|
config: {
|
||||||
url: api.URL_400_OBJECT,
|
url: api.URL_400_OBJECT,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
} as RequestConfig,
|
} as RequestInstructionConfig,
|
||||||
});
|
});
|
||||||
|
|
||||||
await PostRepo.create({ values: { title: 't1' } });
|
await PostRepo.create({ values: { title: 't1' } });
|
||||||
@ -331,7 +331,7 @@ describe('workflow > instructions > request', () => {
|
|||||||
config: {
|
config: {
|
||||||
url: api.URL_END,
|
url: api.URL_END,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
} as RequestConfig,
|
} as RequestInstructionConfig,
|
||||||
});
|
});
|
||||||
|
|
||||||
await PostRepo.create({ values: { title: 't1' } });
|
await PostRepo.create({ values: { title: 't1' } });
|
||||||
@ -357,7 +357,7 @@ describe('workflow > instructions > request', () => {
|
|||||||
method: 'GET',
|
method: 'GET',
|
||||||
timeout: 1000,
|
timeout: 1000,
|
||||||
ignoreFail: true,
|
ignoreFail: true,
|
||||||
} as RequestConfig,
|
} as RequestInstructionConfig,
|
||||||
});
|
});
|
||||||
|
|
||||||
await PostRepo.create({ values: { title: 't1' } });
|
await PostRepo.create({ values: { title: 't1' } });
|
||||||
@ -377,7 +377,7 @@ describe('workflow > instructions > request', () => {
|
|||||||
url: api.URL_DATA,
|
url: api.URL_DATA,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: { title: '{{$context.data.title}}' },
|
data: { title: '{{$context.data.title}}' },
|
||||||
} as RequestConfig,
|
} as RequestInstructionConfig,
|
||||||
});
|
});
|
||||||
|
|
||||||
await PostRepo.create({ values: { title: 't1' } });
|
await PostRepo.create({ values: { title: 't1' } });
|
||||||
@ -398,7 +398,7 @@ describe('workflow > instructions > request', () => {
|
|||||||
url: api.URL_DATA,
|
url: api.URL_DATA,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: { title: '{{$context.data.title}}' },
|
data: { title: '{{$context.data.title}}' },
|
||||||
} as RequestConfig,
|
} as RequestInstructionConfig,
|
||||||
});
|
});
|
||||||
|
|
||||||
const title = 't1\n\nline 2';
|
const title = 't1\n\nline 2';
|
||||||
@ -541,7 +541,7 @@ describe('workflow > instructions > request', () => {
|
|||||||
url: `http://localhost:${(server.address() as AddressInfo).port}/api/categories`,
|
url: `http://localhost:${(server.address() as AddressInfo).port}/api/categories`,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: [{ name: 'Authorization', value: `Bearer ${token}` }],
|
headers: [{ name: 'Authorization', value: `Bearer ${token}` }],
|
||||||
} as RequestConfig,
|
} as RequestInstructionConfig,
|
||||||
});
|
});
|
||||||
|
|
||||||
await PostRepo.create({ values: { title: 't1' } });
|
await PostRepo.create({ values: { title: 't1' } });
|
||||||
@ -576,7 +576,7 @@ describe('workflow > instructions > request', () => {
|
|||||||
config: {
|
config: {
|
||||||
url: api.URL_DATA,
|
url: api.URL_DATA,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
} as RequestConfig,
|
} as RequestInstructionConfig,
|
||||||
});
|
});
|
||||||
|
|
||||||
const workflowPlugin = app.pm.get(PluginWorkflow) as PluginWorkflow;
|
const workflowPlugin = app.pm.get(PluginWorkflow) as PluginWorkflow;
|
||||||
@ -598,7 +598,7 @@ describe('workflow > instructions > request', () => {
|
|||||||
url: api.URL_404,
|
url: api.URL_404,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
ignoreFail: true,
|
ignoreFail: true,
|
||||||
} as RequestConfig,
|
} as RequestInstructionConfig,
|
||||||
});
|
});
|
||||||
|
|
||||||
const workflowPlugin = app.pm.get(PluginWorkflow) as PluginWorkflow;
|
const workflowPlugin = app.pm.get(PluginWorkflow) as PluginWorkflow;
|
||||||
@ -615,7 +615,7 @@ describe('workflow > instructions > request', () => {
|
|||||||
it('invalid config', async () => {
|
it('invalid config', async () => {
|
||||||
const { status, result } = await instruction.test(Object.create({}));
|
const { status, result } = await instruction.test(Object.create({}));
|
||||||
expect(status).toBe(JOB_STATUS.FAILED);
|
expect(status).toBe(JOB_STATUS.FAILED);
|
||||||
expect(result).toBe("Cannot read properties of null (reading 'replace')");
|
expect(result).toBe('Invalid URL');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('data url', async () => {
|
it('data url', async () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user