feat(editor): Workflow history [WIP]- Improve switching between workflow history and editor (no-changelog) (#7353)
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
import { faker } from '@faker-js/faker';
|
||||
import type { WorkflowHistory } from '@/types/workflowHistory';
|
||||
import type { WorkflowHistory, WorkflowVersion } from '@/types/workflowHistory';
|
||||
|
||||
export const workflowHistoryDataFactory: () => WorkflowHistory = () => ({
|
||||
versionId: faker.string.nanoid(),
|
||||
createdAt: faker.date.past().toDateString(),
|
||||
updatedAt: faker.date.past().toDateString(),
|
||||
authors: Array.from({ length: faker.number.int({ min: 2, max: 5 }) }, faker.person.fullName).join(
|
||||
', ',
|
||||
),
|
||||
});
|
||||
|
||||
export const workflowVersionDataFactory: () => WorkflowHistory = () => ({
|
||||
export const workflowVersionDataFactory: () => WorkflowVersion = () => ({
|
||||
...workflowHistoryDataFactory(),
|
||||
workflow: {
|
||||
name: faker.lorem.words(3),
|
||||
},
|
||||
workflowId: faker.string.nanoid(),
|
||||
connections: {},
|
||||
nodes: [],
|
||||
});
|
||||
|
||||
@@ -1,36 +1,13 @@
|
||||
import { createPinia, setActivePinia } from 'pinia';
|
||||
import type { IN8nUISettings } from 'n8n-workflow';
|
||||
import { useWorkflowHistoryStore } from '@/stores/workflowHistory.store';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import {
|
||||
workflowHistoryDataFactory,
|
||||
workflowVersionDataFactory,
|
||||
} from '@/stores/__tests__/utils/workflowHistoryTestUtils';
|
||||
|
||||
const historyData = Array.from({ length: 5 }, workflowHistoryDataFactory);
|
||||
const versionData = {
|
||||
...workflowVersionDataFactory(),
|
||||
...historyData[0],
|
||||
};
|
||||
|
||||
describe('Workflow history store', () => {
|
||||
beforeEach(() => {
|
||||
setActivePinia(createPinia());
|
||||
});
|
||||
|
||||
it('should reset data', () => {
|
||||
const workflowHistoryStore = useWorkflowHistoryStore();
|
||||
|
||||
workflowHistoryStore.addWorkflowHistory(historyData);
|
||||
workflowHistoryStore.setActiveWorkflowVersion(versionData);
|
||||
|
||||
expect(workflowHistoryStore.workflowHistory).toEqual(historyData);
|
||||
expect(workflowHistoryStore.activeWorkflowVersion).toEqual(versionData);
|
||||
|
||||
workflowHistoryStore.reset();
|
||||
expect(workflowHistoryStore.workflowHistory).toEqual([]);
|
||||
expect(workflowHistoryStore.activeWorkflowVersion).toEqual(null);
|
||||
});
|
||||
|
||||
test.each([
|
||||
[true, 1, 1],
|
||||
[true, 2, 2],
|
||||
@@ -49,7 +26,7 @@ describe('Workflow history store', () => {
|
||||
pruneTime,
|
||||
licensePruneTime,
|
||||
},
|
||||
};
|
||||
} as IN8nUISettings;
|
||||
|
||||
expect(workflowHistoryStore.shouldUpgrade).toBe(shouldUpgrade);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user