fix(plugin-field-sort): fix move action to trigger workflow (#6145)

This commit is contained in:
Junyi 2025-01-28 23:18:53 +08:00 committed by GitHub
parent b3b6a31ae9
commit 2783e62aa5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 31 additions and 1 deletions

View File

@ -7,9 +7,9 @@
* For more information, please refer to: https://www.nocobase.com/agreement.
*/
import { pick } from 'lodash';
import { BelongsToManyRepository, Collection, HasManyRepository, TargetKey, Model, Op } from '@nocobase/database';
import { Context } from '@nocobase/actions';
import { pick } from 'lodash';
import { SortField } from './sort-field';

View File

@ -164,6 +164,36 @@ describe('workflow > triggers > collection', () => {
});
describe('config.mode', () => {
it('update by move action', async () => {
db.getCollection('posts').addField('sort', {
type: 'sort',
name: 'sort',
});
await db.sync();
const p1 = await PostRepo.create({ values: { title: 't1' } });
const p2 = await PostRepo.create({ values: { title: 't2' } });
const workflow = await WorkflowModel.create({
enabled: true,
type: 'collection',
config: {
mode: 2,
collection: 'posts',
},
});
const response = await agent.resource('posts').move({
sourceId: p1.id,
targetId: p2.id,
});
await sleep(500);
const e1s = await workflow.getExecutions();
expect(e1s.length).toBe(1);
expect(e1s[0].status).toBe(EXECUTION_STATUS.RESOLVED);
});
it('mode in "update or create" could trigger on each', async () => {
const workflow = await WorkflowModel.create({
enabled: true,