test: improve tests execution time
This commit is contained in:
16
packages/e2e-tests/helpers/auth-api-helper.js
Normal file
16
packages/e2e-tests/helpers/auth-api-helper.js
Normal file
@@ -0,0 +1,16 @@
|
||||
const { expect } = require('../fixtures/index');
|
||||
|
||||
export const getToken = async (apiRequest) => {
|
||||
const tokenResponse = await apiRequest.post(
|
||||
`${process.env.BACKEND_APP_URL}/api/v1/access-tokens`,
|
||||
{
|
||||
data: {
|
||||
email: process.env.LOGIN_EMAIL,
|
||||
password: process.env.LOGIN_PASSWORD,
|
||||
},
|
||||
}
|
||||
);
|
||||
await expect(tokenResponse.status()).toBe(200);
|
||||
|
||||
return await tokenResponse.json();
|
||||
};
|
69
packages/e2e-tests/helpers/flow-api-helper.js
Normal file
69
packages/e2e-tests/helpers/flow-api-helper.js
Normal file
@@ -0,0 +1,69 @@
|
||||
const { expect } = require('../fixtures/index');
|
||||
|
||||
export const createFlow = async (request, token) => {
|
||||
const response = await request.post(
|
||||
`${process.env.BACKEND_APP_URL}/api/v1/flows`,
|
||||
{ headers: { Authorization: token } }
|
||||
);
|
||||
await expect(response.status()).toBe(201);
|
||||
return await response.json();
|
||||
};
|
||||
|
||||
export const getFlow = async (request, token, flowId) => {
|
||||
const response = await request.get(
|
||||
`${process.env.BACKEND_APP_URL}/api/v1/flows/${flowId}`,
|
||||
{ headers: { Authorization: token } }
|
||||
);
|
||||
await expect(response.status()).toBe(200);
|
||||
return await response.json();
|
||||
};
|
||||
|
||||
export const updateFlowName = async (request, token, flowId) => {
|
||||
const updateFlowNameResponse = await request.patch(
|
||||
`${process.env.BACKEND_APP_URL}/api/v1/flows/${flowId}`,
|
||||
{
|
||||
headers: { Authorization: token },
|
||||
data: { name: flowId },
|
||||
}
|
||||
);
|
||||
await expect(updateFlowNameResponse.status()).toBe(200);
|
||||
};
|
||||
|
||||
export const updateFlowStep = async (request, token, stepId, requestBody) => {
|
||||
const updateTriggerStepResponse = await request.patch(
|
||||
`${process.env.BACKEND_APP_URL}/api/v1/steps/${stepId}`,
|
||||
{
|
||||
headers: { Authorization: token },
|
||||
data: requestBody,
|
||||
}
|
||||
);
|
||||
await expect(updateTriggerStepResponse.status()).toBe(200);
|
||||
return await updateTriggerStepResponse.json();
|
||||
};
|
||||
|
||||
export const testStep = async (request, token, stepId) => {
|
||||
const testTriggerStepResponse = await request.post(
|
||||
`${process.env.BACKEND_APP_URL}/api/v1/steps/${stepId}/test`,
|
||||
{
|
||||
headers: { Authorization: token },
|
||||
}
|
||||
);
|
||||
await expect(testTriggerStepResponse.status()).toBe(200);
|
||||
};
|
||||
|
||||
export const publishFlow = async (request, token, flowId) => {
|
||||
const publishFlowResponse = await request.patch(
|
||||
`${process.env.BACKEND_APP_URL}/api/v1/flows/${flowId}/status`,
|
||||
{
|
||||
headers: { Authorization: token },
|
||||
data: { active: true },
|
||||
}
|
||||
);
|
||||
await expect(publishFlowResponse.status()).toBe(200);
|
||||
return publishFlowResponse.json();
|
||||
};
|
||||
|
||||
export const triggerFlow = async (request, url) => {
|
||||
const triggerFlowResponse = await request.get(url);
|
||||
await expect(triggerFlowResponse.status()).toBe(204);
|
||||
};
|
24
packages/e2e-tests/helpers/user-api-helper.js
Normal file
24
packages/e2e-tests/helpers/user-api-helper.js
Normal file
@@ -0,0 +1,24 @@
|
||||
const { expect } = require('../fixtures/index');
|
||||
|
||||
export const addUser = async (apiRequest, token, request) => {
|
||||
const addUserResponse = await apiRequest.post(
|
||||
`${process.env.BACKEND_APP_URL}/api/v1/admin/users`,
|
||||
{
|
||||
headers: { Authorization: token },
|
||||
data: request,
|
||||
}
|
||||
);
|
||||
await expect(addUserResponse.status()).toBe(201);
|
||||
|
||||
return await addUserResponse.json();
|
||||
};
|
||||
|
||||
export const acceptInvitation = async (apiRequest, request) => {
|
||||
const acceptInvitationResponse = await apiRequest.post(
|
||||
`${process.env.BACKEND_APP_URL}/api/v1/users/invitation`,
|
||||
{
|
||||
data: request,
|
||||
}
|
||||
);
|
||||
await expect(acceptInvitationResponse.status()).toBe(204);
|
||||
};
|
Reference in New Issue
Block a user