test: add tests for executions

This commit is contained in:
Jakub P.
2024-12-10 21:03:23 +01:00
parent dba263d7b5
commit 400a45051f
10 changed files with 367 additions and 45 deletions

View File

@@ -6,6 +6,7 @@ export const createFlow = async (request, token) => {
{ headers: { Authorization: token } }
);
await expect(response.status()).toBe(201);
return await response.json();
};
@@ -15,6 +16,7 @@ export const getFlow = async (request, token, flowId) => {
{ headers: { Authorization: token } }
);
await expect(response.status()).toBe(200);
return await response.json();
};
@@ -38,6 +40,7 @@ export const updateFlowStep = async (request, token, stepId, requestBody) => {
}
);
await expect(updateTriggerStepResponse.status()).toBe(200);
return await updateTriggerStepResponse.json();
};
@@ -60,6 +63,7 @@ export const publishFlow = async (request, token, flowId) => {
}
);
await expect(publishFlowResponse.status()).toBe(200);
return publishFlowResponse.json();
};
@@ -67,3 +71,42 @@ export const triggerFlow = async (request, url) => {
const triggerFlowResponse = await request.get(url);
await expect(triggerFlowResponse.status()).toBe(204);
};
export const addWebhookFlow = async (request, token) => {
let flow = await createFlow(request, token);
const flowId = flow.data.id;
await updateFlowName(request, token, flowId);
flow = await getFlow(request, token, flowId);
const flowSteps = flow.data.steps;
const triggerStepId = flowSteps.find((step) => step.type === 'trigger').id;
const actionStepId = flowSteps.find((step) => step.type === 'action').id;
const triggerStep = await updateFlowStep(request, token, triggerStepId, {
appKey: 'webhook',
key: 'catchRawWebhook',
parameters: {
workSynchronously: false,
},
});
await request.get(triggerStep.data.webhookUrl);
await testStep(request, token, triggerStepId);
await updateFlowStep(request, token, actionStepId, {
appKey: 'webhook',
key: 'respondWith',
parameters: {
statusCode: '200',
body: 'ok',
headers: [
{
key: '',
value: '',
},
],
},
});
await testStep(request, token, actionStepId);
return flowId;
};