mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-26 21:19:43 -08:00
f2939568cf
At https://github.com/n8n-io/n8n/pull/8213 we introduced Redis hashes for workflow ownership and manual webhooks... - to remove clutter from multiple related keys at the top level, - to improve performance by preventing serializing-deserializing, and - to guarantee atomicity during concurrent updates in multi-main setup. Workflow activation errors can also benefit from this. Added test coverage as well. To test manually, create a workflow with a trigger with an invalid credential, edit the workflow's `active` column to `true`, and restart. The activation error should show as a red triangle on canvas and in the workflow list.
88 lines
2.8 KiB
TypeScript
88 lines
2.8 KiB
TypeScript
import { ActivationErrorsService } from '@/ActivationErrors.service';
|
|
import { CacheService } from '@/services/cache/cache.service';
|
|
|
|
describe('ActivationErrorsService', () => {
|
|
const cacheService = new CacheService();
|
|
const activationErrorsService = new ActivationErrorsService(cacheService);
|
|
|
|
const firstWorkflowId = 'GSG0etbfTA2CNPDX';
|
|
const secondWorkflowId = 'k2ORscMPO66K0Jk3';
|
|
|
|
const firstErrorMsg = 'Failed to activate';
|
|
const secondErrorMsg = 'Also failed to activate';
|
|
|
|
afterEach(async () => {
|
|
await activationErrorsService.clearAll();
|
|
});
|
|
|
|
describe('register', () => {
|
|
test('should register an activation error for a workflow', async () => {
|
|
await activationErrorsService.register(firstWorkflowId, firstErrorMsg);
|
|
|
|
const activationError = await activationErrorsService.get(firstWorkflowId);
|
|
|
|
expect(activationError).toBe(firstErrorMsg);
|
|
});
|
|
});
|
|
|
|
describe('deregister', () => {
|
|
test('should deregister an activation error for a workflow', async () => {
|
|
await activationErrorsService.register(firstWorkflowId, firstErrorMsg);
|
|
|
|
await activationErrorsService.deregister(firstWorkflowId);
|
|
|
|
const activationError = await activationErrorsService.get(firstWorkflowId);
|
|
|
|
expect(activationError).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe('get', () => {
|
|
test('should retrieve an activation error for a workflow', async () => {
|
|
await activationErrorsService.register(firstWorkflowId, firstErrorMsg);
|
|
|
|
const activationError = await activationErrorsService.get(firstWorkflowId);
|
|
|
|
expect(activationError).toBe(firstErrorMsg);
|
|
});
|
|
|
|
test('should return `null` if no activation error found for a workflow', async () => {
|
|
const activationError = await activationErrorsService.get(firstWorkflowId);
|
|
|
|
expect(activationError).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe('getAll', () => {
|
|
test('should retrieve all activation errors', async () => {
|
|
await activationErrorsService.register(firstWorkflowId, firstErrorMsg);
|
|
await activationErrorsService.register(secondWorkflowId, secondErrorMsg);
|
|
|
|
const allActivationErrors = await activationErrorsService.getAll();
|
|
|
|
expect(allActivationErrors).toEqual({
|
|
[firstWorkflowId]: firstErrorMsg,
|
|
[secondWorkflowId]: secondErrorMsg,
|
|
});
|
|
});
|
|
|
|
test('should return an empty object if no activation errors', async () => {
|
|
const allActivationErrors = await activationErrorsService.getAll();
|
|
|
|
expect(allActivationErrors).toEqual({});
|
|
});
|
|
});
|
|
|
|
describe('clearAll()', () => {
|
|
test('should clear activation errors', async () => {
|
|
await activationErrorsService.register(firstWorkflowId, firstErrorMsg);
|
|
await activationErrorsService.register(secondWorkflowId, secondErrorMsg);
|
|
|
|
await activationErrorsService.clearAll();
|
|
|
|
const allActivationErrors = await activationErrorsService.getAll();
|
|
expect(allActivationErrors).toEqual({});
|
|
});
|
|
});
|
|
});
|