feat: add create or update workflow trigger (#14708)
### Description This PR focuses on https://github.com/twentyhq/core-team-issues/issues/1476 - introduces the handling of upserted events in the workflow trigger system ## Visual Appearance <img width="1792" height="1039" alt="Screenshot 2025-09-21 at 11 40 28 PM" src="https://github.com/user-attachments/assets/d926b566-f7d3-412b-b1ab-ed2064425f3d" /> <img width="501" height="1025" alt="Screenshot 2025-09-21 at 11 40 39 PM" src="https://github.com/user-attachments/assets/13c3031a-0762-4c80-8df1-fa74ca70a540" /> ### Changes - Added `UPSERTED` action to the `DatabaseEventAction` enum. - Updated the `WorkflowEditTriggerDatabaseEventForm` to support upserted events. --------- Co-authored-by: Thomas Trompette <thomas.trompette@sfr.fr>
This commit is contained in:
+31
@@ -173,6 +173,37 @@ describe('generateFakeObjectRecordEvent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should generate record with "after" prefix for UPSERTED action', () => {
|
||||
const result = generateFakeObjectRecordEvent(
|
||||
objectMetadataInfo,
|
||||
DatabaseEventAction.UPSERTED,
|
||||
);
|
||||
|
||||
expect(result).toEqual({
|
||||
object: {
|
||||
isLeaf: true,
|
||||
icon: 'test-company-icon',
|
||||
label: 'Company',
|
||||
value: 'A company',
|
||||
fieldIdName: 'properties.after.id',
|
||||
objectMetadataId: '20202020-c03c-45d6-a4b0-04afe1357c5c',
|
||||
},
|
||||
fields: {
|
||||
'properties.after.field1': {
|
||||
type: 'TEXT',
|
||||
value: 'test',
|
||||
fieldMetadataId: '123e4567-e89b-12d3-a456-426614174000',
|
||||
},
|
||||
'properties.after.field2': {
|
||||
type: 'NUMBER',
|
||||
value: 123,
|
||||
fieldMetadataId: '123e4567-e89b-12d3-a456-426614174001',
|
||||
},
|
||||
},
|
||||
_outputSchemaType: 'RECORD',
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw error for unknown action', () => {
|
||||
expect(() => {
|
||||
generateFakeObjectRecordEvent(
|
||||
|
||||
+1
@@ -45,6 +45,7 @@ export const generateFakeObjectRecordEvent = (
|
||||
switch (action) {
|
||||
case DatabaseEventAction.CREATED:
|
||||
case DatabaseEventAction.UPDATED:
|
||||
case DatabaseEventAction.UPSERTED:
|
||||
return generateFakeObjectRecordEventWithPrefix({
|
||||
objectMetadataInfo,
|
||||
prefix: 'properties.after',
|
||||
|
||||
Reference in New Issue
Block a user