feat: Implement isOwner flag for get flows API endpoint

This commit is contained in:
Faruk AYDIN
2025-03-31 21:18:33 +02:00
parent 351576b6b3
commit 59b887079a
10 changed files with 133 additions and 8 deletions

View File

@@ -11,6 +11,10 @@ const flowSerializer = (flow) => {
updatedAt: flow.updatedAt.getTime(),
};
if ('isOwner' in flow) {
flowData.isOwner = flow.isOwner;
}
if (flow.steps?.length > 0) {
flowData.steps = flow.steps.map((step) => stepSerializer(step));
}

View File

@@ -43,4 +43,22 @@ describe('flowSerializer', () => {
expect(flowSerializer(flow)).toMatchObject(expectedPayload);
});
describe('isOwner', () => {
it('should not be defined by default', async () => {
expect(flowSerializer(flow)).not.toHaveProperty('isOwner');
});
it('should return true if the flow is owned by the current user', async () => {
flow.isOwner = true;
expect(flowSerializer(flow)).toMatchObject({ isOwner: true });
});
it('should return false if the flow is owned by another user', async () => {
flow.isOwner = false;
expect(flowSerializer(flow)).toMatchObject({ isOwner: false });
});
});
});