Merge pull request #2267 from automatisch/export-flow
feat: Implement initial logic of exporting flow
This commit is contained in:
@@ -7,6 +7,7 @@ import ExecutionStep from './execution-step.js';
|
||||
import globalVariable from '../helpers/global-variable.js';
|
||||
import logger from '../helpers/logger.js';
|
||||
import Telemetry from '../helpers/telemetry/index.js';
|
||||
import exportFlow from '../helpers/export-flow.js';
|
||||
import flowQueue from '../queues/flow.js';
|
||||
import {
|
||||
REMOVE_AFTER_30_DAYS_OR_150_JOBS,
|
||||
@@ -426,6 +427,10 @@ class Flow extends Base {
|
||||
}
|
||||
}
|
||||
|
||||
async export() {
|
||||
return await exportFlow(this);
|
||||
}
|
||||
|
||||
async $beforeUpdate(opt, queryContext) {
|
||||
await super.$beforeUpdate(opt, queryContext);
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import { createFlow } from '../../test/factories/flow.js';
|
||||
import { createStep } from '../../test/factories/step.js';
|
||||
import { createExecution } from '../../test/factories/execution.js';
|
||||
import { createExecutionStep } from '../../test/factories/execution-step.js';
|
||||
import * as exportFlow from '../helpers/export-flow.js';
|
||||
|
||||
describe('Flow model', () => {
|
||||
it('tableName should return correct name', () => {
|
||||
@@ -506,6 +507,22 @@ describe('Flow model', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('export', () => {
|
||||
it('should return exportedFlow', async () => {
|
||||
const flow = await createFlow();
|
||||
|
||||
const exportedFlowAsString = {
|
||||
name: 'My Flow Name',
|
||||
};
|
||||
|
||||
vi.spyOn(exportFlow, 'default').mockReturnValue(exportedFlowAsString);
|
||||
|
||||
expect(await flow.export()).toStrictEqual({
|
||||
name: 'My Flow Name',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('throwIfHavingLessThanTwoSteps', () => {
|
||||
it('should throw validation error with less than two steps', async () => {
|
||||
const flow = await createFlow();
|
||||
|
||||
Reference in New Issue
Block a user