mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 05:29:26 +08:00
fix(plugin-workflow-request): fix ignoreFail in sync mode (#4334)
* fix(plugin-workflow-request): fix ignoreFail in sync mode * test(plugin-workflow-request): remote sleep in sync test
This commit is contained in:
parent
6f4c884799
commit
145577942f
@ -83,7 +83,7 @@ export default class extends Instruction {
|
|||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return {
|
return {
|
||||||
status: JOB_STATUS.FAILED,
|
status: config.ignoreFail ? JOB_STATUS.RESOLVED : JOB_STATUS.FAILED,
|
||||||
result: error.isAxiosError ? error.toJSON() : error.message,
|
result: error.isAxiosError ? error.toJSON() : error.message,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -22,12 +22,6 @@ import { RequestConfig } from '../RequestInstruction';
|
|||||||
|
|
||||||
const HOST = 'localhost';
|
const HOST = 'localhost';
|
||||||
|
|
||||||
function getRandomPort() {
|
|
||||||
const minPort = 1024;
|
|
||||||
const maxPort = 49151;
|
|
||||||
return Math.floor(Math.random() * (maxPort - minPort + 1)) + minPort;
|
|
||||||
}
|
|
||||||
|
|
||||||
class MockAPI {
|
class MockAPI {
|
||||||
app: Koa;
|
app: Koa;
|
||||||
server: Server;
|
server: Server;
|
||||||
@ -38,6 +32,9 @@ class MockAPI {
|
|||||||
get URL_400() {
|
get URL_400() {
|
||||||
return `http://${HOST}:${this.port}/api/400`;
|
return `http://${HOST}:${this.port}/api/400`;
|
||||||
}
|
}
|
||||||
|
get URL_404() {
|
||||||
|
return `http://${HOST}:${this.port}/api/404`;
|
||||||
|
}
|
||||||
get URL_TIMEOUT() {
|
get URL_TIMEOUT() {
|
||||||
return `http://${HOST}:${this.port}/api/timeout`;
|
return `http://${HOST}:${this.port}/api/timeout`;
|
||||||
}
|
}
|
||||||
@ -408,11 +405,16 @@ describe('workflow > instructions > request', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('sync request', () => {
|
describe('sync request', () => {
|
||||||
it('sync trigger', async () => {
|
let syncFlow;
|
||||||
const syncFlow = await WorkflowModel.create({
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
syncFlow = await WorkflowModel.create({
|
||||||
type: 'syncTrigger',
|
type: 'syncTrigger',
|
||||||
enabled: true,
|
enabled: true,
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('sync trigger', async () => {
|
||||||
await syncFlow.createNode({
|
await syncFlow.createNode({
|
||||||
type: 'request',
|
type: 'request',
|
||||||
config: {
|
config: {
|
||||||
@ -432,5 +434,24 @@ describe('workflow > instructions > request', () => {
|
|||||||
expect(job.status).toEqual(JOB_STATUS.RESOLVED);
|
expect(job.status).toEqual(JOB_STATUS.RESOLVED);
|
||||||
expect(job.result).toEqual({ meta: {}, data: {} });
|
expect(job.result).toEqual({ meta: {}, data: {} });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('ignoreFail', async () => {
|
||||||
|
await syncFlow.createNode({
|
||||||
|
type: 'request',
|
||||||
|
config: {
|
||||||
|
url: api.URL_404,
|
||||||
|
method: 'GET',
|
||||||
|
ignoreFail: true,
|
||||||
|
} as RequestConfig,
|
||||||
|
});
|
||||||
|
|
||||||
|
const workflowPlugin = app.pm.get(PluginWorkflow) as PluginWorkflow;
|
||||||
|
const processor = (await workflowPlugin.trigger(syncFlow, { data: { title: 't1' } })) as Processor;
|
||||||
|
|
||||||
|
const [execution] = await syncFlow.getExecutions();
|
||||||
|
const [job] = await execution.getJobs();
|
||||||
|
expect(job.status).toBe(JOB_STATUS.RESOLVED);
|
||||||
|
expect(job.result.status).toBe(404);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user