Repository: n8n-io/n8n
File: packages/frontend/editor-ui/src/app/composables/useWorkflowHelpers.test.ts (TypeScript)

Code before:
			expect(upsertTagsSpy).toHaveBeenCalledWith([]);
		});
	});

	describe('getWorkflowDataToSave', () => {
		it('should read tags from workflowDocumentStore', async () => {
			const workflowId = 'test-workflow-id';
			const tagIds = ['tag1', 'tag2'];

			workflowsStore.workflowId = workflowId;
			workflowsStore.workflowName = 'Test Workflow';
			workflowsStore.allNodes = [];
			workflowsStore.allConnections = {};
			workflowsStore.isWorkflowActive = false;
			workflowsStore.workflow.settings = { executionOrder: 'v1' };
			workflowsStore.workflow.versionId = 'v1';
			workflowsStore.workflow.meta = {};
			workflowsStore.pinnedWorkflowData = {};

			const documentId = createWorkflowDocumentId(workflowId);
			const workflowDocumentStore = useWorkflowDocumentStore(documentId);

			Object.defineProperty(workflowDocumentStore, 'tags', {
				value: tagIds,
				writable: true,
			});

			const { getWorkflowDataToSave } = useWorkflowHelpers();
			const workflowData = await getWorkflowDataToSave();

			expect(workflowData.tags).toEqual(tagIds);
			expect(workflowData.id).toBe(workflowId);
		});
	});

	describe('checkConflictingWebhooks', () => {
		it('should return null if no conflicts', async () => {
			const workflowHelpers = useWorkflowHelpers();
			uiStore.markStateClean();
			vi.spyOn(workflowsListStore, 'fetchWorkflow').mockResolvedValue({
				nodes: [],
			} as unknown as IWorkflowDb);
			expect(await workflowHelpers.checkConflictingWebhooks('12345')).toEqual(null);
		});

		it('should return conflicting webhook data and workflow id is different', async () => {
			const workflowHelpers = useWorkflowHelpers();
			uiStore.markStateClean();
			vi.spyOn(workflowsListStore, 'fetchWorkflow').mockResolvedValue({
				nodes: [
					{

Review comment (suggestion):
```suggestion
			workflowDocumentStore.setTags(tagIds)
```

Code after:
			expect(upsertTagsSpy).toHaveBeenCalledWith([]);
		});
	});

	describe('getWorkflowDataToSave', () => {
		it('should read tags from workflowDocumentStore', async () => {
			const workflowId = 'test-workflow-id';
			const tagIds = ['tag1', 'tag2'];

			workflowsStore.workflowId = workflowId;
			workflowsStore.workflowName = 'Test Workflow';
			workflowsStore.allNodes = [];
			workflowsStore.allConnections = {};
			workflowsStore.isWorkflowActive = false;
			workflowsStore.workflow.settings = { executionOrder: 'v1' };
			workflowsStore.workflow.versionId = 'v1';
			workflowsStore.workflow.meta = {};
			workflowsStore.pinnedWorkflowData = {};

			const documentId = createWorkflowDocumentId(workflowId);
			const workflowDocumentStore = useWorkflowDocumentStore(documentId);

			// Note: createTestingPinia() stubs actions by default, so setTags() won't work
			Object.defineProperty(workflowDocumentStore, 'tags', {
				value: tagIds,
			});

			const { getWorkflowDataToSave } = useWorkflowHelpers();
			const workflowData = await getWorkflowDataToSave();

			expect(workflowData.tags).toEqual(tagIds);
			expect(workflowData.id).toBe(workflowId);
		});
	});

	describe('checkConflictingWebhooks', () => {
		it('should return null if no conflicts', async () => {
			const workflowHelpers = useWorkflowHelpers();
			uiStore.markStateClean();
			vi.spyOn(workflowsListStore, 'fetchWorkflow').mockResolvedValue({
				nodes: [],
			} as unknown as IWorkflowDb);
			expect(await workflowHelpers.checkConflictingWebhooks('12345')).toEqual(null);
		});

		it('should return conflicting webhook data and workflow id is different', async () => {
			const workflowHelpers = useWorkflowHelpers();
			uiStore.markStateClean();
			vi.spyOn(workflowsListStore, 'fetchWorkflow').mockResolvedValue({
				nodes: [
					{