feat(editor): Workflow history [WIP]- Add workflow history opening button to main header component (no-changelog) (#7310)

Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
This commit is contained in:
Csaba Tuncsik
2023-10-04 16:45:18 +02:00
committed by GitHub
parent b59b9086d7
commit 4bc9164032
15 changed files with 334 additions and 113 deletions

View File

@@ -0,0 +1,17 @@
import { faker } from '@faker-js/faker';
import type { WorkflowHistory } from '@/types/workflowHistory';
export const workflowHistoryDataFactory: () => WorkflowHistory = () => ({
versionId: faker.string.nanoid(),
createdAt: faker.date.past().toDateString(),
authors: Array.from({ length: faker.number.int({ min: 2, max: 5 }) }, faker.person.fullName).join(
', ',
),
});
export const workflowVersionDataFactory: () => WorkflowHistory = () => ({
...workflowHistoryDataFactory(),
workflow: {
name: faker.lorem.words(3),
},
});

View File

@@ -0,0 +1,57 @@
import { createPinia, setActivePinia } from 'pinia';
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],
[false, 1, 2],
[false, 2, 1],
[false, -1, 2],
[false, 2, -1],
])(
'should set `shouldUpgrade` to %s when pruneTime is %s and licensePruneTime is %s',
(shouldUpgrade, pruneTime, licensePruneTime) => {
const workflowHistoryStore = useWorkflowHistoryStore();
const settingsStore = useSettingsStore();
settingsStore.settings = {
workflowHistory: {
pruneTime,
licensePruneTime,
},
};
expect(workflowHistoryStore.shouldUpgrade).toBe(shouldUpgrade);
},
);
});