mirror of
https://github.com/n8n-io/n8n.git
synced 2026-10-17 13:39:44 +02:00
chore: Reuse the version-name detail helper for activity events (#39595)
Co-authored-by: n8n-cat-bot[bot] <n8n-cat-bot[bot]@users.noreply.github.com>
This commit is contained in:
parent
1333a2c130
commit
2a205c294f
|
|
@ -414,6 +414,37 @@ describe('ActivityEventRelay', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it.each([
|
||||
{ label: 'null', name: null },
|
||||
{ label: 'empty', name: '' },
|
||||
{ label: 'long', name: 'v'.repeat(2_000) },
|
||||
])('formats $label version names the same when publishing and updating', async ({ name }) => {
|
||||
relayWith({ flagOverride: true });
|
||||
|
||||
eventService.emit('workflow-activated', {
|
||||
user,
|
||||
workflowId: 'workflow1',
|
||||
workflow: mock<IWorkflowDb>({
|
||||
id: 'workflow1',
|
||||
name: 'Lead enrichment',
|
||||
activeVersion: mock<WorkflowHistory>({ name }),
|
||||
}),
|
||||
publicApi: false,
|
||||
});
|
||||
eventService.emit('workflow-version-updated', {
|
||||
user,
|
||||
workflowId: 'workflow1',
|
||||
workflowName: 'Lead enrichment',
|
||||
versionId: 'version1',
|
||||
versionName: name,
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
expect(activityEventRepository.record).toHaveBeenCalledTimes(2);
|
||||
const [[published], [updated]] = activityEventRepository.record.mock.calls;
|
||||
expect(updated.data).toEqual({ versionId: 'version1', ...published.data });
|
||||
});
|
||||
|
||||
it('records no version name when unpublishing, which clears the relation first', async () => {
|
||||
relayWith({ flagOverride: true });
|
||||
|
||||
|
|
|
|||
|
|
@ -255,7 +255,7 @@ export class ActivityEventRelay extends EventRelay {
|
|||
workflowId,
|
||||
workflowName,
|
||||
versionId,
|
||||
versionName,
|
||||
versionName: updatedVersionName,
|
||||
}: RelayEventMap['workflow-version-updated']) {
|
||||
await this.record({
|
||||
category: 'workflow',
|
||||
|
|
@ -265,9 +265,7 @@ export class ActivityEventRelay extends EventRelay {
|
|||
resourceType: 'workflow',
|
||||
resourceId: workflowId,
|
||||
resourceName: workflowName,
|
||||
// The name is unbounded user input. Left whole it can push `data` past the budget, and an
|
||||
// over-budget payload is replaced entirely — which would take `versionId` with it.
|
||||
data: { versionId, ...(versionName ? { versionName: clip(versionName) } : {}) },
|
||||
data: { versionId, ...versionName(updatedVersionName) },
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user