Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
8f9041301c | |||
3573fc8895 | |||
253d4ab6bd | |||
1c9d30b688 | |||
feff219994 | |||
6bc2fe0f46 | |||
![]() |
3d62fabaac | ||
![]() |
e41a331ad7 | ||
![]() |
978ceaadb6 | ||
![]() |
770b07179f | ||
![]() |
6d15167ad9 | ||
![]() |
39cba6bc74 | ||
![]() |
9558e66abf | ||
![]() |
ff7908955e | ||
![]() |
26b095b835 |
52
.gitea/workflows/registry.yml
Normal file
52
.gitea/workflows/registry.yml
Normal file
@@ -0,0 +1,52 @@
|
||||
name: release-tag
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
jobs:
|
||||
release-image:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
DOCKER_ORG: groot
|
||||
DOCKER_LATEST: latest
|
||||
RUNNER_TOOL_CACHE: /toolcache
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
- name: Set up Docker BuildX
|
||||
uses: docker/setup-buildx-action@v2
|
||||
with: # replace it with your local IP
|
||||
config-inline: |
|
||||
[registry."git.send.nrw"]
|
||||
http = true
|
||||
insecure = true
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: git.send.nrw # replace it with your local IP
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Get Meta
|
||||
id: meta
|
||||
run: |
|
||||
echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT
|
||||
echo REPO_VERSION=$(git describe --tags --always | sed 's/^v//') >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: ./docker
|
||||
file: ./docker/Dockerfile.compose
|
||||
entrypoint: ./docker/compose-entrypoint.sh
|
||||
platforms: |
|
||||
linux/amd64
|
||||
push: true
|
||||
tags: | # replace it with your local IP and tags
|
||||
git.send.nrw/${{ env.DOCKER_ORG }}/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }}
|
||||
git.send.nrw/${{ env.DOCKER_ORG }}/${{ steps.meta.outputs.REPO_NAME }}:${{ env.DOCKER_LATEST }}
|
1
.github/workflows/playwright.yml
vendored
1
.github/workflows/playwright.yml
vendored
@@ -114,7 +114,6 @@ jobs:
|
||||
- name: Run Playwright tests
|
||||
working-directory: ./packages/e2e-tests
|
||||
env:
|
||||
PORT: 3000
|
||||
LOGIN_EMAIL: user@automatisch.io
|
||||
LOGIN_PASSWORD: sample
|
||||
BASE_URL: http://localhost:3000
|
||||
|
@@ -1,10 +1,7 @@
|
||||
version: '3.9'
|
||||
services:
|
||||
main:
|
||||
build:
|
||||
context: ./docker
|
||||
dockerfile: Dockerfile.compose
|
||||
entrypoint: /compose-entrypoint.sh
|
||||
image: git.send.nrw/groot/automatisch:latest
|
||||
ports:
|
||||
- '3000:3000'
|
||||
depends_on:
|
||||
@@ -28,10 +25,7 @@ services:
|
||||
volumes:
|
||||
- automatisch_storage:/automatisch/storage
|
||||
worker:
|
||||
build:
|
||||
context: ./docker
|
||||
dockerfile: Dockerfile.compose
|
||||
entrypoint: /compose-entrypoint.sh
|
||||
image: git.send.nrw/groot/automatisch:latest
|
||||
depends_on:
|
||||
- main
|
||||
environment:
|
||||
|
@@ -87,14 +87,14 @@ describe('GET /api/v1/apps/:appKey/connections', () => {
|
||||
|
||||
it('should return not found response for invalid connection UUID', async () => {
|
||||
await createPermission({
|
||||
action: 'update',
|
||||
action: 'read',
|
||||
subject: 'Connection',
|
||||
roleId: currentUserRole.id,
|
||||
conditions: ['isCreator'],
|
||||
});
|
||||
|
||||
await request(app)
|
||||
.get('/api/v1/connections/invalid-connection-id/connections')
|
||||
.get('/api/v1/apps/invalid-connection-id/connections')
|
||||
.set('Authorization', token)
|
||||
.expect(404);
|
||||
});
|
||||
|
@@ -193,7 +193,7 @@ describe('POST /api/v1/steps/:stepId/dynamic-data', () => {
|
||||
const notExistingStepUUID = Crypto.randomUUID();
|
||||
|
||||
await request(app)
|
||||
.get(`/api/v1/steps/${notExistingStepUUID}/dynamic-data`)
|
||||
.post(`/api/v1/steps/${notExistingStepUUID}/dynamic-data`)
|
||||
.set('Authorization', token)
|
||||
.expect(404);
|
||||
});
|
||||
@@ -216,7 +216,7 @@ describe('POST /api/v1/steps/:stepId/dynamic-data', () => {
|
||||
const step = await createStep({ appKey: null });
|
||||
|
||||
await request(app)
|
||||
.get(`/api/v1/steps/${step.id}/dynamic-data`)
|
||||
.post(`/api/v1/steps/${step.id}/dynamic-data`)
|
||||
.set('Authorization', token)
|
||||
.expect(404);
|
||||
});
|
||||
|
@@ -118,7 +118,7 @@ describe('POST /api/v1/steps/:stepId/dynamic-fields', () => {
|
||||
const notExistingStepUUID = Crypto.randomUUID();
|
||||
|
||||
await request(app)
|
||||
.get(`/api/v1/steps/${notExistingStepUUID}/dynamic-fields`)
|
||||
.post(`/api/v1/steps/${notExistingStepUUID}/dynamic-fields`)
|
||||
.set('Authorization', token)
|
||||
.expect(404);
|
||||
});
|
||||
@@ -138,10 +138,11 @@ describe('POST /api/v1/steps/:stepId/dynamic-fields', () => {
|
||||
conditions: [],
|
||||
});
|
||||
|
||||
const step = await createStep({ appKey: null });
|
||||
const step = await createStep();
|
||||
await step.$query().patch({ appKey: null });
|
||||
|
||||
await request(app)
|
||||
.get(`/api/v1/steps/${step.id}/dynamic-fields`)
|
||||
.post(`/api/v1/steps/${step.id}/dynamic-fields`)
|
||||
.set('Authorization', token)
|
||||
.expect(404);
|
||||
});
|
||||
|
@@ -996,21 +996,9 @@ describe('User model', () => {
|
||||
|
||||
const user = await createUser();
|
||||
|
||||
const presentDate = DateTime.fromObject(
|
||||
{ year: 2024, month: 11, day: 17, hour: 11, minute: 30 },
|
||||
{ zone: 'UTC+0' }
|
||||
);
|
||||
|
||||
vi.setSystemTime(presentDate);
|
||||
|
||||
await user.startTrialPeriod();
|
||||
|
||||
const futureDate = DateTime.fromObject(
|
||||
{ year: 2025, month: 1, day: 1 },
|
||||
{ zone: 'UTC+0' }
|
||||
);
|
||||
|
||||
vi.setSystemTime(futureDate);
|
||||
vi.setSystemTime(DateTime.now().plus({ month: 1 }));
|
||||
|
||||
const refetchedUser = await user.$query();
|
||||
|
||||
@@ -1118,7 +1106,9 @@ describe('User model', () => {
|
||||
|
||||
const user = await createUser();
|
||||
|
||||
expect(() => user.getPlanAndUsage()).rejects.toThrow('NotFoundError');
|
||||
await expect(() => user.getPlanAndUsage()).rejects.toThrow(
|
||||
'NotFoundError'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1189,7 +1179,7 @@ describe('User model', () => {
|
||||
});
|
||||
|
||||
it('should throw not found error when user role does not exist', async () => {
|
||||
expect(() =>
|
||||
await expect(() =>
|
||||
User.registerUser({
|
||||
fullName: 'Sample user',
|
||||
email: 'user@automatisch.io',
|
||||
@@ -1257,6 +1247,8 @@ describe('User model', () => {
|
||||
|
||||
describe('createUsageData', () => {
|
||||
it('should create usage data if Automatisch is a cloud installation', async () => {
|
||||
vi.useFakeTimers();
|
||||
|
||||
vi.spyOn(appConfig, 'isCloud', 'get').mockReturnValue(true);
|
||||
|
||||
const user = await createUser({
|
||||
@@ -1264,10 +1256,14 @@ describe('User model', () => {
|
||||
email: 'user@automatisch.io',
|
||||
});
|
||||
|
||||
vi.setSystemTime(DateTime.now().plus({ month: 1 }));
|
||||
|
||||
const usageData = await user.createUsageData();
|
||||
const currentUsageData = await user.$relatedQuery('currentUsageData');
|
||||
|
||||
expect(usageData).toStrictEqual(currentUsageData);
|
||||
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it('should not create usage data if Automatisch is not a cloud installation', async () => {
|
||||
|
@@ -1,31 +1,4 @@
|
||||
import process from 'process';
|
||||
import { Queue } from 'bullmq';
|
||||
import redisConfig from '../config/redis.js';
|
||||
import logger from '../helpers/logger.js';
|
||||
|
||||
const CONNECTION_REFUSED = 'ECONNREFUSED';
|
||||
|
||||
const redisConnection = {
|
||||
connection: redisConfig,
|
||||
};
|
||||
|
||||
const actionQueue = new Queue('action', redisConnection);
|
||||
|
||||
process.on('SIGTERM', async () => {
|
||||
await actionQueue.close();
|
||||
});
|
||||
|
||||
actionQueue.on('error', (error) => {
|
||||
if (error.code === CONNECTION_REFUSED) {
|
||||
logger.error(
|
||||
'Make sure you have installed Redis and it is running.',
|
||||
error
|
||||
);
|
||||
|
||||
process.exit();
|
||||
}
|
||||
|
||||
logger.error('Error happened in action queue!', error);
|
||||
});
|
||||
import { generateQueue } from './queue.js';
|
||||
|
||||
const actionQueue = generateQueue('action');
|
||||
export default actionQueue;
|
||||
|
@@ -1,31 +1,4 @@
|
||||
import process from 'process';
|
||||
import { Queue } from 'bullmq';
|
||||
import redisConfig from '../config/redis.js';
|
||||
import logger from '../helpers/logger.js';
|
||||
|
||||
const CONNECTION_REFUSED = 'ECONNREFUSED';
|
||||
|
||||
const redisConnection = {
|
||||
connection: redisConfig,
|
||||
};
|
||||
|
||||
const deleteUserQueue = new Queue('delete-user', redisConnection);
|
||||
|
||||
process.on('SIGTERM', async () => {
|
||||
await deleteUserQueue.close();
|
||||
});
|
||||
|
||||
deleteUserQueue.on('error', (error) => {
|
||||
if (error.code === CONNECTION_REFUSED) {
|
||||
logger.error(
|
||||
'Make sure you have installed Redis and it is running.',
|
||||
error
|
||||
);
|
||||
|
||||
process.exit();
|
||||
}
|
||||
|
||||
logger.error('Error happened in delete user queue!', error);
|
||||
});
|
||||
import { generateQueue } from './queue.js';
|
||||
|
||||
const deleteUserQueue = generateQueue('delete-user');
|
||||
export default deleteUserQueue;
|
||||
|
@@ -1,31 +1,4 @@
|
||||
import process from 'process';
|
||||
import { Queue } from 'bullmq';
|
||||
import redisConfig from '../config/redis.js';
|
||||
import logger from '../helpers/logger.js';
|
||||
|
||||
const CONNECTION_REFUSED = 'ECONNREFUSED';
|
||||
|
||||
const redisConnection = {
|
||||
connection: redisConfig,
|
||||
};
|
||||
|
||||
const emailQueue = new Queue('email', redisConnection);
|
||||
|
||||
process.on('SIGTERM', async () => {
|
||||
await emailQueue.close();
|
||||
});
|
||||
|
||||
emailQueue.on('error', (error) => {
|
||||
if (error.code === CONNECTION_REFUSED) {
|
||||
logger.error(
|
||||
'Make sure you have installed Redis and it is running.',
|
||||
error
|
||||
);
|
||||
|
||||
process.exit();
|
||||
}
|
||||
|
||||
logger.error('Error happened in email queue!', error);
|
||||
});
|
||||
import { generateQueue } from './queue.js';
|
||||
|
||||
const emailQueue = generateQueue('email');
|
||||
export default emailQueue;
|
||||
|
@@ -1,31 +1,4 @@
|
||||
import process from 'process';
|
||||
import { Queue } from 'bullmq';
|
||||
import redisConfig from '../config/redis.js';
|
||||
import logger from '../helpers/logger.js';
|
||||
|
||||
const CONNECTION_REFUSED = 'ECONNREFUSED';
|
||||
|
||||
const redisConnection = {
|
||||
connection: redisConfig,
|
||||
};
|
||||
|
||||
const flowQueue = new Queue('flow', redisConnection);
|
||||
|
||||
process.on('SIGTERM', async () => {
|
||||
await flowQueue.close();
|
||||
});
|
||||
|
||||
flowQueue.on('error', (error) => {
|
||||
if (error.code === CONNECTION_REFUSED) {
|
||||
logger.error(
|
||||
'Make sure you have installed Redis and it is running.',
|
||||
error
|
||||
);
|
||||
|
||||
process.exit();
|
||||
}
|
||||
|
||||
logger.error('Error happened in flow queue!', error);
|
||||
});
|
||||
import { generateQueue } from './queue.js';
|
||||
|
||||
const flowQueue = generateQueue('flow');
|
||||
export default flowQueue;
|
||||
|
21
packages/backend/src/queues/index.js
Normal file
21
packages/backend/src/queues/index.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import appConfig from '../config/app.js';
|
||||
import actionQueue from './action.js';
|
||||
import emailQueue from './email.js';
|
||||
import flowQueue from './flow.js';
|
||||
import triggerQueue from './trigger.js';
|
||||
import deleteUserQueue from './delete-user.ee.js';
|
||||
import removeCancelledSubscriptionsQueue from './remove-cancelled-subscriptions.ee.js';
|
||||
|
||||
const queues = [
|
||||
actionQueue,
|
||||
emailQueue,
|
||||
flowQueue,
|
||||
triggerQueue,
|
||||
deleteUserQueue,
|
||||
];
|
||||
|
||||
if (appConfig.isCloud) {
|
||||
queues.push(removeCancelledSubscriptionsQueue);
|
||||
}
|
||||
|
||||
export default queues;
|
44
packages/backend/src/queues/queue.js
Normal file
44
packages/backend/src/queues/queue.js
Normal file
@@ -0,0 +1,44 @@
|
||||
import process from 'process';
|
||||
import { Queue } from 'bullmq';
|
||||
import redisConfig from '../config/redis.js';
|
||||
import logger from '../helpers/logger.js';
|
||||
|
||||
const CONNECTION_REFUSED = 'ECONNREFUSED';
|
||||
|
||||
const redisConnection = {
|
||||
connection: redisConfig,
|
||||
};
|
||||
|
||||
export const generateQueue = (queueName, options) => {
|
||||
const queue = new Queue(queueName, redisConnection);
|
||||
|
||||
queue.on('error', (error) => queueOnError(error, queueName));
|
||||
|
||||
if (options?.runDaily) addScheduler(queueName, queue);
|
||||
|
||||
return queue;
|
||||
};
|
||||
|
||||
const queueOnError = (error, queueName) => {
|
||||
if (error.code === CONNECTION_REFUSED) {
|
||||
const errorMessage =
|
||||
'Make sure you have installed Redis and it is running.';
|
||||
|
||||
logger.error(errorMessage, error);
|
||||
|
||||
process.exit();
|
||||
}
|
||||
|
||||
logger.error(`Error happened in ${queueName} queue!`, error);
|
||||
};
|
||||
|
||||
const addScheduler = (queueName, queue) => {
|
||||
const everydayAtOneOclock = '0 1 * * *';
|
||||
|
||||
queue.add(queueName, null, {
|
||||
jobId: queueName,
|
||||
repeat: {
|
||||
pattern: everydayAtOneOclock,
|
||||
},
|
||||
});
|
||||
};
|
@@ -1,44 +1,8 @@
|
||||
import process from 'process';
|
||||
import { Queue } from 'bullmq';
|
||||
import redisConfig from '../config/redis.js';
|
||||
import logger from '../helpers/logger.js';
|
||||
import { generateQueue } from './queue.js';
|
||||
|
||||
const CONNECTION_REFUSED = 'ECONNREFUSED';
|
||||
|
||||
const redisConnection = {
|
||||
connection: redisConfig,
|
||||
};
|
||||
|
||||
const removeCancelledSubscriptionsQueue = new Queue(
|
||||
const removeCancelledSubscriptionsQueue = generateQueue(
|
||||
'remove-cancelled-subscriptions',
|
||||
redisConnection
|
||||
{ runDaily: true }
|
||||
);
|
||||
|
||||
process.on('SIGTERM', async () => {
|
||||
await removeCancelledSubscriptionsQueue.close();
|
||||
});
|
||||
|
||||
removeCancelledSubscriptionsQueue.on('error', (error) => {
|
||||
if (error.code === CONNECTION_REFUSED) {
|
||||
logger.error(
|
||||
'Make sure you have installed Redis and it is running.',
|
||||
error
|
||||
);
|
||||
|
||||
process.exit();
|
||||
}
|
||||
|
||||
logger.error(
|
||||
'Error happened in remove cancelled subscriptions queue!',
|
||||
error
|
||||
);
|
||||
});
|
||||
|
||||
removeCancelledSubscriptionsQueue.add('remove-cancelled-subscriptions', null, {
|
||||
jobId: 'remove-cancelled-subscriptions',
|
||||
repeat: {
|
||||
pattern: '0 1 * * *',
|
||||
},
|
||||
});
|
||||
|
||||
export default removeCancelledSubscriptionsQueue;
|
||||
|
@@ -1,31 +1,4 @@
|
||||
import process from 'process';
|
||||
import { Queue } from 'bullmq';
|
||||
import redisConfig from '../config/redis.js';
|
||||
import logger from '../helpers/logger.js';
|
||||
|
||||
const CONNECTION_REFUSED = 'ECONNREFUSED';
|
||||
|
||||
const redisConnection = {
|
||||
connection: redisConfig,
|
||||
};
|
||||
|
||||
const triggerQueue = new Queue('trigger', redisConnection);
|
||||
|
||||
process.on('SIGTERM', async () => {
|
||||
await triggerQueue.close();
|
||||
});
|
||||
|
||||
triggerQueue.on('error', (error) => {
|
||||
if (error.code === CONNECTION_REFUSED) {
|
||||
logger.error(
|
||||
'Make sure you have installed Redis and it is running.',
|
||||
error
|
||||
);
|
||||
|
||||
process.exit();
|
||||
}
|
||||
|
||||
logger.error('Error happened in trigger queue!', error);
|
||||
});
|
||||
import { generateQueue } from './queue.js';
|
||||
|
||||
const triggerQueue = generateQueue('trigger');
|
||||
export default triggerQueue;
|
||||
|
@@ -1,20 +1,22 @@
|
||||
import * as Sentry from './helpers/sentry.ee.js';
|
||||
import appConfig from './config/app.js';
|
||||
import process from 'node:process';
|
||||
|
||||
Sentry.init();
|
||||
|
||||
import './config/orm.js';
|
||||
import './helpers/check-worker-readiness.js';
|
||||
import './workers/flow.js';
|
||||
import './workers/trigger.js';
|
||||
import './workers/action.js';
|
||||
import './workers/email.js';
|
||||
import './workers/delete-user.ee.js';
|
||||
import queues from './queues/index.js';
|
||||
import workers from './workers/index.js';
|
||||
|
||||
if (appConfig.isCloud) {
|
||||
import('./workers/remove-cancelled-subscriptions.ee.js');
|
||||
import('./queues/remove-cancelled-subscriptions.ee.js');
|
||||
}
|
||||
process.on('SIGTERM', async () => {
|
||||
for (const queue of queues) {
|
||||
await queue.close();
|
||||
}
|
||||
|
||||
for (const worker of workers) {
|
||||
await worker.close();
|
||||
}
|
||||
});
|
||||
|
||||
import telemetry from './helpers/telemetry/index.js';
|
||||
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import { Worker } from 'bullmq';
|
||||
import process from 'node:process';
|
||||
|
||||
import * as Sentry from '../helpers/sentry.ee.js';
|
||||
import redisConfig from '../config/redis.js';
|
||||
@@ -15,7 +14,7 @@ import delayAsMilliseconds from '../helpers/delay-as-milliseconds.js';
|
||||
|
||||
const DEFAULT_DELAY_DURATION = 0;
|
||||
|
||||
export const worker = new Worker(
|
||||
const actionWorker = new Worker(
|
||||
'action',
|
||||
async (job) => {
|
||||
const { stepId, flowId, executionId, computedParameters, executionStep } =
|
||||
@@ -55,11 +54,11 @@ export const worker = new Worker(
|
||||
{ connection: redisConfig }
|
||||
);
|
||||
|
||||
worker.on('completed', (job) => {
|
||||
actionWorker.on('completed', (job) => {
|
||||
logger.info(`JOB ID: ${job.id} - FLOW ID: ${job.data.flowId} has started!`);
|
||||
});
|
||||
|
||||
worker.on('failed', (job, err) => {
|
||||
actionWorker.on('failed', (job, err) => {
|
||||
const errorMessage = `
|
||||
JOB ID: ${job.id} - FLOW ID: ${job.data.flowId} has failed to start with ${err.message}
|
||||
\n ${err.stack}
|
||||
@@ -74,6 +73,4 @@ worker.on('failed', (job, err) => {
|
||||
});
|
||||
});
|
||||
|
||||
process.on('SIGTERM', async () => {
|
||||
await worker.close();
|
||||
});
|
||||
export default actionWorker;
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import { Worker } from 'bullmq';
|
||||
import process from 'node:process';
|
||||
|
||||
import * as Sentry from '../helpers/sentry.ee.js';
|
||||
import redisConfig from '../config/redis.js';
|
||||
@@ -8,7 +7,7 @@ import appConfig from '../config/app.js';
|
||||
import User from '../models/user.js';
|
||||
import ExecutionStep from '../models/execution-step.js';
|
||||
|
||||
export const worker = new Worker(
|
||||
const deleteUserWorker = new Worker(
|
||||
'delete-user',
|
||||
async (job) => {
|
||||
const { id } = job.data;
|
||||
@@ -46,13 +45,13 @@ export const worker = new Worker(
|
||||
{ connection: redisConfig }
|
||||
);
|
||||
|
||||
worker.on('completed', (job) => {
|
||||
deleteUserWorker.on('completed', (job) => {
|
||||
logger.info(
|
||||
`JOB ID: ${job.id} - The user with the ID of '${job.data.id}' has been deleted!`
|
||||
);
|
||||
});
|
||||
|
||||
worker.on('failed', (job, err) => {
|
||||
deleteUserWorker.on('failed', (job, err) => {
|
||||
const errorMessage = `
|
||||
JOB ID: ${job.id} - The user with the ID of '${job.data.id}' has failed to be deleted! ${err.message}
|
||||
\n ${err.stack}
|
||||
@@ -67,6 +66,4 @@ worker.on('failed', (job, err) => {
|
||||
});
|
||||
});
|
||||
|
||||
process.on('SIGTERM', async () => {
|
||||
await worker.close();
|
||||
});
|
||||
export default deleteUserWorker;
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import { Worker } from 'bullmq';
|
||||
import process from 'node:process';
|
||||
|
||||
import * as Sentry from '../helpers/sentry.ee.js';
|
||||
import redisConfig from '../config/redis.js';
|
||||
@@ -16,7 +15,7 @@ const isAutomatischEmail = (email) => {
|
||||
return email.endsWith('@automatisch.io');
|
||||
};
|
||||
|
||||
export const worker = new Worker(
|
||||
const emailWorker = new Worker(
|
||||
'email',
|
||||
async (job) => {
|
||||
const { email, subject, template, params } = job.data;
|
||||
@@ -39,13 +38,13 @@ export const worker = new Worker(
|
||||
{ connection: redisConfig }
|
||||
);
|
||||
|
||||
worker.on('completed', (job) => {
|
||||
emailWorker.on('completed', (job) => {
|
||||
logger.info(
|
||||
`JOB ID: ${job.id} - ${job.data.subject} email sent to ${job.data.email}!`
|
||||
);
|
||||
});
|
||||
|
||||
worker.on('failed', (job, err) => {
|
||||
emailWorker.on('failed', (job, err) => {
|
||||
const errorMessage = `
|
||||
JOB ID: ${job.id} - ${job.data.subject} email to ${job.data.email} has failed to send with ${err.message}
|
||||
\n ${err.stack}
|
||||
@@ -60,6 +59,4 @@ worker.on('failed', (job, err) => {
|
||||
});
|
||||
});
|
||||
|
||||
process.on('SIGTERM', async () => {
|
||||
await worker.close();
|
||||
});
|
||||
export default emailWorker;
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import { Worker } from 'bullmq';
|
||||
import process from 'node:process';
|
||||
|
||||
import * as Sentry from '../helpers/sentry.ee.js';
|
||||
import redisConfig from '../config/redis.js';
|
||||
@@ -13,7 +12,7 @@ import {
|
||||
REMOVE_AFTER_7_DAYS_OR_50_JOBS,
|
||||
} from '../helpers/remove-job-configuration.js';
|
||||
|
||||
export const worker = new Worker(
|
||||
const flowWorker = new Worker(
|
||||
'flow',
|
||||
async (job) => {
|
||||
const { flowId } = job.data;
|
||||
@@ -64,11 +63,11 @@ export const worker = new Worker(
|
||||
{ connection: redisConfig }
|
||||
);
|
||||
|
||||
worker.on('completed', (job) => {
|
||||
flowWorker.on('completed', (job) => {
|
||||
logger.info(`JOB ID: ${job.id} - FLOW ID: ${job.data.flowId} has started!`);
|
||||
});
|
||||
|
||||
worker.on('failed', async (job, err) => {
|
||||
flowWorker.on('failed', async (job, err) => {
|
||||
const errorMessage = `
|
||||
JOB ID: ${job.id} - FLOW ID: ${job.data.flowId} has failed to start with ${err.message}
|
||||
\n ${err.stack}
|
||||
@@ -95,6 +94,4 @@ worker.on('failed', async (job, err) => {
|
||||
});
|
||||
});
|
||||
|
||||
process.on('SIGTERM', async () => {
|
||||
await worker.close();
|
||||
});
|
||||
export default flowWorker;
|
||||
|
21
packages/backend/src/workers/index.js
Normal file
21
packages/backend/src/workers/index.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import appConfig from '../config/app.js';
|
||||
import actionWorker from './action.js';
|
||||
import emailWorker from './email.js';
|
||||
import flowWorker from './flow.js';
|
||||
import triggerWorker from './trigger.js';
|
||||
import deleteUserWorker from './delete-user.ee.js';
|
||||
import removeCancelledSubscriptionsWorker from './remove-cancelled-subscriptions.ee.js';
|
||||
|
||||
const workers = [
|
||||
actionWorker,
|
||||
emailWorker,
|
||||
flowWorker,
|
||||
triggerWorker,
|
||||
deleteUserWorker,
|
||||
];
|
||||
|
||||
if (appConfig.isCloud) {
|
||||
workers.push(removeCancelledSubscriptionsWorker);
|
||||
}
|
||||
|
||||
export default workers;
|
@@ -1,12 +1,11 @@
|
||||
import { Worker } from 'bullmq';
|
||||
import process from 'node:process';
|
||||
import { DateTime } from 'luxon';
|
||||
import * as Sentry from '../helpers/sentry.ee.js';
|
||||
import redisConfig from '../config/redis.js';
|
||||
import logger from '../helpers/logger.js';
|
||||
import Subscription from '../models/subscription.ee.js';
|
||||
|
||||
export const worker = new Worker(
|
||||
const removeCancelledSubscriptionsWorker = new Worker(
|
||||
'remove-cancelled-subscriptions',
|
||||
async () => {
|
||||
await Subscription.query()
|
||||
@@ -23,13 +22,13 @@ export const worker = new Worker(
|
||||
{ connection: redisConfig }
|
||||
);
|
||||
|
||||
worker.on('completed', (job) => {
|
||||
removeCancelledSubscriptionsWorker.on('completed', (job) => {
|
||||
logger.info(
|
||||
`JOB ID: ${job.id} - The cancelled subscriptions have been removed!`
|
||||
);
|
||||
});
|
||||
|
||||
worker.on('failed', (job, err) => {
|
||||
removeCancelledSubscriptionsWorker.on('failed', (job, err) => {
|
||||
const errorMessage = `
|
||||
JOB ID: ${job.id} - ERROR: The cancelled subscriptions can not be removed! ${err.message}
|
||||
\n ${err.stack}
|
||||
@@ -42,6 +41,4 @@ worker.on('failed', (job, err) => {
|
||||
});
|
||||
});
|
||||
|
||||
process.on('SIGTERM', async () => {
|
||||
await worker.close();
|
||||
});
|
||||
export default removeCancelledSubscriptionsWorker;
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import { Worker } from 'bullmq';
|
||||
import process from 'node:process';
|
||||
|
||||
import * as Sentry from '../helpers/sentry.ee.js';
|
||||
import redisConfig from '../config/redis.js';
|
||||
@@ -12,7 +11,7 @@ import {
|
||||
REMOVE_AFTER_7_DAYS_OR_50_JOBS,
|
||||
} from '../helpers/remove-job-configuration.js';
|
||||
|
||||
export const worker = new Worker(
|
||||
const triggerWorker = new Worker(
|
||||
'trigger',
|
||||
async (job) => {
|
||||
const { flowId, executionId, stepId, executionStep } = await processTrigger(
|
||||
@@ -41,11 +40,11 @@ export const worker = new Worker(
|
||||
{ connection: redisConfig }
|
||||
);
|
||||
|
||||
worker.on('completed', (job) => {
|
||||
triggerWorker.on('completed', (job) => {
|
||||
logger.info(`JOB ID: ${job.id} - FLOW ID: ${job.data.flowId} has started!`);
|
||||
});
|
||||
|
||||
worker.on('failed', (job, err) => {
|
||||
triggerWorker.on('failed', (job, err) => {
|
||||
const errorMessage = `
|
||||
JOB ID: ${job.id} - FLOW ID: ${job.data.flowId} has failed to start with ${err.message}
|
||||
\n ${err.stack}
|
||||
@@ -60,6 +59,4 @@ worker.on('failed', (job, err) => {
|
||||
});
|
||||
});
|
||||
|
||||
process.on('SIGTERM', async () => {
|
||||
await worker.close();
|
||||
});
|
||||
export default triggerWorker;
|
||||
|
@@ -1,21 +0,0 @@
|
||||
const { AuthenticatedPage } = require('./authenticated-page');
|
||||
const { expect } = require('@playwright/test');
|
||||
|
||||
export class ExecutionDetailsPage extends AuthenticatedPage {
|
||||
constructor(page) {
|
||||
super(page);
|
||||
|
||||
this.executionCreatedAt = page.getByTestId('execution-created-at');
|
||||
this.executionId = page.getByTestId('execution-id');
|
||||
this.executionName = page.getByTestId('execution-name');
|
||||
this.executionStep = page.getByTestId('execution-step');
|
||||
}
|
||||
|
||||
async verifyExecutionData(flowId) {
|
||||
await expect(this.executionCreatedAt).toContainText(/\d+ seconds? ago/);
|
||||
await expect(this.executionId).toHaveText(
|
||||
/Execution ID: [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i
|
||||
);
|
||||
await expect(this.executionName).toHaveText(flowId);
|
||||
}
|
||||
}
|
@@ -1,93 +0,0 @@
|
||||
const { ExecutionDetailsPage } = require('./execution-details-page');
|
||||
const { expect } = require('@playwright/test');
|
||||
|
||||
export class ExecutionStepDetails extends ExecutionDetailsPage {
|
||||
constructor(page, executionStep) {
|
||||
super(page);
|
||||
|
||||
this.executionStep = executionStep;
|
||||
this.stepType = executionStep.getByTestId('step-type');
|
||||
this.stepPositionAndName = executionStep.getByTestId(
|
||||
'step-position-and-name'
|
||||
);
|
||||
this.executionStepId = executionStep.getByTestId('execution-step-id');
|
||||
this.executionStepExecutedAt = executionStep.getByTestId(
|
||||
'execution-step-executed-at'
|
||||
);
|
||||
this.dataInTab = executionStep.getByTestId('data-in-tab');
|
||||
this.dataInPanel = executionStep.getByTestId('data-in-panel');
|
||||
this.dataOutTab = executionStep.getByTestId('data-out-tab');
|
||||
this.dataOutPanel = executionStep.getByTestId('data-out-panel');
|
||||
}
|
||||
|
||||
async expectDataInTabToBeSelectedByDefault() {
|
||||
await expect(this.dataInTab).toHaveClass(/Mui-selected/);
|
||||
}
|
||||
|
||||
async expectDataInToContainText(searchText, desiredText) {
|
||||
await expect(this.dataInPanel).toContainText(desiredText);
|
||||
await this.dataInPanel.locator('#search-input').fill(searchText);
|
||||
await expect(this.dataInPanel).toContainText(desiredText);
|
||||
}
|
||||
|
||||
async expectDataOutToContainText(searchText, desiredText) {
|
||||
await expect(this.dataOutPanel).toContainText(desiredText);
|
||||
await this.dataOutPanel.locator('#search-input').fill(searchText);
|
||||
await expect(this.dataOutPanel).toContainText(desiredText);
|
||||
}
|
||||
|
||||
async verifyTriggerExecutionStep({
|
||||
stepPositionAndName,
|
||||
stepDataInKey,
|
||||
stepDataInValue,
|
||||
stepDataOutKey,
|
||||
stepDataOutValue,
|
||||
}) {
|
||||
await expect(this.stepType).toHaveText('Trigger');
|
||||
await this.verifyExecutionStep({
|
||||
stepPositionAndName,
|
||||
stepDataInKey,
|
||||
stepDataInValue,
|
||||
stepDataOutKey,
|
||||
stepDataOutValue,
|
||||
});
|
||||
}
|
||||
|
||||
async verifyActionExecutionStep({
|
||||
stepPositionAndName,
|
||||
stepDataInKey,
|
||||
stepDataInValue,
|
||||
stepDataOutKey,
|
||||
stepDataOutValue,
|
||||
}) {
|
||||
await expect(this.stepType).toHaveText('Action');
|
||||
await this.verifyExecutionStep({
|
||||
stepPositionAndName,
|
||||
stepDataInKey,
|
||||
stepDataInValue,
|
||||
stepDataOutKey,
|
||||
stepDataOutValue,
|
||||
});
|
||||
}
|
||||
|
||||
async verifyExecutionStep({
|
||||
stepPositionAndName,
|
||||
stepDataInKey,
|
||||
stepDataInValue,
|
||||
stepDataOutKey,
|
||||
stepDataOutValue,
|
||||
}) {
|
||||
await expect(this.stepPositionAndName).toHaveText(stepPositionAndName);
|
||||
await expect(this.executionStepId).toHaveText(
|
||||
/ID: [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i
|
||||
);
|
||||
await expect(this.executionStepExecutedAt).toContainText(
|
||||
/executed \d+ seconds? ago/
|
||||
);
|
||||
await this.expectDataInTabToBeSelectedByDefault();
|
||||
await this.expectDataInToContainText(stepDataInKey, stepDataInValue);
|
||||
await this.dataOutTab.click();
|
||||
await expect(this.dataOutPanel).toContainText(stepDataOutValue);
|
||||
await this.expectDataOutToContainText(stepDataOutKey, stepDataOutValue);
|
||||
}
|
||||
}
|
@@ -2,11 +2,4 @@ const { AuthenticatedPage } = require('./authenticated-page');
|
||||
|
||||
export class ExecutionsPage extends AuthenticatedPage {
|
||||
screenshotPath = '/executions';
|
||||
|
||||
constructor(page) {
|
||||
super(page);
|
||||
|
||||
this.executionRow = this.page.getByTestId('execution-row');
|
||||
this.executionsPageLoader = this.page.getByTestId('executions-loader');
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,6 @@ const { test, expect } = require('@playwright/test');
|
||||
const { ApplicationsPage } = require('./applications-page');
|
||||
const { ConnectionsPage } = require('./connections-page');
|
||||
const { ExecutionsPage } = require('./executions-page');
|
||||
const { ExecutionDetailsPage } = require('./execution-details-page');
|
||||
const { FlowEditorPage } = require('./flow-editor-page');
|
||||
const { UserInterfacePage } = require('./user-interface-page');
|
||||
const { LoginPage } = require('./login-page');
|
||||
@@ -30,9 +29,6 @@ exports.test = test.extend({
|
||||
executionsPage: async ({ page }, use) => {
|
||||
await use(new ExecutionsPage(page));
|
||||
},
|
||||
executionDetailsPage: async ({ page }, use) => {
|
||||
await use(new ExecutionDetailsPage(page));
|
||||
},
|
||||
flowEditorPage: async ({ page }, use) => {
|
||||
await use(new FlowEditorPage(page));
|
||||
},
|
||||
|
@@ -1,15 +0,0 @@
|
||||
const { expect } = require('../fixtures/index');
|
||||
|
||||
export const getToken = async (apiRequest) => {
|
||||
const tokenResponse = await apiRequest.post(
|
||||
`http://localhost:${process.env.PORT}/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();
|
||||
};
|
@@ -1,108 +0,0 @@
|
||||
const { expect } = require('../fixtures/index');
|
||||
|
||||
export const createFlow = async (request, token) => {
|
||||
const response = await request.post(
|
||||
`http://localhost:${process.env.PORT}/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(
|
||||
`http://localhost:${process.env.PORT}/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(
|
||||
`http://localhost:${process.env.PORT}/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(
|
||||
`http://localhost:${process.env.PORT}/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(
|
||||
`http://localhost:${process.env.PORT}/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(
|
||||
`http://localhost:${process.env.PORT}/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);
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
@@ -2,14 +2,11 @@ const { publicTest: setup, expect } = require('../../fixtures/index');
|
||||
|
||||
setup.describe.serial('Admin setup page', () => {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
setup(
|
||||
'should not be able to login if admin is not created',
|
||||
async ({ page, adminSetupPage }) => {
|
||||
setup('should not be able to login if admin is not created', async ({ page, adminSetupPage, loginPage }) => {
|
||||
await expect(async () => {
|
||||
await expect(await page.url()).toContain(adminSetupPage.path);
|
||||
}).toPass();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
setup('should validate the inputs', async ({ adminSetupPage }) => {
|
||||
await adminSetupPage.open();
|
||||
|
@@ -1,138 +1,37 @@
|
||||
const { request } = require('@playwright/test');
|
||||
const { test, expect } = require('../../fixtures/index');
|
||||
const {
|
||||
triggerFlow,
|
||||
publishFlow,
|
||||
addWebhookFlow,
|
||||
} = require('../../helpers/flow-api-helper');
|
||||
const {
|
||||
ExecutionStepDetails,
|
||||
} = require('../../fixtures/execution-step-details');
|
||||
const { getToken } = require('../../helpers/auth-api-helper');
|
||||
|
||||
test.describe('Executions page', () => {
|
||||
let flowId;
|
||||
|
||||
test.beforeAll(async () => {
|
||||
const apiRequest = await request.newContext();
|
||||
const tokenJsonResponse = await getToken(apiRequest);
|
||||
|
||||
flowId = await addWebhookFlow(apiRequest, tokenJsonResponse.data.token);
|
||||
|
||||
const { data } = await publishFlow(
|
||||
apiRequest,
|
||||
tokenJsonResponse.data.token,
|
||||
flowId
|
||||
);
|
||||
|
||||
const triggerStepWebhookUrl = data.steps.find(
|
||||
(step) => step.type === 'trigger'
|
||||
).webhookUrl;
|
||||
|
||||
await triggerFlow(apiRequest, triggerStepWebhookUrl);
|
||||
});
|
||||
|
||||
// no execution data exists in an empty account
|
||||
test.describe.skip('Executions page', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.getByTestId('executions-page-drawer-link').click();
|
||||
await page.getByTestId('execution-row').first().click();
|
||||
|
||||
await expect(page).toHaveURL(/\/executions\//);
|
||||
});
|
||||
|
||||
test('show correct step data for trigger and actions on test and non-test execution', async ({
|
||||
page,
|
||||
executionsPage,
|
||||
executionDetailsPage,
|
||||
}) => {
|
||||
await executionsPage.executionsPageLoader.waitFor({
|
||||
state: 'detached',
|
||||
});
|
||||
const flowExecutions = await executionsPage.executionRow.filter({
|
||||
hasText: flowId,
|
||||
});
|
||||
await test.step('show only trigger step on test execution', async () => {
|
||||
await expect(flowExecutions.last()).toContainText('Test run');
|
||||
await flowExecutions.last().click();
|
||||
test('displays data in by default', async ({ page, executionsPage }) => {
|
||||
await expect(page.getByTestId('execution-step').last()).toBeVisible();
|
||||
await expect(page.getByTestId('execution-step')).toHaveCount(2);
|
||||
|
||||
await executionDetailsPage.verifyExecutionData(flowId);
|
||||
await expect(executionDetailsPage.executionStep).toHaveCount(1);
|
||||
|
||||
const executionStepDetails = new ExecutionStepDetails(
|
||||
page,
|
||||
executionDetailsPage.executionStep.last()
|
||||
);
|
||||
await executionStepDetails.verifyTriggerExecutionStep({
|
||||
stepPositionAndName: '1. Webhook',
|
||||
stepDataInKey: 'workSynchronously',
|
||||
stepDataInValue: 'workSynchronously',
|
||||
stepDataOutKey: 'host',
|
||||
stepDataOutValue: 'localhost',
|
||||
});
|
||||
|
||||
await page.goBack();
|
||||
});
|
||||
|
||||
await test.step('show trigger and action step on action test execution', async () => {
|
||||
await expect(flowExecutions.nth(1)).toContainText('Test run');
|
||||
await flowExecutions.nth(1).click();
|
||||
|
||||
await expect(executionDetailsPage.executionStep).toHaveCount(2);
|
||||
await executionDetailsPage.verifyExecutionData(flowId);
|
||||
|
||||
const firstExecutionStepDetails = new ExecutionStepDetails(
|
||||
page,
|
||||
executionDetailsPage.executionStep.first()
|
||||
);
|
||||
await firstExecutionStepDetails.verifyTriggerExecutionStep({
|
||||
stepPositionAndName: '1. Webhook',
|
||||
stepDataInKey: 'workSynchronously',
|
||||
stepDataInValue: 'workSynchronously',
|
||||
stepDataOutKey: 'host',
|
||||
stepDataOutValue: 'localhost',
|
||||
});
|
||||
|
||||
const lastExecutionStepDetails = new ExecutionStepDetails(
|
||||
page,
|
||||
executionDetailsPage.executionStep.last()
|
||||
);
|
||||
await lastExecutionStepDetails.verifyActionExecutionStep({
|
||||
stepPositionAndName: '2. Webhook',
|
||||
stepDataInKey: 'body',
|
||||
stepDataInValue: 'body:"ok"',
|
||||
stepDataOutKey: 'body',
|
||||
stepDataOutValue: 'body:"ok"',
|
||||
});
|
||||
|
||||
await page.goBack();
|
||||
});
|
||||
|
||||
await test.step('show trigger and action step on flow execution', async () => {
|
||||
await expect(flowExecutions.first()).not.toContainText('Test run');
|
||||
await flowExecutions.first().click();
|
||||
|
||||
await expect(executionDetailsPage.executionStep).toHaveCount(2);
|
||||
await executionDetailsPage.verifyExecutionData(flowId);
|
||||
|
||||
const firstExecutionStepDetails = new ExecutionStepDetails(
|
||||
page,
|
||||
executionDetailsPage.executionStep.first()
|
||||
);
|
||||
await firstExecutionStepDetails.verifyTriggerExecutionStep({
|
||||
stepPositionAndName: '1. Webhook',
|
||||
stepDataInKey: 'workSynchronously',
|
||||
stepDataInValue: 'workSynchronously',
|
||||
stepDataOutKey: 'host',
|
||||
stepDataOutValue: 'localhost',
|
||||
});
|
||||
|
||||
const lastExecutionStepDetails = new ExecutionStepDetails(
|
||||
page,
|
||||
executionDetailsPage.executionStep.last()
|
||||
);
|
||||
await lastExecutionStepDetails.verifyActionExecutionStep({
|
||||
stepPositionAndName: '2. Webhook',
|
||||
stepDataInKey: 'body',
|
||||
stepDataInValue: 'body:"ok"',
|
||||
stepDataOutKey: 'body',
|
||||
stepDataOutValue: 'body:"ok"',
|
||||
await executionsPage.screenshot({
|
||||
path: 'Execution - data in.png',
|
||||
});
|
||||
});
|
||||
|
||||
test('displays data out', async ({ page, executionsPage }) => {
|
||||
const executionStepCount = await page.getByTestId('execution-step').count();
|
||||
for (let i = 0; i < executionStepCount; i++) {
|
||||
await page.getByTestId('data-out-tab').nth(i).click();
|
||||
await expect(page.getByTestId('data-out-panel').nth(i)).toBeVisible();
|
||||
|
||||
await executionsPage.screenshot({
|
||||
path: `Execution - data out - ${i}.png`,
|
||||
animations: 'disabled',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
test('does not display error', async ({ page }) => {
|
||||
await expect(page.getByTestId('error-tab')).toBeHidden();
|
||||
});
|
||||
});
|
||||
|
@@ -1,54 +1,17 @@
|
||||
const { request } = require('@playwright/test');
|
||||
const { test, expect } = require('../../fixtures/index');
|
||||
const {
|
||||
triggerFlow,
|
||||
publishFlow,
|
||||
addWebhookFlow,
|
||||
} = require('../../helpers/flow-api-helper');
|
||||
const { getToken } = require('../../helpers/auth-api-helper');
|
||||
|
||||
test.describe('Executions page', () => {
|
||||
let flowId;
|
||||
|
||||
test.beforeAll(async () => {
|
||||
const apiRequest = await request.newContext();
|
||||
const tokenJsonResponse = await getToken(apiRequest);
|
||||
|
||||
flowId = await addWebhookFlow(apiRequest, tokenJsonResponse.data.token);
|
||||
|
||||
const { data } = await publishFlow(
|
||||
apiRequest,
|
||||
tokenJsonResponse.data.token,
|
||||
flowId
|
||||
);
|
||||
|
||||
const triggerStepWebhookUrl = data.steps.find(
|
||||
(step) => step.type === 'trigger'
|
||||
).webhookUrl;
|
||||
|
||||
await triggerFlow(apiRequest, triggerStepWebhookUrl);
|
||||
});
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.getByTestId('executions-page-drawer-link').click();
|
||||
});
|
||||
|
||||
test('should be able to see normal and test executions', async ({
|
||||
executionsPage,
|
||||
}) => {
|
||||
await executionsPage.executionsPageLoader.waitFor({
|
||||
// no executions exist in an empty account
|
||||
test.skip('displays executions', async ({ page, executionsPage }) => {
|
||||
await page.getByTestId('executions-loader').waitFor({
|
||||
state: 'detached',
|
||||
});
|
||||
const flowExecutions = await executionsPage.executionRow.filter({
|
||||
hasText: flowId,
|
||||
});
|
||||
await expect(page.getByTestId('execution-row').first()).toBeVisible();
|
||||
|
||||
await expect(flowExecutions).toHaveCount(4);
|
||||
await expect(flowExecutions.first()).toContainText('Success');
|
||||
await expect(flowExecutions.first()).not.toContainText('Test run');
|
||||
for (let testFlow = 1; testFlow < 4; testFlow++) {
|
||||
await expect(flowExecutions.nth(testFlow)).toContainText('Test run');
|
||||
await expect(flowExecutions.nth(testFlow)).toContainText('Success');
|
||||
}
|
||||
await executionsPage.screenshot({ path: 'Executions.png' });
|
||||
});
|
||||
});
|
||||
|
@@ -10,7 +10,7 @@ import { ExecutionPropType } from 'propTypes/propTypes';
|
||||
|
||||
function ExecutionName(props) {
|
||||
return (
|
||||
<Typography data-test="execution-name" variant="h3" gutterBottom>
|
||||
<Typography variant="h3" gutterBottom>
|
||||
{props.name}
|
||||
</Typography>
|
||||
);
|
||||
@@ -29,7 +29,7 @@ function ExecutionId(props) {
|
||||
);
|
||||
return (
|
||||
<Box sx={{ display: 'flex' }}>
|
||||
<Typography data-test="execution-id" variant="body2">
|
||||
<Typography variant="body2">
|
||||
{formatMessage('execution.id', { id })}
|
||||
</Typography>
|
||||
</Box>
|
||||
@@ -47,7 +47,7 @@ function ExecutionDate(props) {
|
||||
<Tooltip
|
||||
title={createdAt.toLocaleString(DateTime.DATETIME_FULL_WITH_SECONDS)}
|
||||
>
|
||||
<Typography data-test="execution-created-at" variant="body1" gutterBottom>
|
||||
<Typography variant="body1" gutterBottom>
|
||||
{relativeCreatedAt}
|
||||
</Typography>
|
||||
</Tooltip>
|
||||
|
@@ -36,11 +36,7 @@ function ExecutionStepId(props) {
|
||||
|
||||
return (
|
||||
<Box sx={{ display: 'flex' }} gridArea="id">
|
||||
<Typography
|
||||
data-test="execution-step-id"
|
||||
variant="caption"
|
||||
fontWeight="bold"
|
||||
>
|
||||
<Typography variant="caption" fontWeight="bold">
|
||||
{formatMessage('executionStep.id', { id })}
|
||||
</Typography>
|
||||
</Box>
|
||||
@@ -60,11 +56,7 @@ function ExecutionStepDate(props) {
|
||||
<Tooltip
|
||||
title={createdAt.toLocaleString(DateTime.DATETIME_FULL_WITH_SECONDS)}
|
||||
>
|
||||
<Typography
|
||||
data-test="execution-step-executed-at"
|
||||
variant="caption"
|
||||
gutterBottom
|
||||
>
|
||||
<Typography variant="caption" gutterBottom>
|
||||
{formatMessage('executionStep.executedAt', {
|
||||
datetime: relativeCreatedAt,
|
||||
})}
|
||||
@@ -127,12 +119,12 @@ function ExecutionStep(props) {
|
||||
<ExecutionStepId id={executionStep.step.id} />
|
||||
|
||||
<Box flex="1" gridArea="step">
|
||||
<Typography data-test="step-type" variant="caption">
|
||||
<Typography variant="caption">
|
||||
{isTrigger && formatMessage('flowStep.triggerType')}
|
||||
{isAction && formatMessage('flowStep.actionType')}
|
||||
</Typography>
|
||||
|
||||
<Typography data-test="step-position-and-name" variant="body2">
|
||||
<Typography variant="body2">
|
||||
{step.position}. {app?.name}
|
||||
</Typography>
|
||||
</Box>
|
||||
@@ -160,7 +152,7 @@ function ExecutionStep(props) {
|
||||
</Tabs>
|
||||
</Box>
|
||||
|
||||
<TabPanel value={activeTabIndex} index={0} data-test="data-in-panel">
|
||||
<TabPanel value={activeTabIndex} index={0}>
|
||||
<SearchableJSONViewer data={executionStep.dataIn} />
|
||||
</TabPanel>
|
||||
|
||||
|
Reference in New Issue
Block a user