Merge pull request #1398 from automatisch/tests/disable-typescript

test: Disable ts check for test files
This commit is contained in:
Ömer Faruk Aydın
2023-10-31 12:08:30 +01:00
committed by GitHub
10 changed files with 83 additions and 86 deletions

View File

@@ -7,4 +7,12 @@ module.exports = {
'plugin:@typescript-eslint/recommended', 'plugin:@typescript-eslint/recommended',
'prettier', 'prettier',
], ],
overrides: [
{
files: ['**/*.test.ts', '**/test/**/*.ts'],
rules: {
'@typescript-eslint/ban-ts-comment': ['off'],
},
},
],
}; };

View File

@@ -1,3 +1,4 @@
// @ts-nocheck
import request from 'supertest'; import request from 'supertest';
import app from '../../app'; import app from '../../app';
import * as license from '../../helpers/license.ee'; import * as license from '../../helpers/license.ee';
@@ -22,7 +23,7 @@ describe('graphQL getAutomatischInfo query', () => {
beforeEach(async () => { beforeEach(async () => {
jest.spyOn(license, 'getLicense').mockResolvedValue(false); jest.spyOn(license, 'getLicense').mockResolvedValue(false);
jest.replaceProperty(appConfig, 'isCloud', false) jest.replaceProperty(appConfig, 'isCloud', false);
}); });
it('should return empty license data', async () => { it('should return empty license data', async () => {
@@ -36,9 +37,9 @@ describe('graphQL getAutomatischInfo query', () => {
getAutomatischInfo: { getAutomatischInfo: {
isCloud: false, isCloud: false,
license: { license: {
id: null as string, id: null,
name: null as string, name: null,
expireAt: null as string, expireAt: null,
verified: false, verified: false,
}, },
}, },
@@ -63,7 +64,7 @@ describe('graphQL getAutomatischInfo query', () => {
describe('and with cloud flag enabled', () => { describe('and with cloud flag enabled', () => {
beforeEach(async () => { beforeEach(async () => {
jest.replaceProperty(appConfig, 'isCloud', true) jest.replaceProperty(appConfig, 'isCloud', true);
}); });
it('should return all license data', async () => { it('should return all license data', async () => {
@@ -92,7 +93,7 @@ describe('graphQL getAutomatischInfo query', () => {
describe('and with cloud flag disabled', () => { describe('and with cloud flag disabled', () => {
beforeEach(async () => { beforeEach(async () => {
jest.replaceProperty(appConfig, 'isCloud', false) jest.replaceProperty(appConfig, 'isCloud', false);
}); });
it('should return all license data', async () => { it('should return all license data', async () => {

View File

@@ -1,9 +1,9 @@
import request, { Test } from 'supertest'; // @ts-nocheck
import request from 'supertest';
import app from '../../app'; import app from '../../app';
import createAuthTokenByUserId from '../../helpers/create-auth-token-by-user-id'; import createAuthTokenByUserId from '../../helpers/create-auth-token-by-user-id';
import { createRole } from '../../../test/factories/role'; import { createRole } from '../../../test/factories/role';
import { createUser } from '../../../test/factories/user'; import { createUser } from '../../../test/factories/user';
import { IRole, IUser } from '@automatisch/types';
describe('graphQL getCurrentUser query', () => { describe('graphQL getCurrentUser query', () => {
describe('with unauthenticated user', () => { describe('with unauthenticated user', () => {
@@ -31,7 +31,7 @@ describe('graphQL getCurrentUser query', () => {
}); });
describe('with authenticated user', () => { describe('with authenticated user', () => {
let role: IRole, currentUser: IUser, token: string, requestObject: Test; let role, currentUser, token, requestObject;
beforeEach(async () => { beforeEach(async () => {
role = await createRole({ role = await createRole({
@@ -70,12 +70,12 @@ describe('graphQL getCurrentUser query', () => {
const expectedResponsePayload = { const expectedResponsePayload = {
data: { data: {
getCurrentUser: { getCurrentUser: {
createdAt: (currentUser.createdAt as Date).getTime().toString(), createdAt: currentUser.createdAt.getTime().toString(),
email: currentUser.email, email: currentUser.email,
fullName: currentUser.fullName, fullName: currentUser.fullName,
id: currentUser.id, id: currentUser.id,
role: { id: role.id, name: role.name }, role: { id: role.id, name: role.name },
updatedAt: (currentUser.updatedAt as Date).getTime().toString(), updatedAt: currentUser.updatedAt.getTime().toString(),
}, },
}, },
}; };

View File

@@ -1,8 +1,8 @@
// @ts-nocheck
import request from 'supertest'; import request from 'supertest';
import app from '../../app'; import app from '../../app';
import appConfig from '../../config/app'; import appConfig from '../../config/app';
import createAuthTokenByUserId from '../../helpers/create-auth-token-by-user-id'; import createAuthTokenByUserId from '../../helpers/create-auth-token-by-user-id';
import { IJSONObject } from '@automatisch/types';
import { createRole } from '../../../test/factories/role'; import { createRole } from '../../../test/factories/role';
import { createPermission } from '../../../test/factories/permission'; import { createPermission } from '../../../test/factories/permission';
import { createUser } from '../../../test/factories/user'; import { createUser } from '../../../test/factories/user';
@@ -10,7 +10,6 @@ import { createFlow } from '../../../test/factories/flow';
import { createStep } from '../../../test/factories/step'; import { createStep } from '../../../test/factories/step';
import { createExecution } from '../../../test/factories/execution'; import { createExecution } from '../../../test/factories/execution';
import { createExecutionStep } from '../../../test/factories/execution-step'; import { createExecutionStep } from '../../../test/factories/execution-step';
import { IRole, IUser, IExecution, IFlow, IStep } from '@automatisch/types';
describe('graphQL getExecutions query', () => { describe('graphQL getExecutions query', () => {
const query = ` const query = `
@@ -74,25 +73,25 @@ describe('graphQL getExecutions query', () => {
}); });
describe('and with correct permission', () => { describe('and with correct permission', () => {
let role: IRole, let role,
currentUser: IUser, currentUser,
anotherUser: IUser, anotherUser,
token: string, token,
flowOne: IFlow, flowOne,
stepOneForFlowOne: IStep, stepOneForFlowOne,
stepTwoForFlowOne: IStep, stepTwoForFlowOne,
executionOne: IExecution, executionOne,
flowTwo: IFlow, flowTwo,
stepOneForFlowTwo: IStep, stepOneForFlowTwo,
stepTwoForFlowTwo: IStep, stepTwoForFlowTwo,
executionTwo: IExecution, executionTwo,
flowThree: IFlow, flowThree,
stepOneForFlowThree: IStep, stepOneForFlowThree,
stepTwoForFlowThree: IStep, stepTwoForFlowThree,
executionThree: IExecution, executionThree,
expectedResponseForExecutionOne: IJSONObject, expectedResponseForExecutionOne,
expectedResponseForExecutionTwo: IJSONObject, expectedResponseForExecutionTwo,
expectedResponseForExecutionThree: IJSONObject; expectedResponseForExecutionThree;
beforeEach(async () => { beforeEach(async () => {
role = await createRole({ role = await createRole({
@@ -195,7 +194,7 @@ describe('graphQL getExecutions query', () => {
expectedResponseForExecutionOne = { expectedResponseForExecutionOne = {
node: { node: {
createdAt: (executionOne.createdAt as Date).getTime().toString(), createdAt: executionOne.createdAt.getTime().toString(),
flow: { flow: {
active: flowOne.active, active: flowOne.active,
id: flowOne.id, id: flowOne.id,
@@ -212,13 +211,13 @@ describe('graphQL getExecutions query', () => {
id: executionOne.id, id: executionOne.id,
status: 'success', status: 'success',
testRun: executionOne.testRun, testRun: executionOne.testRun,
updatedAt: (executionOne.updatedAt as Date).getTime().toString(), updatedAt: executionOne.updatedAt.getTime().toString(),
}, },
}; };
expectedResponseForExecutionTwo = { expectedResponseForExecutionTwo = {
node: { node: {
createdAt: (executionTwo.createdAt as Date).getTime().toString(), createdAt: executionTwo.createdAt.getTime().toString(),
flow: { flow: {
active: flowTwo.active, active: flowTwo.active,
id: flowTwo.id, id: flowTwo.id,
@@ -235,13 +234,13 @@ describe('graphQL getExecutions query', () => {
id: executionTwo.id, id: executionTwo.id,
status: 'failure', status: 'failure',
testRun: executionTwo.testRun, testRun: executionTwo.testRun,
updatedAt: (executionTwo.updatedAt as Date).getTime().toString(), updatedAt: executionTwo.updatedAt.getTime().toString(),
}, },
}; };
expectedResponseForExecutionThree = { expectedResponseForExecutionThree = {
node: { node: {
createdAt: (executionThree.createdAt as Date).getTime().toString(), createdAt: executionThree.createdAt.getTime().toString(),
flow: { flow: {
active: flowThree.active, active: flowThree.active,
id: flowThree.id, id: flowThree.id,
@@ -258,7 +257,7 @@ describe('graphQL getExecutions query', () => {
id: executionThree.id, id: executionThree.id,
status: 'failure', status: 'failure',
testRun: executionThree.testRun, testRun: executionThree.testRun,
updatedAt: (executionThree.updatedAt as Date).getTime().toString(), updatedAt: executionThree.updatedAt.getTime().toString(),
}, },
}; };
}); });
@@ -435,13 +434,9 @@ describe('graphQL getExecutions query', () => {
}); });
it('should return only executions data within date range', async () => { it('should return only executions data within date range', async () => {
const createdAtFrom = (executionOne.createdAt as Date) const createdAtFrom = executionOne.createdAt.getTime().toString();
.getTime()
.toString();
const createdAtTo = (executionOne.createdAt as Date) const createdAtTo = executionOne.createdAt.getTime().toString();
.getTime()
.toString();
const query = ` const query = `
query { query {

View File

@@ -1,3 +1,4 @@
// @ts-nocheck
import request from 'supertest'; import request from 'supertest';
import app from '../../app'; import app from '../../app';
import createAuthTokenByUserId from '../../helpers/create-auth-token-by-user-id'; import createAuthTokenByUserId from '../../helpers/create-auth-token-by-user-id';
@@ -5,21 +6,20 @@ import Crypto from 'crypto';
import { createRole } from '../../../test/factories/role'; import { createRole } from '../../../test/factories/role';
import { createPermission } from '../../../test/factories/permission'; import { createPermission } from '../../../test/factories/permission';
import { createUser } from '../../../test/factories/user'; import { createUser } from '../../../test/factories/user';
import { IRole, IUser, IPermission } from '@automatisch/types';
import * as license from '../../helpers/license.ee'; import * as license from '../../helpers/license.ee';
describe('graphQL getRole query', () => { describe('graphQL getRole query', () => {
let validRole: IRole, let validRole,
invalidRoleId: string, invalidRoleId,
queryWithValidRole: string, queryWithValidRole,
queryWithInvalidRole: string, queryWithInvalidRole,
userWithPermissions: IUser, userWithPermissions,
userWithoutPermissions: IUser, userWithoutPermissions,
tokenWithPermissions: string, tokenWithPermissions,
tokenWithoutPermissions: string, tokenWithoutPermissions,
invalidToken: string, invalidToken,
permissionOne: IPermission, permissionOne,
permissionTwo: IPermission; permissionTwo;
beforeEach(async () => { beforeEach(async () => {
validRole = await createRole(); validRole = await createRole();

View File

@@ -1,22 +1,22 @@
// @ts-nocheck
import request from 'supertest'; import request from 'supertest';
import app from '../../app'; import app from '../../app';
import createAuthTokenByUserId from '../../helpers/create-auth-token-by-user-id'; import createAuthTokenByUserId from '../../helpers/create-auth-token-by-user-id';
import { createRole } from '../../../test/factories/role'; import { createRole } from '../../../test/factories/role';
import { createPermission } from '../../../test/factories/permission'; import { createPermission } from '../../../test/factories/permission';
import { createUser } from '../../../test/factories/user'; import { createUser } from '../../../test/factories/user';
import { IRole, IUser } from '@automatisch/types';
import * as license from '../../helpers/license.ee'; import * as license from '../../helpers/license.ee';
describe('graphQL getRoles query', () => { describe('graphQL getRoles query', () => {
let currentUserRole: IRole, let currentUserRole,
roleOne: IRole, roleOne,
roleSecond: IRole, roleSecond,
query: string, query,
userWithPermissions: IUser, userWithPermissions,
userWithoutPermissions: IUser, userWithoutPermissions,
tokenWithPermissions: string, tokenWithPermissions,
tokenWithoutPermissions: string, tokenWithoutPermissions,
invalidToken: string; invalidToken;
beforeEach(async () => { beforeEach(async () => {
currentUserRole = await createRole({ name: 'Current user role' }); currentUserRole = await createRole({ name: 'Current user role' });

View File

@@ -1,6 +1,6 @@
// @ts-nocheck
import request from 'supertest'; import request from 'supertest';
import app from '../../app'; import app from '../../app';
import { IUser } from '@automatisch/types';
import User from '../../models/user'; import User from '../../models/user';
import { createUser } from '../../../test/factories/user'; import { createUser } from '../../../test/factories/user';
import createAuthTokenByUserId from '../../helpers/create-auth-token-by-user-id'; import createAuthTokenByUserId from '../../helpers/create-auth-token-by-user-id';
@@ -32,7 +32,7 @@ describe('graphQL getTrialStatus query', () => {
}); });
describe('with authenticated user', () => { describe('with authenticated user', () => {
let user: IUser, userToken: string; let user, userToken;
beforeEach(async () => { beforeEach(async () => {
const trialExpiryDate = DateTime.now().plus({ days: 30 }).toISODate(); const trialExpiryDate = DateTime.now().plus({ days: 30 }).toISODate();
@@ -54,7 +54,7 @@ describe('graphQL getTrialStatus query', () => {
.expect(200); .expect(200);
const expectedResponsePayload = { const expectedResponsePayload = {
data: { getTrialStatus: null as string }, data: { getTrialStatus: null },
}; };
expect(response.body).toEqual(expectedResponsePayload); expect(response.body).toEqual(expectedResponsePayload);
@@ -82,7 +82,7 @@ describe('graphQL getTrialStatus query', () => {
.expect(200); .expect(200);
const expectedResponsePayload = { const expectedResponsePayload = {
data: { getTrialStatus: null as string }, data: { getTrialStatus: null },
}; };
expect(response.body).toEqual(expectedResponsePayload); expect(response.body).toEqual(expectedResponsePayload);

View File

@@ -1,11 +1,11 @@
import request, { Test } from 'supertest'; // @ts-nocheck
import request from 'supertest';
import app from '../../app'; import app from '../../app';
import createAuthTokenByUserId from '../../helpers/create-auth-token-by-user-id'; import createAuthTokenByUserId from '../../helpers/create-auth-token-by-user-id';
import Crypto from 'crypto'; import Crypto from 'crypto';
import { createRole } from '../../../test/factories/role'; import { createRole } from '../../../test/factories/role';
import { createPermission } from '../../../test/factories/permission'; import { createPermission } from '../../../test/factories/permission';
import { createUser } from '../../../test/factories/user'; import { createUser } from '../../../test/factories/user';
import { IRole, IUser } from '@automatisch/types';
describe('graphQL getUser query', () => { describe('graphQL getUser query', () => {
describe('with unauthenticated user', () => { describe('with unauthenticated user', () => {
@@ -61,11 +61,7 @@ describe('graphQL getUser query', () => {
}); });
describe('and correct permissions', () => { describe('and correct permissions', () => {
let role: IRole, let role, currentUser, anotherUser, token, requestObject;
currentUser: IUser,
anotherUser: IUser,
token: string,
requestObject: Test;
beforeEach(async () => { beforeEach(async () => {
role = await createRole({ role = await createRole({
@@ -116,12 +112,12 @@ describe('graphQL getUser query', () => {
const expectedResponsePayload = { const expectedResponsePayload = {
data: { data: {
getUser: { getUser: {
createdAt: (anotherUser.createdAt as Date).getTime().toString(), createdAt: anotherUser.createdAt.getTime().toString(),
email: anotherUser.email, email: anotherUser.email,
fullName: anotherUser.fullName, fullName: anotherUser.fullName,
id: anotherUser.id, id: anotherUser.id,
role: { id: role.id, name: role.name }, role: { id: role.id, name: role.name },
updatedAt: (anotherUser.updatedAt as Date).getTime().toString(), updatedAt: anotherUser.updatedAt.getTime().toString(),
}, },
}, },
}; };

View File

@@ -1,10 +1,10 @@
import request, { Test } from 'supertest'; // @ts-nocheck
import request from 'supertest';
import app from '../../app'; import app from '../../app';
import createAuthTokenByUserId from '../../helpers/create-auth-token-by-user-id'; import createAuthTokenByUserId from '../../helpers/create-auth-token-by-user-id';
import { createRole } from '../../../test/factories/role'; import { createRole } from '../../../test/factories/role';
import { createPermission } from '../../../test/factories/permission'; import { createPermission } from '../../../test/factories/permission';
import { createUser } from '../../../test/factories/user'; import { createUser } from '../../../test/factories/user';
import { IRole, IUser } from '@automatisch/types';
describe('graphQL getUsers query', () => { describe('graphQL getUsers query', () => {
const query = ` const query = `
@@ -61,11 +61,7 @@ describe('graphQL getUsers query', () => {
}); });
describe('and with correct permissions', () => { describe('and with correct permissions', () => {
let role: IRole, let role, currentUser, anotherUser, token, requestObject;
currentUser: IUser,
anotherUser: IUser,
token: string,
requestObject: Test;
beforeEach(async () => { beforeEach(async () => {
role = await createRole({ role = await createRole({

View File

@@ -1,3 +1,4 @@
// @ts-nocheck
import request from 'supertest'; import request from 'supertest';
import app from '../../app'; import app from '../../app';
import appConfig from '../../config/app'; import appConfig from '../../config/app';