Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(editor): Fix delete all existing executions #11352

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ async function handleDeleteSelected() {
await executionsStore.deleteExecutions({
filters: executionsStore.executionsFilters,
...(allExistingSelected.value
? { deleteBefore: props.executions[0].startedAt }
? { deleteBefore: new Date() }
: {
ids: Object.keys(selectedItems.value),
}),
Expand Down
69 changes: 69 additions & 0 deletions packages/editor-ui/src/stores/executions.store.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { vi } from 'vitest';
import { setActivePinia, createPinia } from 'pinia';

import type { ExecutionSummaryWithScopes } from '@/Interface';
import { useExecutionsStore } from '@/stores/executions.store';

vi.mock('@/utils/apiUtils', () => ({
makeRestApiRequest: vi.fn(),
}));

describe('executions.store', () => {
let executionsStore: ReturnType<typeof useExecutionsStore>;

beforeEach(() => {
setActivePinia(createPinia());
executionsStore = useExecutionsStore();
});

describe('deleteExecutions', () => {
const mockExecutions: ExecutionSummaryWithScopes[] = [
{
id: '3',
mode: 'manual',
status: 'success',
startedAt: new Date('2021-01-03T00:00:00Z'),
workflowId: '1',
scopes: [],
},
{
id: '2',
mode: 'manual',
status: 'success',
startedAt: new Date('2021-01-02T00:00:00Z'),
workflowId: '1',
scopes: [],
},
{
id: '1',
mode: 'manual',
status: 'success',
startedAt: new Date('2021-01-01T00:00:00Z'),
workflowId: '1',
scopes: [],
},
];

beforeEach(() => {
mockExecutions.forEach(executionsStore.addExecution);
});

it('should delete executions by ID', async () => {
await executionsStore.deleteExecutions({ ids: ['1', '3'] });

expect(executionsStore.executions).toEqual([mockExecutions[1]]);
});

it('should delete executions started before given date', async () => {
await executionsStore.deleteExecutions({ deleteBefore: mockExecutions[1].startedAt });

expect(executionsStore.executions).toEqual([mockExecutions[0], mockExecutions[1]]);
});

it('should delete all executions if given date is now', async () => {
await executionsStore.deleteExecutions({ deleteBefore: new Date() });

expect(executionsStore.executions).toEqual([]);
});
});
});
1 change: 1 addition & 0 deletions packages/editor-ui/src/stores/executions.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ export const useExecutionsStore = defineStore('executions', () => {
stopCurrentExecution,
retryExecution,
deleteExecutions,
addExecution,
resetData,
reset,
};
Expand Down
Loading