mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 21:07:28 -08:00
fix(editor): Fix delete all existing executions (#11352)
This commit is contained in:
parent
d309112647
commit
3ec103f8ba
|
@ -143,7 +143,7 @@ async function handleDeleteSelected() {
|
||||||
await executionsStore.deleteExecutions({
|
await executionsStore.deleteExecutions({
|
||||||
filters: executionsStore.executionsFilters,
|
filters: executionsStore.executionsFilters,
|
||||||
...(allExistingSelected.value
|
...(allExistingSelected.value
|
||||||
? { deleteBefore: props.executions[0].startedAt }
|
? { deleteBefore: new Date() }
|
||||||
: {
|
: {
|
||||||
ids: Object.keys(selectedItems.value),
|
ids: Object.keys(selectedItems.value),
|
||||||
}),
|
}),
|
||||||
|
|
69
packages/editor-ui/src/stores/executions.store.test.ts
Normal file
69
packages/editor-ui/src/stores/executions.store.test.ts
Normal file
|
@ -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([]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -290,6 +290,7 @@ export const useExecutionsStore = defineStore('executions', () => {
|
||||||
stopCurrentExecution,
|
stopCurrentExecution,
|
||||||
retryExecution,
|
retryExecution,
|
||||||
deleteExecutions,
|
deleteExecutions,
|
||||||
|
addExecution,
|
||||||
resetData,
|
resetData,
|
||||||
reset,
|
reset,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue