feat: Implement createEmptyFlow method for user model

This commit is contained in:
Faruk AYDIN
2025-03-10 16:08:52 +01:00
parent 75a7a068f3
commit ac1f644071
4 changed files with 35 additions and 9 deletions

View File

@@ -1507,6 +1507,28 @@ describe('User model', () => {
});
});
describe('createEmptyFlow', () => {
it('should create a flow with default name', async () => {
const user = await createUser();
const flow = await user.createEmptyFlow();
expect(flow.name).toBe('Name your flow');
expect(flow.userId).toBe(user.id);
});
it('should call createInitialSteps on the created flow', async () => {
const user = await createUser();
const createInitialStepsSpy = vi.spyOn(
Flow.prototype,
'createInitialSteps'
);
await user.createEmptyFlow();
expect(createInitialStepsSpy).toHaveBeenCalledOnce();
});
});
describe('$beforeInsert', () => {
it('should call super.$beforeInsert', async () => {
const superBeforeInsertSpy = vi