diff --git a/packages/cli/.eslintrc.js b/packages/cli/.eslintrc.js index bb1041607ddcd4..17ecfee499ae99 100644 --- a/packages/cli/.eslintrc.js +++ b/packages/cli/.eslintrc.js @@ -40,13 +40,13 @@ module.exports = { overrides: [ { - files: ['./src/databases/**/*.ts', './test/**/*.ts'], + files: ['./src/databases/**/*.ts', './test/**/*.ts', './src/**/__tests__/**/*.ts'], rules: { 'n8n-local-rules/misplaced-n8n-typeorm-import': 'off', }, }, { - files: ['./test/**/*.ts'], + files: ['./test/**/*.ts', './src/**/__tests__/**/*.ts'], rules: { 'n8n-local-rules/no-type-unsafe-event-emitter': 'off', }, diff --git a/packages/cli/src/ActiveWebhooks.ts b/packages/cli/src/ActiveWebhooks.ts index 79626df025f753..43136e75d384a8 100644 --- a/packages/cli/src/ActiveWebhooks.ts +++ b/packages/cli/src/ActiveWebhooks.ts @@ -72,11 +72,9 @@ export class ActiveWebhooks implements IWebhookManager { const pathElements = path.split('/').slice(1); // extracting params from path - // @ts-ignore webhook.webhookPath.split('/').forEach((ele, index) => { if (ele.startsWith(':')) { // write params to req.params - // @ts-ignore request.params[ele.slice(1)] = pathElements[index]; } }); diff --git a/packages/cli/test/unit/ExternalSecrets/ExternalSecretsManager.test.ts b/packages/cli/src/ExternalSecrets/__tests__/ExternalSecretsManager.ee.test.ts similarity index 97% rename from packages/cli/test/unit/ExternalSecrets/ExternalSecretsManager.test.ts rename to packages/cli/src/ExternalSecrets/__tests__/ExternalSecretsManager.ee.test.ts index cf72688d24397d..92475c93115e94 100644 --- a/packages/cli/test/unit/ExternalSecrets/ExternalSecretsManager.test.ts +++ b/packages/cli/src/ExternalSecrets/__tests__/ExternalSecretsManager.ee.test.ts @@ -6,13 +6,13 @@ import { License } from '@/License'; import { ExternalSecretsManager } from '@/ExternalSecrets/ExternalSecretsManager.ee'; import { ExternalSecretsProviders } from '@/ExternalSecrets/ExternalSecretsProviders.ee'; import { InternalHooks } from '@/InternalHooks'; -import { mockInstance } from '../../shared/mocking'; +import { mockInstance } from '@test/mocking'; import { DummyProvider, ErrorProvider, FailedProvider, MockProviders, -} from '../../shared/ExternalSecrets/utils'; +} from '@test/ExternalSecrets/utils'; import { mock } from 'jest-mock-extended'; describe('External Secrets Manager', () => { diff --git a/packages/cli/test/unit/Ldap/helpers.test.ts b/packages/cli/src/Ldap/__tests__/helpers.test.ts similarity index 96% rename from packages/cli/test/unit/Ldap/helpers.test.ts rename to packages/cli/src/Ldap/__tests__/helpers.test.ts index debb96da382d16..719adea76c5a74 100644 --- a/packages/cli/test/unit/Ldap/helpers.test.ts +++ b/packages/cli/src/Ldap/__tests__/helpers.test.ts @@ -1,5 +1,5 @@ import { UserRepository } from '@/databases/repositories/user.repository'; -import { mockInstance } from '../../shared/mocking'; +import { mockInstance } from '@test/mocking'; import * as helpers from '@/Ldap/helpers.ee'; import { AuthIdentity } from '@/databases/entities/AuthIdentity'; import { User } from '@/databases/entities/User'; diff --git a/packages/cli/test/unit/UserManagementMailer.test.ts b/packages/cli/src/UserManagement/email/__tests__/UserManagementMailer.test.ts similarity index 100% rename from packages/cli/test/unit/UserManagementMailer.test.ts rename to packages/cli/src/UserManagement/email/__tests__/UserManagementMailer.test.ts diff --git a/packages/cli/src/WorkflowExecuteAdditionalData.ts b/packages/cli/src/WorkflowExecuteAdditionalData.ts index 74c469284a7eb3..21a5cc70934c42 100644 --- a/packages/cli/src/WorkflowExecuteAdditionalData.ts +++ b/packages/cli/src/WorkflowExecuteAdditionalData.ts @@ -717,7 +717,6 @@ export async function getRunData( const runData: IWorkflowExecutionDataProcess = { executionMode: mode, executionData: runExecutionData, - // @ts-ignore workflowData, }; diff --git a/packages/cli/test/unit/ActiveExecutions.test.ts b/packages/cli/src/__tests__/ActiveExecutions.test.ts similarity index 100% rename from packages/cli/test/unit/ActiveExecutions.test.ts rename to packages/cli/src/__tests__/ActiveExecutions.test.ts diff --git a/packages/cli/test/unit/CredentialTypes.test.ts b/packages/cli/src/__tests__/CredentialTypes.test.ts similarity index 95% rename from packages/cli/test/unit/CredentialTypes.test.ts rename to packages/cli/src/__tests__/CredentialTypes.test.ts index 0ee99c9f8ae6e8..2a8e6a939a0450 100644 --- a/packages/cli/test/unit/CredentialTypes.test.ts +++ b/packages/cli/src/__tests__/CredentialTypes.test.ts @@ -1,7 +1,7 @@ import { CredentialTypes } from '@/CredentialTypes'; import { Container } from 'typedi'; import { LoadNodesAndCredentials } from '@/LoadNodesAndCredentials'; -import { mockInstance } from '../shared/mocking'; +import { mockInstance } from '@test/mocking'; describe('CredentialTypes', () => { const mockNodesAndCredentials = mockInstance(LoadNodesAndCredentials, { diff --git a/packages/cli/test/unit/CredentialsHelper.test.ts b/packages/cli/src/__tests__/CredentialsHelper.test.ts similarity index 99% rename from packages/cli/test/unit/CredentialsHelper.test.ts rename to packages/cli/src/__tests__/CredentialsHelper.test.ts index 19be100b02b841..88cd19ad3dc5dc 100644 --- a/packages/cli/test/unit/CredentialsHelper.test.ts +++ b/packages/cli/src/__tests__/CredentialsHelper.test.ts @@ -14,7 +14,7 @@ import { NodeTypes } from '@/NodeTypes'; import { LoadNodesAndCredentials } from '@/LoadNodesAndCredentials'; import { CredentialsRepository } from '@db/repositories/credentials.repository'; import { SharedCredentialsRepository } from '@db/repositories/sharedCredentials.repository'; -import { mockInstance } from '../shared/mocking'; +import { mockInstance } from '@test/mocking'; describe('CredentialsHelper', () => { mockInstance(CredentialsRepository); diff --git a/packages/cli/test/unit/License.test.ts b/packages/cli/src/__tests__/License.test.ts similarity index 99% rename from packages/cli/test/unit/License.test.ts rename to packages/cli/src/__tests__/License.test.ts index 6d7311656c961c..31effecc0eba48 100644 --- a/packages/cli/test/unit/License.test.ts +++ b/packages/cli/src/__tests__/License.test.ts @@ -5,7 +5,7 @@ import config from '@/config'; import { License } from '@/License'; import { Logger } from '@/Logger'; import { N8N_VERSION } from '@/constants'; -import { mockInstance } from '../shared/mocking'; +import { mockInstance } from '@test/mocking'; import { OrchestrationService } from '@/services/orchestration.service'; jest.mock('@n8n_io/license-sdk'); diff --git a/packages/cli/test/unit/TestWebhooks.test.ts b/packages/cli/src/__tests__/TestWebhooks.test.ts similarity index 100% rename from packages/cli/test/unit/TestWebhooks.test.ts rename to packages/cli/src/__tests__/TestWebhooks.test.ts diff --git a/packages/cli/test/unit/WaitTracker.test.ts b/packages/cli/src/__tests__/WaitTracker.test.ts similarity index 100% rename from packages/cli/test/unit/WaitTracker.test.ts rename to packages/cli/src/__tests__/WaitTracker.test.ts diff --git a/packages/cli/test/unit/WebhookHelpers.test.ts b/packages/cli/src/__tests__/WebhookHelpers.test.ts similarity index 100% rename from packages/cli/test/unit/WebhookHelpers.test.ts rename to packages/cli/src/__tests__/WebhookHelpers.test.ts diff --git a/packages/cli/test/unit/WorkflowExecuteAdditionalData.test.ts b/packages/cli/src/__tests__/WorkflowExecuteAdditionalData.test.ts similarity index 96% rename from packages/cli/test/unit/WorkflowExecuteAdditionalData.test.ts rename to packages/cli/src/__tests__/WorkflowExecuteAdditionalData.test.ts index 2984220637aaed..eca60e56c52169 100644 --- a/packages/cli/test/unit/WorkflowExecuteAdditionalData.test.ts +++ b/packages/cli/src/__tests__/WorkflowExecuteAdditionalData.test.ts @@ -1,5 +1,5 @@ import { VariablesService } from '@/environments/variables/variables.service.ee'; -import { mockInstance } from '../shared/mocking'; +import { mockInstance } from '@test/mocking'; import { MessageEventBus } from '@/eventbus/MessageEventBus/MessageEventBus'; import { getBase } from '@/WorkflowExecuteAdditionalData'; import Container from 'typedi'; diff --git a/packages/cli/test/unit/WorkflowHelpers.test.ts b/packages/cli/src/__tests__/WorkflowHelpers.test.ts similarity index 100% rename from packages/cli/test/unit/WorkflowHelpers.test.ts rename to packages/cli/src/__tests__/WorkflowHelpers.test.ts diff --git a/packages/cli/test/unit/WorkflowRunner.test.ts b/packages/cli/src/__tests__/WorkflowRunner.test.ts similarity index 86% rename from packages/cli/test/unit/WorkflowRunner.test.ts rename to packages/cli/src/__tests__/WorkflowRunner.test.ts index c972d6bb739331..668150092f60aa 100644 --- a/packages/cli/test/unit/WorkflowRunner.test.ts +++ b/packages/cli/src/__tests__/WorkflowRunner.test.ts @@ -4,11 +4,11 @@ import type { User } from '@db/entities/User'; import { WorkflowRunner } from '@/WorkflowRunner'; import config from '@/config'; -import * as testDb from '../integration/shared/testDb'; -import { setupTestServer } from '../integration/shared/utils'; -import { createUser } from '../integration/shared/db/users'; -import { createWorkflow } from '../integration/shared/db/workflows'; -import { createExecution } from '../integration/shared/db/executions'; +import * as testDb from '@test-integration/testDb'; +import { setupTestServer } from '@test-integration/utils'; +import { createUser } from '@test-integration/db/users'; +import { createWorkflow } from '@test-integration/db/workflows'; +import { createExecution } from '@test-integration/db/executions'; import { mockInstance } from '@test/mocking'; import { Telemetry } from '@/telemetry'; diff --git a/packages/cli/test/unit/auth/auth.service.test.ts b/packages/cli/src/auth/__tests__/auth.service.test.ts similarity index 100% rename from packages/cli/test/unit/auth/auth.service.test.ts rename to packages/cli/src/auth/__tests__/auth.service.test.ts diff --git a/packages/cli/test/unit/commands/db/revert.test.ts b/packages/cli/src/commands/db/__tests__/revert.test.ts similarity index 98% rename from packages/cli/test/unit/commands/db/revert.test.ts rename to packages/cli/src/commands/db/__tests__/revert.test.ts index cea3f89253383c..13c554a786ad3e 100644 --- a/packages/cli/test/unit/commands/db/revert.test.ts +++ b/packages/cli/src/commands/db/__tests__/revert.test.ts @@ -1,5 +1,5 @@ import { main } from '@/commands/db/revert'; -import { mockInstance } from '../../../shared/mocking'; +import { mockInstance } from '@test/mocking'; import { Logger } from '@/Logger'; import type { IrreversibleMigration, ReversibleMigration } from '@/databases/types'; import type { Migration, MigrationExecutor } from '@n8n/typeorm'; diff --git a/packages/cli/test/unit/config/index.test.ts b/packages/cli/src/config/__tests__/index.test.ts similarity index 100% rename from packages/cli/test/unit/config/index.test.ts rename to packages/cli/src/config/__tests__/index.test.ts diff --git a/packages/cli/test/unit/controllers/curl.controller.test.ts b/packages/cli/src/controllers/__tests__/curl.controller.test.ts similarity index 100% rename from packages/cli/test/unit/controllers/curl.controller.test.ts rename to packages/cli/src/controllers/__tests__/curl.controller.test.ts diff --git a/packages/cli/test/unit/controllers/dynamic-node-parameters.controller.test.ts b/packages/cli/src/controllers/__tests__/dynamic-node-parameters.controller.test.ts similarity index 100% rename from packages/cli/test/unit/controllers/dynamic-node-parameters.controller.test.ts rename to packages/cli/src/controllers/__tests__/dynamic-node-parameters.controller.test.ts diff --git a/packages/cli/test/unit/controllers/me.controller.test.ts b/packages/cli/src/controllers/__tests__/me.controller.test.ts similarity index 98% rename from packages/cli/test/unit/controllers/me.controller.test.ts rename to packages/cli/src/controllers/__tests__/me.controller.test.ts index 2416ecafbddb4f..9fd165be80c5db 100644 --- a/packages/cli/test/unit/controllers/me.controller.test.ts +++ b/packages/cli/src/controllers/__tests__/me.controller.test.ts @@ -13,8 +13,8 @@ import { InternalHooks } from '@/InternalHooks'; import { License } from '@/License'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { UserRepository } from '@/databases/repositories/user.repository'; -import { badPasswords } from '../shared/testData'; -import { mockInstance } from '../../shared/mocking'; +import { badPasswords } from '@test/testData'; +import { mockInstance } from '@test/mocking'; const browserId = 'test-browser-id'; diff --git a/packages/cli/test/unit/controllers/owner.controller.test.ts b/packages/cli/src/controllers/__tests__/owner.controller.test.ts similarity index 97% rename from packages/cli/test/unit/controllers/owner.controller.test.ts rename to packages/cli/src/controllers/__tests__/owner.controller.test.ts index 0057c2370896b1..3aabc87cade9a4 100644 --- a/packages/cli/test/unit/controllers/owner.controller.test.ts +++ b/packages/cli/src/controllers/__tests__/owner.controller.test.ts @@ -16,8 +16,8 @@ import type { OwnerRequest } from '@/requests'; import type { UserService } from '@/services/user.service'; import { PasswordUtility } from '@/services/password.utility'; -import { mockInstance } from '../../shared/mocking'; -import { badPasswords } from '../shared/testData'; +import { mockInstance } from '@test/mocking'; +import { badPasswords } from '@test/testData'; describe('OwnerController', () => { const configGetSpy = jest.spyOn(config, 'getEnv'); diff --git a/packages/cli/test/unit/controllers/translation.controller.test.ts b/packages/cli/src/controllers/__tests__/translation.controller.test.ts similarity index 100% rename from packages/cli/test/unit/controllers/translation.controller.test.ts rename to packages/cli/src/controllers/__tests__/translation.controller.test.ts diff --git a/packages/cli/test/unit/controllers/userSettings.controller.test.ts b/packages/cli/src/controllers/__tests__/userSettings.controller.test.ts similarity index 96% rename from packages/cli/test/unit/controllers/userSettings.controller.test.ts rename to packages/cli/src/controllers/__tests__/userSettings.controller.test.ts index e29afb74ccc29b..3794008641fa5c 100644 --- a/packages/cli/test/unit/controllers/userSettings.controller.test.ts +++ b/packages/cli/src/controllers/__tests__/userSettings.controller.test.ts @@ -60,7 +60,7 @@ describe('UserSettingsController', () => { [], ], [ - 'updates user settings, reseting to waiting state', + 'updates user settings, resetting to waiting state', { waitingForResponse: true, ignoredCount: 0, @@ -137,7 +137,7 @@ describe('UserSettingsController', () => { 'is waitingForResponse but missing ignoredCount', { lastShownAt: 123, waitingForResponse: true }, ], - ])('thows error when request payload is %s', async (_, payload) => { + ])('throws error when request payload is %s', async (_, payload) => { const req = mock(); req.user.id = '1'; req.body = payload; diff --git a/packages/cli/test/unit/controllers/oauth/oAuth1Credential.controller.test.ts b/packages/cli/src/controllers/oauth/__tests__/oAuth1Credential.controller.test.ts similarity index 99% rename from packages/cli/test/unit/controllers/oauth/oAuth1Credential.controller.test.ts rename to packages/cli/src/controllers/oauth/__tests__/oAuth1Credential.controller.test.ts index cbadc1cf877164..fae443b4ce9a21 100644 --- a/packages/cli/test/unit/controllers/oauth/oAuth1Credential.controller.test.ts +++ b/packages/cli/src/controllers/oauth/__tests__/oAuth1Credential.controller.test.ts @@ -19,7 +19,7 @@ import { CredentialsHelper } from '@/CredentialsHelper'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; -import { mockInstance } from '../../../shared/mocking'; +import { mockInstance } from '@test/mocking'; describe('OAuth1CredentialController', () => { mockInstance(Logger); diff --git a/packages/cli/test/unit/controllers/oauth/oAuth2Credential.controller.test.ts b/packages/cli/src/controllers/oauth/__tests__/oAuth2Credential.controller.test.ts similarity index 99% rename from packages/cli/test/unit/controllers/oauth/oAuth2Credential.controller.test.ts rename to packages/cli/src/controllers/oauth/__tests__/oAuth2Credential.controller.test.ts index f2b718fda00902..f354a1ec024e71 100644 --- a/packages/cli/test/unit/controllers/oauth/oAuth2Credential.controller.test.ts +++ b/packages/cli/src/controllers/oauth/__tests__/oAuth2Credential.controller.test.ts @@ -19,7 +19,7 @@ import { CredentialsHelper } from '@/CredentialsHelper'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; -import { mockInstance } from '../../../shared/mocking'; +import { mockInstance } from '@test/mocking'; describe('OAuth2CredentialController', () => { mockInstance(Logger); diff --git a/packages/cli/src/credentials/__tests__/credentials.service.test.ts b/packages/cli/src/credentials/__tests__/credentials.service.test.ts index 18216df8674ce1..a5fa3ca183cb7c 100644 --- a/packages/cli/src/credentials/__tests__/credentials.service.test.ts +++ b/packages/cli/src/credentials/__tests__/credentials.service.test.ts @@ -3,7 +3,7 @@ import { mock } from 'jest-mock-extended'; import { CREDENTIAL_BLANKING_VALUE } from '@/constants'; import type { CredentialsEntity } from '@db/entities/CredentialsEntity'; import type { CredentialTypes } from '@/CredentialTypes'; -import { CredentialsService } from '../credentials.service'; +import { CredentialsService } from '@/credentials/credentials.service'; describe('CredentialsService', () => { const credType = mock({ diff --git a/packages/cli/test/unit/databases/entities/user.entity.test.ts b/packages/cli/src/databases/entities/__tests__/user.entity.test.ts similarity index 100% rename from packages/cli/test/unit/databases/entities/user.entity.test.ts rename to packages/cli/src/databases/entities/__tests__/user.entity.test.ts diff --git a/packages/cli/test/unit/repositories/execution.repository.test.ts b/packages/cli/src/databases/repositories/__tests__/execution.repository.test.ts similarity index 95% rename from packages/cli/test/unit/repositories/execution.repository.test.ts rename to packages/cli/src/databases/repositories/__tests__/execution.repository.test.ts index f8aba2e8a1228a..1a4929f5cdf6e6 100644 --- a/packages/cli/test/unit/repositories/execution.repository.test.ts +++ b/packages/cli/src/databases/repositories/__tests__/execution.repository.test.ts @@ -8,8 +8,7 @@ import { mock } from 'jest-mock-extended'; import { ExecutionEntity } from '@db/entities/ExecutionEntity'; import { ExecutionRepository } from '@db/repositories/execution.repository'; -import { mockEntityManager } from '../../shared/mocking'; -import { mockInstance } from '../../shared/mocking'; +import { mockInstance, mockEntityManager } from '@test/mocking'; describe('ExecutionRepository', () => { const entityManager = mockEntityManager(ExecutionEntity); diff --git a/packages/cli/test/unit/repositories/sharedCredentials.repository.test.ts b/packages/cli/src/databases/repositories/__tests__/sharedCredentials.repository.test.ts similarity index 98% rename from packages/cli/test/unit/repositories/sharedCredentials.repository.test.ts rename to packages/cli/src/databases/repositories/__tests__/sharedCredentials.repository.test.ts index 8eb8b498145efe..6fb4bad4eacf31 100644 --- a/packages/cli/test/unit/repositories/sharedCredentials.repository.test.ts +++ b/packages/cli/src/databases/repositories/__tests__/sharedCredentials.repository.test.ts @@ -8,7 +8,7 @@ import type { CredentialsEntity } from '@db/entities/CredentialsEntity'; import { SharedCredentials } from '@db/entities/SharedCredentials'; import { SharedCredentialsRepository } from '@db/repositories/sharedCredentials.repository'; import { GLOBAL_MEMBER_SCOPES, GLOBAL_OWNER_SCOPES } from '@/permissions/global-roles'; -import { mockEntityManager } from '../../shared/mocking'; +import { mockEntityManager } from '@test/mocking'; describe('SharedCredentialsRepository', () => { const entityManager = mockEntityManager(SharedCredentials); diff --git a/packages/cli/test/unit/repositories/workflowStatistics.test.ts b/packages/cli/src/databases/repositories/__tests__/workflowStatistics.test.ts similarity index 96% rename from packages/cli/test/unit/repositories/workflowStatistics.test.ts rename to packages/cli/src/databases/repositories/__tests__/workflowStatistics.test.ts index 86e0ee1c92bd18..7bed056549751d 100644 --- a/packages/cli/test/unit/repositories/workflowStatistics.test.ts +++ b/packages/cli/src/databases/repositories/__tests__/workflowStatistics.test.ts @@ -5,7 +5,7 @@ import { mock, mockClear } from 'jest-mock-extended'; import { StatisticsNames, WorkflowStatistics } from '@db/entities/WorkflowStatistics'; import { WorkflowStatisticsRepository } from '@db/repositories/workflowStatistics.repository'; -import { mockEntityManager } from '../../shared/mocking'; +import { mockEntityManager } from '@test/mocking'; describe('insertWorkflowStatistics', () => { const entityManager = mockEntityManager(WorkflowStatistics); diff --git a/packages/cli/test/unit/databases/utils/customValidators.test.ts b/packages/cli/src/databases/utils/__tests__/customValidators.test.ts similarity index 100% rename from packages/cli/test/unit/databases/utils/customValidators.test.ts rename to packages/cli/src/databases/utils/__tests__/customValidators.test.ts diff --git a/packages/cli/test/unit/databases/utils/migrationHelpers.test.ts b/packages/cli/src/databases/utils/__tests__/migrationHelpers.test.ts similarity index 100% rename from packages/cli/test/unit/databases/utils/migrationHelpers.test.ts rename to packages/cli/src/databases/utils/__tests__/migrationHelpers.test.ts diff --git a/packages/cli/test/unit/decorators/OnShutdown.test.ts b/packages/cli/src/decorators/__tests__/OnShutdown.test.ts similarity index 100% rename from packages/cli/test/unit/decorators/OnShutdown.test.ts rename to packages/cli/src/decorators/__tests__/OnShutdown.test.ts diff --git a/packages/cli/test/unit/decorators/controller.registry.test.ts b/packages/cli/src/decorators/__tests__/controller.registry.test.ts similarity index 100% rename from packages/cli/test/unit/decorators/controller.registry.test.ts rename to packages/cli/src/decorators/__tests__/controller.registry.test.ts diff --git a/packages/cli/test/unit/GitService.test.ts b/packages/cli/src/environments/sourceControl/__tests__/sourceControlGit.service.test.ts similarity index 100% rename from packages/cli/test/unit/GitService.test.ts rename to packages/cli/src/environments/sourceControl/__tests__/sourceControlGit.service.test.ts diff --git a/packages/cli/test/unit/SourceControl.test.ts b/packages/cli/src/environments/sourceControl/__tests__/sourceControlHelper.ee.test.ts similarity index 99% rename from packages/cli/test/unit/SourceControl.test.ts rename to packages/cli/src/environments/sourceControl/__tests__/sourceControlHelper.ee.test.ts index 5eeccbb1b97f44..5141d36f2f7ddf 100644 --- a/packages/cli/test/unit/SourceControl.test.ts +++ b/packages/cli/src/environments/sourceControl/__tests__/sourceControlHelper.ee.test.ts @@ -18,7 +18,7 @@ import { import { constants as fsConstants, accessSync } from 'fs'; import type { SourceControlledFile } from '@/environments/sourceControl/types/sourceControlledFile'; import type { SourceControlPreferences } from '@/environments/sourceControl/types/sourceControlPreferences'; -import { mockInstance } from '../shared/mocking'; +import { mockInstance } from '@test/mocking'; const pushResult: SourceControlledFile[] = [ { diff --git a/packages/cli/test/unit/utils.test.ts b/packages/cli/src/errors/response-errors/__tests__/webhook-not-found.error.test.ts similarity index 100% rename from packages/cli/test/unit/utils.test.ts rename to packages/cli/src/errors/response-errors/__tests__/webhook-not-found.error.test.ts diff --git a/packages/cli/test/unit/execution-lifecyle/restoreBinaryDataId.test.ts b/packages/cli/src/executionLifecycleHooks/__tests__/restoreBinaryDataId.test.ts similarity index 97% rename from packages/cli/test/unit/execution-lifecyle/restoreBinaryDataId.test.ts rename to packages/cli/src/executionLifecycleHooks/__tests__/restoreBinaryDataId.test.ts index 3fcdb79c72c7ec..ea962882bd7825 100644 --- a/packages/cli/test/unit/execution-lifecyle/restoreBinaryDataId.test.ts +++ b/packages/cli/src/executionLifecycleHooks/__tests__/restoreBinaryDataId.test.ts @@ -1,6 +1,6 @@ import { restoreBinaryDataId } from '@/executionLifecycleHooks/restoreBinaryDataId'; import { BinaryDataService } from 'n8n-core'; -import { mockInstance } from '../../shared/mocking'; +import { mockInstance } from '@test/mocking'; import type { IRun } from 'n8n-workflow'; import config from '@/config'; @@ -24,7 +24,7 @@ function toIRun(item?: object) { } function getDataId(run: IRun, kind: 'binary' | 'json') { - // @ts-ignore + // @ts-expect-error The type doesn't have the correct structure return run.data.resultData.runData.myNode[0].data.main[0][0][kind].data.id; } diff --git a/packages/cli/test/unit/execution-lifecyle/saveExecutionProgress.test.ts b/packages/cli/src/executionLifecycleHooks/__tests__/saveExecutionProgress.test.ts similarity index 98% rename from packages/cli/test/unit/execution-lifecyle/saveExecutionProgress.test.ts rename to packages/cli/src/executionLifecycleHooks/__tests__/saveExecutionProgress.test.ts index 4235e56ecbad38..9b1faa7f60540d 100644 --- a/packages/cli/test/unit/execution-lifecyle/saveExecutionProgress.test.ts +++ b/packages/cli/src/executionLifecycleHooks/__tests__/saveExecutionProgress.test.ts @@ -1,5 +1,5 @@ import { ExecutionRepository } from '@/databases/repositories/execution.repository'; -import { mockInstance } from '../../shared/mocking'; +import { mockInstance } from '@test/mocking'; import { Logger } from '@/Logger'; import { saveExecutionProgress } from '@/executionLifecycleHooks/saveExecutionProgress'; import * as fnModule from '@/executionLifecycleHooks/toSaveSettings'; diff --git a/packages/cli/test/unit/execution-lifecyle/toSaveSettings.test.ts b/packages/cli/src/executionLifecycleHooks/__tests__/toSaveSettings.test.ts similarity index 98% rename from packages/cli/test/unit/execution-lifecyle/toSaveSettings.test.ts rename to packages/cli/src/executionLifecycleHooks/__tests__/toSaveSettings.test.ts index 6fc516a0ea2144..57379e0e73055d 100644 --- a/packages/cli/test/unit/execution-lifecyle/toSaveSettings.test.ts +++ b/packages/cli/src/executionLifecycleHooks/__tests__/toSaveSettings.test.ts @@ -35,7 +35,7 @@ describe('failed production executions', () => { }); }); -describe('sucessful production executions', () => { +describe('successful production executions', () => { it('should favor workflow settings over defaults', () => { config.set('executions.saveDataOnSuccess', 'none'); diff --git a/packages/cli/test/unit/controllers/executions.controller.test.ts b/packages/cli/src/executions/__tests__/executions.controller.test.ts similarity index 100% rename from packages/cli/test/unit/controllers/executions.controller.test.ts rename to packages/cli/src/executions/__tests__/executions.controller.test.ts diff --git a/packages/cli/test/unit/middleware/executions/parse-range-query.middleware.test.ts b/packages/cli/src/executions/__tests__/parse-range-query.middleware.test.ts similarity index 100% rename from packages/cli/test/unit/middleware/executions/parse-range-query.middleware.test.ts rename to packages/cli/src/executions/__tests__/parse-range-query.middleware.test.ts diff --git a/packages/cli/test/unit/license/license.service.test.ts b/packages/cli/src/license/__tests__/license.service.test.ts similarity index 100% rename from packages/cli/test/unit/license/license.service.test.ts rename to packages/cli/src/license/__tests__/license.service.test.ts diff --git a/packages/cli/test/unit/middleware/listQuery.test.ts b/packages/cli/src/middlewares/listQuery/__tests__/listQuery.test.ts similarity index 100% rename from packages/cli/test/unit/middleware/listQuery.test.ts rename to packages/cli/src/middlewares/listQuery/__tests__/listQuery.test.ts diff --git a/packages/cli/test/unit/PostHog.test.ts b/packages/cli/src/posthog/__tests__/PostHog.test.ts similarity index 97% rename from packages/cli/test/unit/PostHog.test.ts rename to packages/cli/src/posthog/__tests__/PostHog.test.ts index 5798c0cce2217a..f1604f7253df1f 100644 --- a/packages/cli/test/unit/PostHog.test.ts +++ b/packages/cli/src/posthog/__tests__/PostHog.test.ts @@ -2,7 +2,7 @@ import { PostHog } from 'posthog-node'; import { InstanceSettings } from 'n8n-core'; import { PostHogClient } from '@/posthog'; import config from '@/config'; -import { mockInstance } from '../shared/mocking'; +import { mockInstance } from '@test/mocking'; jest.mock('posthog-node'); diff --git a/packages/cli/test/unit/push/index.test.ts b/packages/cli/src/push/__tests__/index.test.ts similarity index 96% rename from packages/cli/test/unit/push/index.test.ts rename to packages/cli/src/push/__tests__/index.test.ts index 17366935093748..a61496b0c9248d 100644 --- a/packages/cli/test/unit/push/index.test.ts +++ b/packages/cli/src/push/__tests__/index.test.ts @@ -9,7 +9,7 @@ import { WebSocketPush } from '@/push/websocket.push'; import type { WebSocketPushRequest, SSEPushRequest } from '@/push/types'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; -import { mockInstance } from '../../shared/mocking'; +import { mockInstance } from '@test/mocking'; jest.unmock('@/push'); diff --git a/packages/cli/test/unit/push/websocket.push.test.ts b/packages/cli/src/push/__tests__/websocket.push.test.ts similarity index 98% rename from packages/cli/test/unit/push/websocket.push.test.ts rename to packages/cli/src/push/__tests__/websocket.push.test.ts index 7531e43776c2cd..f1a0e577f9ad8f 100644 --- a/packages/cli/test/unit/push/websocket.push.test.ts +++ b/packages/cli/src/push/__tests__/websocket.push.test.ts @@ -6,7 +6,7 @@ import { WebSocketPush } from '@/push/websocket.push'; import { Logger } from '@/Logger'; import type { PushDataExecutionRecovered } from '@/Interfaces'; -import { mockInstance } from '../../shared/mocking'; +import { mockInstance } from '@test/mocking'; jest.useFakeTimers(); diff --git a/packages/cli/test/unit/ExecutionMetadataService.test.ts b/packages/cli/src/services/__tests__/ExecutionMetadataService.test.ts similarity index 94% rename from packages/cli/test/unit/ExecutionMetadataService.test.ts rename to packages/cli/src/services/__tests__/ExecutionMetadataService.test.ts index 826aae5e253247..8b77b8b1681d47 100644 --- a/packages/cli/test/unit/ExecutionMetadataService.test.ts +++ b/packages/cli/src/services/__tests__/ExecutionMetadataService.test.ts @@ -1,7 +1,7 @@ import { Container } from 'typedi'; import { ExecutionMetadataRepository } from '@db/repositories/executionMetadata.repository'; import { ExecutionMetadataService } from '@/services/executionMetadata.service'; -import { mockInstance } from '../shared/mocking'; +import { mockInstance } from '@test/mocking'; describe('ExecutionMetadataService', () => { const repository = mockInstance(ExecutionMetadataRepository); diff --git a/packages/cli/test/unit/services/activeWorkflows.service.test.ts b/packages/cli/src/services/__tests__/activeWorkflows.service.test.ts similarity index 100% rename from packages/cli/test/unit/services/activeWorkflows.service.test.ts rename to packages/cli/src/services/__tests__/activeWorkflows.service.test.ts diff --git a/packages/cli/test/unit/services/communityPackages.service.test.ts b/packages/cli/src/services/__tests__/communityPackages.service.test.ts similarity index 97% rename from packages/cli/test/unit/services/communityPackages.service.test.ts rename to packages/cli/src/services/__tests__/communityPackages.service.test.ts index 2b0d8bf0d452a4..acfecc8171ba0a 100644 --- a/packages/cli/test/unit/services/communityPackages.service.test.ts +++ b/packages/cli/src/services/__tests__/communityPackages.service.test.ts @@ -20,13 +20,10 @@ import { InstalledPackagesRepository } from '@db/repositories/installedPackages. import { InstalledNodes } from '@db/entities/InstalledNodes'; import { LoadNodesAndCredentials } from '@/LoadNodesAndCredentials'; -import { mockInstance } from '../../shared/mocking'; -import { - COMMUNITY_NODE_VERSION, - COMMUNITY_PACKAGE_VERSION, -} from '../../integration/shared/constants'; -import { randomName } from '../../integration/shared/random'; -import { mockPackageName, mockPackagePair } from '../../integration/shared/utils'; +import { mockInstance } from '@test/mocking'; +import { COMMUNITY_NODE_VERSION, COMMUNITY_PACKAGE_VERSION } from '@test-integration/constants'; +import { randomName } from '@test-integration/random'; +import { mockPackageName, mockPackagePair } from '@test-integration/utils'; import { InstanceSettings, PackageDirectoryLoader } from 'n8n-core'; import { Logger } from '@/Logger'; diff --git a/packages/cli/test/unit/credentials-tester.unit.test.ts b/packages/cli/src/services/__tests__/credentials-tester.service.test.ts similarity index 100% rename from packages/cli/test/unit/credentials-tester.unit.test.ts rename to packages/cli/src/services/__tests__/credentials-tester.service.test.ts diff --git a/packages/cli/test/unit/services/curl.service.test.ts b/packages/cli/src/services/__tests__/curl.service.test.ts similarity index 100% rename from packages/cli/test/unit/services/curl.service.test.ts rename to packages/cli/src/services/__tests__/curl.service.test.ts diff --git a/packages/cli/test/unit/services/hooks.service.test.ts b/packages/cli/src/services/__tests__/hooks.service.test.ts similarity index 100% rename from packages/cli/test/unit/services/hooks.service.test.ts rename to packages/cli/src/services/__tests__/hooks.service.test.ts diff --git a/packages/cli/test/unit/services/jwt.service.test.ts b/packages/cli/src/services/__tests__/jwt.service.test.ts similarity index 100% rename from packages/cli/test/unit/services/jwt.service.test.ts rename to packages/cli/src/services/__tests__/jwt.service.test.ts diff --git a/packages/cli/test/unit/services/naming.service.test.ts b/packages/cli/src/services/__tests__/naming.service.test.ts similarity index 98% rename from packages/cli/test/unit/services/naming.service.test.ts rename to packages/cli/src/services/__tests__/naming.service.test.ts index ea2c34fb8c1ee6..1ca216734630ee 100644 --- a/packages/cli/test/unit/services/naming.service.test.ts +++ b/packages/cli/src/services/__tests__/naming.service.test.ts @@ -1,6 +1,6 @@ import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; -import { mockInstance } from '../../shared/mocking'; +import { mockInstance } from '@test/mocking'; import { NamingService } from '@/services/naming.service'; import type { WorkflowEntity } from '@/databases/entities/WorkflowEntity'; import type { CredentialsEntity } from '@/databases/entities/CredentialsEntity'; diff --git a/packages/cli/test/unit/services/orchestration.service.test.ts b/packages/cli/src/services/__tests__/orchestration.service.test.ts similarity index 99% rename from packages/cli/test/unit/services/orchestration.service.test.ts rename to packages/cli/src/services/__tests__/orchestration.service.test.ts index 0b63f74344b579..c69e674613e256 100644 --- a/packages/cli/test/unit/services/orchestration.service.test.ts +++ b/packages/cli/src/services/__tests__/orchestration.service.test.ts @@ -17,7 +17,7 @@ import { ExternalSecretsManager } from '@/ExternalSecrets/ExternalSecretsManager import { Logger } from '@/Logger'; import { Push } from '@/push'; import { ActiveWorkflowManager } from '@/ActiveWorkflowManager'; -import { mockInstance } from '../../shared/mocking'; +import { mockInstance } from '@test/mocking'; import { RedisClientService } from '@/services/redis/redis-client.service'; const instanceSettings = Container.get(InstanceSettings); diff --git a/packages/cli/test/unit/services/ownership.service.test.ts b/packages/cli/src/services/__tests__/ownership.service.test.ts similarity index 98% rename from packages/cli/test/unit/services/ownership.service.test.ts rename to packages/cli/src/services/__tests__/ownership.service.test.ts index d1a722da196257..8a3d40eb60f8d3 100644 --- a/packages/cli/test/unit/services/ownership.service.test.ts +++ b/packages/cli/src/services/__tests__/ownership.service.test.ts @@ -3,14 +3,14 @@ import { SharedWorkflowRepository } from '@db/repositories/sharedWorkflow.reposi import { SharedWorkflow } from '@db/entities/SharedWorkflow'; import { User } from '@db/entities/User'; import type { SharedCredentials } from '@db/entities/SharedCredentials'; -import { mockInstance } from '../../shared/mocking'; +import { mockInstance } from '@test/mocking'; import { WorkflowEntity } from '@/databases/entities/WorkflowEntity'; import { UserRepository } from '@/databases/repositories/user.repository'; import { mock } from 'jest-mock-extended'; import { Project } from '@/databases/entities/Project'; import { ProjectRelationRepository } from '@/databases/repositories/projectRelation.repository'; import { ProjectRelation } from '@/databases/entities/ProjectRelation'; -import { mockCredential, mockProject } from '../shared/mockObjects'; +import { mockCredential, mockProject } from '@test/mockObjects'; describe('OwnershipService', () => { const userRepository = mockInstance(UserRepository); diff --git a/packages/cli/test/unit/utilities/password.utility.test.ts b/packages/cli/src/services/__tests__/password.utility.test.ts similarity index 100% rename from packages/cli/test/unit/utilities/password.utility.test.ts rename to packages/cli/src/services/__tests__/password.utility.test.ts diff --git a/packages/cli/test/unit/services/redis.service.test.ts b/packages/cli/src/services/__tests__/redis.service.test.ts similarity index 94% rename from packages/cli/test/unit/services/redis.service.test.ts rename to packages/cli/src/services/__tests__/redis.service.test.ts index cb963ad5355676..1d9652983735c6 100644 --- a/packages/cli/test/unit/services/redis.service.test.ts +++ b/packages/cli/src/services/__tests__/redis.service.test.ts @@ -2,7 +2,7 @@ import Container from 'typedi'; import { Logger } from '@/Logger'; import config from '@/config'; import { RedisService } from '@/services/redis.service'; -import { mockInstance } from '../../shared/mocking'; +import { mockInstance } from '@test/mocking'; jest.mock('ioredis', () => { const Redis = require('ioredis-mock'); @@ -14,7 +14,7 @@ jest.mock('ioredis', () => { }; } // second mock for our code - return function (...args: any) { + return function (...args: unknown[]) { return new Redis(args); }; }); diff --git a/packages/cli/test/unit/services/test-webhook-registrations.service.test.ts b/packages/cli/src/services/__tests__/test-webhook-registrations.service.test.ts similarity index 100% rename from packages/cli/test/unit/services/test-webhook-registrations.service.test.ts rename to packages/cli/src/services/__tests__/test-webhook-registrations.service.test.ts diff --git a/packages/cli/test/unit/services/user.service.test.ts b/packages/cli/src/services/__tests__/user.service.test.ts similarity index 98% rename from packages/cli/test/unit/services/user.service.test.ts rename to packages/cli/src/services/__tests__/user.service.test.ts index 89929f57b0b895..5aeb919220c231 100644 --- a/packages/cli/test/unit/services/user.service.test.ts +++ b/packages/cli/src/services/__tests__/user.service.test.ts @@ -4,7 +4,7 @@ import { v4 as uuid } from 'uuid'; import { User } from '@db/entities/User'; import { UserService } from '@/services/user.service'; import { UrlService } from '@/services/url.service'; -import { mockInstance } from '../../shared/mocking'; +import { mockInstance } from '@test/mocking'; import { UserRepository } from '@/databases/repositories/user.repository'; import { GlobalConfig } from '@n8n/config'; diff --git a/packages/cli/test/unit/services/webhook.service.test.ts b/packages/cli/src/services/__tests__/webhook.service.test.ts similarity index 99% rename from packages/cli/test/unit/services/webhook.service.test.ts rename to packages/cli/src/services/__tests__/webhook.service.test.ts index adb18de4b309bb..181bc607529565 100644 --- a/packages/cli/test/unit/services/webhook.service.test.ts +++ b/packages/cli/src/services/__tests__/webhook.service.test.ts @@ -4,7 +4,7 @@ import { WebhookRepository } from '@db/repositories/webhook.repository'; import { CacheService } from '@/services/cache/cache.service'; import { WebhookService } from '@/services/webhook.service'; import { WebhookEntity } from '@db/entities/WebhookEntity'; -import { mockInstance } from '../../shared/mocking'; +import { mockInstance } from '@test/mocking'; const createWebhook = (method: string, path: string, webhookId?: string, pathSegments?: number) => Object.assign(new WebhookEntity(), { diff --git a/packages/cli/test/unit/services/workflow-statistics.service.test.ts b/packages/cli/src/services/__tests__/workflow-statistics.service.test.ts similarity index 99% rename from packages/cli/test/unit/services/workflow-statistics.service.test.ts rename to packages/cli/src/services/__tests__/workflow-statistics.service.test.ts index 6d9baf49ea939b..24c3bce560d32f 100644 --- a/packages/cli/test/unit/services/workflow-statistics.service.test.ts +++ b/packages/cli/src/services/__tests__/workflow-statistics.service.test.ts @@ -17,7 +17,7 @@ import { WorkflowStatisticsRepository } from '@db/repositories/workflowStatistic import { WorkflowStatisticsService } from '@/services/workflow-statistics.service'; import { UserService } from '@/services/user.service'; import { OwnershipService } from '@/services/ownership.service'; -import { mockInstance } from '../../shared/mocking'; +import { mockInstance } from '@test/mocking'; import type { Project } from '@/databases/entities/Project'; describe('WorkflowStatisticsService', () => { diff --git a/packages/cli/test/unit/services/cache-mock.service.test.ts b/packages/cli/src/services/cache/__tests__/cache-mock.service.test.ts similarity index 100% rename from packages/cli/test/unit/services/cache-mock.service.test.ts rename to packages/cli/src/services/cache/__tests__/cache-mock.service.test.ts diff --git a/packages/cli/test/unit/services/cache.service.test.ts b/packages/cli/src/services/cache/__tests__/cache.service.test.ts similarity index 100% rename from packages/cli/test/unit/services/cache.service.test.ts rename to packages/cli/src/services/cache/__tests__/cache.service.test.ts diff --git a/packages/cli/test/unit/shutdown/Shutdown.service.test.ts b/packages/cli/src/shutdown/__tests__/Shutdown.service.test.ts similarity index 100% rename from packages/cli/test/unit/shutdown/Shutdown.service.test.ts rename to packages/cli/src/shutdown/__tests__/Shutdown.service.test.ts diff --git a/packages/cli/test/unit/sso/saml/saml.service.ee.test.ts b/packages/cli/src/sso/saml/__tests__/saml.service.ee.test.ts similarity index 97% rename from packages/cli/test/unit/sso/saml/saml.service.ee.test.ts rename to packages/cli/src/sso/saml/__tests__/saml.service.ee.test.ts index 9ba6ddaf2a6bd6..89d693fc98037b 100644 --- a/packages/cli/test/unit/sso/saml/saml.service.ee.test.ts +++ b/packages/cli/src/sso/saml/__tests__/saml.service.ee.test.ts @@ -1,7 +1,7 @@ import { mock } from 'jest-mock-extended'; import type express from 'express'; import { SamlService } from '@/sso/saml/saml.service.ee'; -import { mockInstance } from '../../../shared/mocking'; +import { mockInstance } from '@test/mocking'; import { UrlService } from '@/services/url.service'; import { Logger } from '@/Logger'; import type { IdentityProviderInstance, ServiceProviderInstance } from 'samlify'; diff --git a/packages/cli/test/unit/sso/saml/samlHelpers.test.ts b/packages/cli/src/sso/saml/__tests__/samlHelpers.test.ts similarity index 96% rename from packages/cli/test/unit/sso/saml/samlHelpers.test.ts rename to packages/cli/src/sso/saml/__tests__/samlHelpers.test.ts index f6c35ff67e514d..778b1a08571568 100644 --- a/packages/cli/test/unit/sso/saml/samlHelpers.test.ts +++ b/packages/cli/src/sso/saml/__tests__/samlHelpers.test.ts @@ -2,7 +2,7 @@ import { User } from '@/databases/entities/User'; import { generateNanoId } from '@/databases/utils/generators'; import * as helpers from '@/sso/saml/samlHelpers'; import type { SamlUserAttributes } from '@/sso/saml/types/samlUserAttributes'; -import { mockInstance } from '../../../shared/mocking'; +import { mockInstance } from '@test/mocking'; import { UserRepository } from '@/databases/repositories/user.repository'; import type { AuthIdentity } from '@/databases/entities/AuthIdentity'; import { AuthIdentityRepository } from '@/databases/repositories/authIdentity.repository'; diff --git a/packages/cli/test/unit/Telemetry.test.ts b/packages/cli/src/telemetry/__tests__/telemetry.test.ts similarity index 99% rename from packages/cli/test/unit/Telemetry.test.ts rename to packages/cli/src/telemetry/__tests__/telemetry.test.ts index af8445c814663a..a0441519eaf6fc 100644 --- a/packages/cli/test/unit/Telemetry.test.ts +++ b/packages/cli/src/telemetry/__tests__/telemetry.test.ts @@ -1,11 +1,11 @@ import type RudderStack from '@rudderstack/rudder-sdk-node'; import { Telemetry } from '@/telemetry'; import config from '@/config'; -import { flushPromises } from './Helpers'; +import { flushPromises } from '@test/flushPromises'; import { PostHogClient } from '@/posthog'; import { mock } from 'jest-mock-extended'; import { InstanceSettings } from 'n8n-core'; -import { mockInstance } from '../shared/mocking'; +import { mockInstance } from '@test/mocking'; jest.unmock('@/telemetry'); jest.mock('@/posthog'); diff --git a/packages/cli/test/unit/workflow-execution.service.test.ts b/packages/cli/src/workflows/__tests__/workflow-execution.service.test.ts similarity index 100% rename from packages/cli/test/unit/workflow-execution.service.test.ts rename to packages/cli/src/workflows/__tests__/workflow-execution.service.test.ts diff --git a/packages/cli/test/unit/services/workflowHistory.service.ee.test.ts b/packages/cli/src/workflows/workflowHistory/__tests__/workflowHistory.service.ee.test.ts similarity index 96% rename from packages/cli/test/unit/services/workflowHistory.service.ee.test.ts rename to packages/cli/src/workflows/workflowHistory/__tests__/workflowHistory.service.ee.test.ts index 05ccae70051a21..5b28b8d1714689 100644 --- a/packages/cli/test/unit/services/workflowHistory.service.ee.test.ts +++ b/packages/cli/src/workflows/workflowHistory/__tests__/workflowHistory.service.ee.test.ts @@ -4,8 +4,8 @@ import { WorkflowHistoryRepository } from '@db/repositories/workflowHistory.repo import { SharedWorkflowRepository } from '@db/repositories/sharedWorkflow.repository'; import { WorkflowHistoryService } from '@/workflows/workflowHistory/workflowHistory.service.ee'; import { Logger } from '@/Logger'; -import { mockInstance } from '../../shared/mocking'; -import { getWorkflow } from '../../integration/shared/workflow'; +import { mockInstance } from '@test/mocking'; +import { getWorkflow } from '@test-integration/workflow'; const workflowHistoryRepository = mockInstance(WorkflowHistoryRepository); const logger = mockInstance(Logger); diff --git a/packages/cli/test/unit/workflowHistoryHelper.test.ts b/packages/cli/src/workflows/workflowHistory/__tests__/workflowHistoryHelper.ee.test.ts similarity index 96% rename from packages/cli/test/unit/workflowHistoryHelper.test.ts rename to packages/cli/src/workflows/workflowHistory/__tests__/workflowHistoryHelper.ee.test.ts index 32a6cdd6f0d520..427f98188495b3 100644 --- a/packages/cli/test/unit/workflowHistoryHelper.test.ts +++ b/packages/cli/src/workflows/workflowHistory/__tests__/workflowHistoryHelper.ee.test.ts @@ -1,7 +1,7 @@ import { License } from '@/License'; import config from '@/config'; import { getWorkflowHistoryPruneTime } from '@/workflows/workflowHistory/workflowHistoryHelper.ee'; -import { mockInstance } from '../shared/mocking'; +import { mockInstance } from '@test/mocking'; let licensePruneTime = -1; diff --git a/packages/cli/test/integration/PermissionChecker.test.ts b/packages/cli/test/integration/PermissionChecker.test.ts index d5262a50d06728..ff10d0497439ad 100644 --- a/packages/cli/test/integration/PermissionChecker.test.ts +++ b/packages/cli/test/integration/PermissionChecker.test.ts @@ -1,6 +1,6 @@ import { v4 as uuid } from 'uuid'; import { Container } from 'typedi'; -import type { INode } from 'n8n-workflow'; +import type { INode, INodeTypeData } from 'n8n-workflow'; import { randomInt } from 'n8n-workflow'; import type { User } from '@db/entities/User'; import { WorkflowRepository } from '@db/repositories/workflow.repository'; @@ -14,7 +14,6 @@ import { mockInstance } from '../shared/mocking'; import { randomCredentialPayload as randomCred } from '../integration/shared/random'; import * as testDb from '../integration/shared/testDb'; import type { SaveCredentialFunction } from '../integration/shared/types'; -import { mockNodeTypesData } from '../unit/Helpers'; import { affixRoleToSaveCredential } from '../integration/shared/db/credentials'; import { createOwner, createUser } from '../integration/shared/db/users'; import { SharedCredentialsRepository } from '@/databases/repositories/sharedCredentials.repository'; @@ -25,6 +24,36 @@ import { ProjectRepository } from '@/databases/repositories/project.repository'; const ownershipService = mockInstance(OwnershipService); +function mockNodeTypesData( + nodeNames: string[], + options?: { + addTrigger?: boolean; + }, +) { + return nodeNames.reduce((acc, nodeName) => { + return ( + (acc[`n8n-nodes-base.${nodeName}`] = { + sourcePath: '', + type: { + description: { + displayName: nodeName, + name: nodeName, + group: [], + description: '', + version: 1, + defaults: {}, + inputs: [], + outputs: [], + properties: [], + }, + trigger: options?.addTrigger ? async () => undefined : undefined, + }, + }), + acc + ); + }, {}); +} + const createWorkflow = async (nodes: INode[], workflowOwner?: User): Promise => { const workflowDetails = { id: randomInt(1, 10).toString(), diff --git a/packages/cli/test/unit/webhooks.test.ts b/packages/cli/test/integration/webhooks.test.ts similarity index 98% rename from packages/cli/test/unit/webhooks.test.ts rename to packages/cli/test/integration/webhooks.test.ts index c891588597ac5b..9bd1977ed53d28 100644 --- a/packages/cli/test/unit/webhooks.test.ts +++ b/packages/cli/test/integration/webhooks.test.ts @@ -11,7 +11,7 @@ import { WaitingWebhooks } from '@/WaitingWebhooks'; import { WaitingForms } from '@/WaitingForms'; import type { IResponseCallbackData } from '@/Interfaces'; -import { mockInstance } from '../shared/mocking'; +import { mockInstance } from '@test/mocking'; import { GlobalConfig } from '@n8n/config'; import Container from 'typedi'; diff --git a/packages/cli/test/shared/flushPromises.ts b/packages/cli/test/shared/flushPromises.ts new file mode 100644 index 00000000000000..405b9e98dca26c --- /dev/null +++ b/packages/cli/test/shared/flushPromises.ts @@ -0,0 +1,6 @@ +/** + * Ensure all pending promises settle. The promise's `resolve` is placed in + * the macrotask queue and so called at the next iteration of the event loop + * after all promises in the microtask queue have settled first. + */ +export const flushPromises = async () => await new Promise(setImmediate); diff --git a/packages/cli/test/unit/shared/mockObjects.ts b/packages/cli/test/shared/mockObjects.ts similarity index 94% rename from packages/cli/test/unit/shared/mockObjects.ts rename to packages/cli/test/shared/mockObjects.ts index e7a165977301f9..a8795e8e1013f6 100644 --- a/packages/cli/test/unit/shared/mockObjects.ts +++ b/packages/cli/test/shared/mockObjects.ts @@ -8,7 +8,7 @@ import { randomEmail, randomName, uniqueId, -} from '../../integration/shared/random'; +} from '../integration/shared/random'; export const mockCredential = (): CredentialsEntity => Object.assign(new CredentialsEntity(), randomCredentialPayload()); diff --git a/packages/cli/test/unit/shared/testData.ts b/packages/cli/test/shared/testData.ts similarity index 100% rename from packages/cli/test/unit/shared/testData.ts rename to packages/cli/test/shared/testData.ts diff --git a/packages/cli/test/unit/Helpers.ts b/packages/cli/test/unit/Helpers.ts deleted file mode 100644 index 50b9f434890765..00000000000000 --- a/packages/cli/test/unit/Helpers.ts +++ /dev/null @@ -1,38 +0,0 @@ -import type { INodeTypeData } from 'n8n-workflow'; - -/** - * Ensure all pending promises settle. The promise's `resolve` is placed in - * the macrotask queue and so called at the next iteration of the event loop - * after all promises in the microtask queue have settled first. - */ -export const flushPromises = async () => await new Promise(setImmediate); - -export function mockNodeTypesData( - nodeNames: string[], - options?: { - addTrigger?: boolean; - }, -) { - return nodeNames.reduce((acc, nodeName) => { - return ( - (acc[`n8n-nodes-base.${nodeName}`] = { - sourcePath: '', - type: { - description: { - displayName: nodeName, - name: nodeName, - group: [], - description: '', - version: 1, - defaults: {}, - inputs: [], - outputs: [], - properties: [], - }, - trigger: options?.addTrigger ? async () => undefined : undefined, - }, - }), - acc - ); - }, {}); -}