Fix(plugin workflow) (#549)
* fix(plugin-workflow): clear options when change collection * fix(plugin-workflow): fix schedule trigger
This commit is contained in:
parent
8fa4be8589
commit
95d0b524d0
@ -4,7 +4,7 @@ import { getApp, sleep } from '..';
|
||||
|
||||
|
||||
|
||||
describe.skip('workflow > triggers > schedule', () => {
|
||||
describe('workflow > triggers > schedule', () => {
|
||||
let app: Application;
|
||||
let db: Database;
|
||||
let PostRepo;
|
||||
@ -186,13 +186,16 @@ describe.skip('workflow > triggers > schedule', () => {
|
||||
}
|
||||
});
|
||||
|
||||
const now = new Date();
|
||||
await sleep((2.5 - now.getSeconds() % 2) * 1000 - now.getMilliseconds());
|
||||
|
||||
const post = await PostRepo.create({ values: { title: 't1' }});
|
||||
|
||||
await sleep(1000);
|
||||
const executions = await workflow.getExecutions();
|
||||
expect(executions.length).toBe(0);
|
||||
|
||||
await sleep(1000);
|
||||
await sleep(2000);
|
||||
const [execution] = await workflow.getExecutions();
|
||||
expect(execution).toBeDefined();
|
||||
expect(execution.context.data.id).toBe(post.id);
|
||||
|
@ -62,8 +62,8 @@ ScheduleModes.set(SCHEDULE_MODE.CONSTANT, {
|
||||
trigger(workflow, date) {
|
||||
const { startsOn, endsOn, repeat } = workflow.config;
|
||||
if (startsOn && typeof repeat === 'number') {
|
||||
const startTime = Date.parse(startsOn);
|
||||
if ((startTime - date.getTime()) % repeat) {
|
||||
const startTime = Math.floor(Date.parse(startsOn) / 1000) * 1000;
|
||||
if (Math.round(date.getTime() - startTime) % repeat) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user