Skip to content

Commit

Permalink
BC-7340 - avoid test factories import cycles
Browse files Browse the repository at this point in the history
  • Loading branch information
virgilchiriac committed May 15, 2024
1 parent d6f6285 commit e09c19b
Show file tree
Hide file tree
Showing 256 changed files with 358 additions and 263 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { CalendarEventDto, CalendarService } from '@infra/calendar';
import { HttpService } from '@nestjs/axios';
import { HttpStatus, InternalServerErrorException } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { axiosResponseFactory } from '@shared/testing';
import { axiosResponseFactory } from '@shared/testing/factory';
import { AxiosResponse } from 'axios';
import { of, throwError } from 'rxjs';
import { Logger } from '@src/core/logger';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ObjectId } from '@mikro-orm/mongodb';
import { HttpService } from '@nestjs/axios';
import { NotFoundException, NotImplementedException, UnprocessableEntityException } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { axiosResponseFactory } from '@shared/testing';
import { axiosResponseFactory } from '@shared/testing/factory';
import { LegacyLogger } from '@src/core/logger';
import { AxiosResponse } from 'axios';
import { Observable, of } from 'rxjs';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { LtiToolDO } from '@shared/domain/domainobject/ltitool.do';
import { LtiPrivacyPermission, LtiRoleType, User } from '@shared/domain/entity';
import { RoleName } from '@shared/domain/interface';
import { LtiToolRepo } from '@shared/repo';
import { ltiToolDOFactory, pseudonymFactory, setupEntities, userDoFactory, userFactory } from '@shared/testing';
import { ltiToolDOFactory, pseudonymFactory, setupEntities, userDoFactory, userFactory } from '@shared/testing/factory';
import { LegacyLogger } from '@src/core/logger';
import { TeamRolePermissionsDto } from '../../dto/team-role-permissions.dto';
import { NextcloudClient } from './nextcloud.client';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Test, TestingModule } from '@nestjs/testing';
import { SystemEntity } from '@shared/domain/entity';
import { SystemTypeEnum } from '@shared/domain/types';

import { systemEntityFactory } from '@shared/testing';
import { systemEntityFactory } from '@shared/testing/factory';
import { AxiosResponse } from 'axios';
import { of } from 'rxjs';
import { v1 } from 'uuid';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import {
} from '@infra/oauth-provider/dto';
import { HttpService } from '@nestjs/axios';
import { Test, TestingModule } from '@nestjs/testing';
import { axiosResponseFactory } from '@shared/testing';
import { axiosErrorFactory } from '@shared/testing/factory';
import { axiosResponseFactory, axiosErrorFactory } from '@shared/testing/factory';
import { AxiosError, AxiosRequestConfig, Method, RawAxiosRequestHeaders } from 'axios';
import { of, throwError } from 'rxjs';
import { ProviderConsentSessionResponse } from '../dto';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createMock, DeepMocked } from '@golevelup/ts-jest';
import { OauthAdapterService, OAuthTokenDto } from '@modules/oauth';
import { HttpService } from '@nestjs/axios';
import { axiosResponseFactory } from '@shared/testing';
import { axiosResponseFactory } from '@shared/testing/factory';
import { Logger } from '@src/core/logger';
import { of } from 'rxjs';
import { SchulconnexConfigurationMissingLoggable } from './loggable';
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/modules/account/api/account.uc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { UnauthorizedException } from '@nestjs/common/exceptions/unauthorized.ex
import { Role, User } from '@shared/domain/entity';
import { Permission, RoleName } from '@shared/domain/interface';
import { EntityId } from '@shared/domain/types';
import { schoolEntityFactory, setupEntities, userFactory } from '@shared/testing';
import { schoolEntityFactory, setupEntities, userFactory } from '@shared/testing/factory';
import { Account, AccountSave } from '../domain';
import { AccountEntity } from '../domain/entity/account.entity';
import { AccountService } from '../domain/services';
Expand Down
8 changes: 7 additions & 1 deletion apps/server/src/modules/account/api/test/account.api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import { INestApplication } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { User } from '@shared/domain/entity';
import { Permission, RoleName } from '@shared/domain/interface';
import { TestApiClient, cleanupCollections, roleFactory, schoolEntityFactory, userFactory } from '@shared/testing';
import {
TestApiClient,
cleanupCollections,
roleFactory,
schoolEntityFactory,
userFactory,
} from '@shared/testing/factory';
import { ServerTestModule } from '@modules/server/server.module';
import {
AccountByIdBodyParams,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Test, TestingModule } from '@nestjs/testing';
import { EntityNotFoundError } from '@shared/common';
import { IdmAccount } from '@shared/domain/interface';
import { EntityId } from '@shared/domain/types';
import { setupEntities, userFactory } from '@shared/testing';
import { setupEntities, userFactory } from '@shared/testing/factory';
import { Logger } from '@src/core/logger';
import bcrypt from 'bcryptjs';
import { v1 } from 'uuid';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Test, TestingModule } from '@nestjs/testing';
import { AuthorizationError, EntityNotFoundError, ForbiddenOperationError, ValidationError } from '@shared/common';
import { User } from '@shared/domain/entity';
import { UserRepo } from '@shared/repo';
import { schoolEntityFactory, setupEntities, systemFactory, userFactory } from '@shared/testing';
import { schoolEntityFactory, setupEntities, systemFactory, userFactory } from '@shared/testing/factory';
import { Logger } from '@src/core/logger';
import 'reflect-metadata';
import { Account, AccountSave, UpdateAccount } from '..';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Test, TestingModule } from '@nestjs/testing';
import { Role } from '@shared/domain/entity';
import { Permission, RoleName } from '@shared/domain/interface';
import { UserRepo } from '@shared/repo';
import { setupEntities, systemFactory, userFactory } from '@shared/testing';
import { setupEntities, systemFactory, userFactory } from '@shared/testing/factory';
import { ObjectId } from '@mikro-orm/mongodb';
import { AccountRepo } from '../../repo/micro-orm/account.repo';
import { AccountValidationService } from './account.validation.service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { NotFoundError } from '@mikro-orm/core';
import { EntityManager, ObjectId } from '@mikro-orm/mongodb';
import { Test, TestingModule } from '@nestjs/testing';
import { User } from '@shared/domain/entity';
import { cleanupCollections, userFactory } from '@shared/testing';
import { cleanupCollections, userFactory } from '@shared/testing/factory';
import { AccountRepo } from './account.repo';
import { AccountEntity } from '../../domain/entity/account.entity';
import { AccountDoToEntityMapper } from './mapper/account-do-to-entity.mapper';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { HttpService } from '@nestjs/axios';
import { createMock, DeepMocked } from '@golevelup/ts-jest';
import { ConfigService } from '@nestjs/config';
import { ServerConfig } from '@modules/server';
import { axiosResponseFactory } from '@shared/testing';
import { axiosResponseFactory } from '@shared/testing/factory';
import { of, throwError } from 'rxjs';
import { AxiosError } from 'axios';
import { StatusAdapter } from './status.adapter';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { HttpService } from '@nestjs/axios';
import { Test, TestingModule } from '@nestjs/testing';
import request from 'supertest';
import { of } from 'rxjs';
import { axiosResponseFactory } from '@shared/testing';
import { axiosResponseFactory } from '@shared/testing/factory';
import { SchulcloudTheme } from '@shared/domain/types';
import { serverConfig, ServerTestModule } from '../../../server';
import { createComponent, createIncident } from '../../testing';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { HttpStatus, INestApplication } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { SchoolEntity, SystemEntity, User } from '@shared/domain/entity';
import { RoleName } from '@shared/domain/interface';
import { roleFactory, schoolEntityFactory, systemEntityFactory, userFactory } from '@shared/testing';
import { roleFactory, schoolEntityFactory, systemEntityFactory, userFactory } from '@shared/testing/factory';
import { AccountEntity } from '@src/modules/account/domain/entity/account.entity';
import { accountFactory } from '@src/modules/account/testing';
import axios from 'axios';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ValidationError } from '@shared/common';
import { UserDO } from '@shared/domain/domainobject/user.do';
import { Permission, RoleName } from '@shared/domain/interface';
import { roleFactory, schoolEntityFactory, setupEntities, userDoFactory, userFactory } from '@shared/testing';
import { roleFactory, schoolEntityFactory, setupEntities, userDoFactory, userFactory } from '@shared/testing/factory';
import { ICurrentUser, OauthCurrentUser } from '../interface';
import { CreateJwtPayload, JwtPayload } from '../interface/jwt-payload';
import { CurrentUserMapper } from './current-user.mapper';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createMock } from '@golevelup/ts-jest';
import { UnauthorizedException } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { SystemEntity } from '@shared/domain/entity';
import { systemEntityFactory } from '@shared/testing';
import { systemEntityFactory } from '@shared/testing/factory';
import { LegacyLogger } from '@src/core/logger';
import { LdapService } from './ldap.service';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ConfigService } from '@nestjs/config';
import { User } from '@shared/domain/entity';
import { RoleName } from '@shared/domain/interface';
import { UserRepo } from '@shared/repo';
import { setupEntities, userFactory } from '@shared/testing';
import { setupEntities, userFactory } from '@shared/testing/factory';
import { accountDoFactory } from '@src/modules/account/testing';
import bcrypt from 'bcryptjs';
import { AuthenticationService } from '../services/authentication.service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Test, TestingModule } from '@nestjs/testing';
import { UserDO } from '@shared/domain/domainobject/user.do';
import { RoleName } from '@shared/domain/interface';
import { EntityId } from '@shared/domain/types';
import { userDoFactory } from '@shared/testing';
import { userDoFactory } from '@shared/testing/factory';

import { ICurrentUser, OauthCurrentUser } from '../interface';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { schoolExternalToolEntityFactory } from '@modules/tool/school-external-t
import { Test, TestingModule } from '@nestjs/testing';
import { Role, User } from '@shared/domain/entity';
import { Permission } from '@shared/domain/interface';
import { roleFactory, schoolEntityFactory, setupEntities, userFactory } from '@shared/testing';
import { roleFactory, schoolEntityFactory, setupEntities, userFactory } from '@shared/testing/factory';
import { AuthorizationHelper } from '../service/authorization.helper';
import { Action } from '../type';
import { ContextExternalToolRule } from './context-external-tool.rule';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Test, TestingModule } from '@nestjs/testing';
import { CourseGroup, User } from '@shared/domain/entity';
import { Permission } from '@shared/domain/interface';
import { courseFactory, courseGroupFactory, roleFactory, setupEntities, userFactory } from '@shared/testing';
import { courseFactory, courseGroupFactory, roleFactory, setupEntities, userFactory } from '@shared/testing/factory';
import { CourseGroupRule } from './course-group.rule';
import { CourseRule } from './course.rule';
import { Action } from '../type';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { courseFactory } from '@modules/learnroom/testing';
import { Test, TestingModule } from '@nestjs/testing';
import { Course, User } from '@shared/domain/entity';
import { Permission } from '@shared/domain/interface';
import { courseFactory as courseEntityFactory, roleFactory, setupEntities, userFactory } from '@shared/testing';
import { courseFactory as courseEntityFactory, roleFactory, setupEntities, userFactory } from '@shared/testing/factory';
import { AuthorizationHelper } from '../service/authorization.helper';
import { Action } from '../type';
import { CourseRule } from './course.rule';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest';
import { Test, TestingModule } from '@nestjs/testing';
import { Role, SchoolEntity, User } from '@shared/domain/entity';
import { Permission } from '@shared/domain/interface';
import { groupFactory, roleFactory, schoolEntityFactory, setupEntities, userFactory } from '@shared/testing';
import { groupFactory, roleFactory, schoolEntityFactory, setupEntities, userFactory } from '@shared/testing/factory';
import { Action, AuthorizationContext, AuthorizationHelper } from '@src/modules/authorization';
import { Group } from '@src/modules/group';
import { ObjectId } from '@mikro-orm/mongodb';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Test, TestingModule } from '@nestjs/testing';
import { Permission } from '@shared/domain/interface';
import { roleFactory, legacySchoolDoFactory, setupEntities, userFactory } from '@shared/testing';
import { roleFactory, legacySchoolDoFactory, setupEntities, userFactory } from '@shared/testing/factory';
import { ObjectId } from '@mikro-orm/mongodb';
import { Action } from '../type';
import { AuthorizationHelper } from '../service/authorization.helper';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createMock, DeepMocked } from '@golevelup/ts-jest';
import { schoolFactory } from '@modules/school/testing/school.factory';
import { Test, TestingModule } from '@nestjs/testing';
import { setupEntities, userFactory } from '@shared/testing';
import { setupEntities, userFactory } from '@shared/testing/factory';
import { AuthorizationContextBuilder } from '../mapper';
import { AuthorizationHelper } from '../service/authorization.helper';
import { SchoolRule } from './school.rule';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import { System } from '@modules/system';
import { Test, TestingModule } from '@nestjs/testing';
import { SchoolEntity, SystemEntity, User } from '@shared/domain/entity';
import { Permission } from '@shared/domain/interface';
import { schoolEntityFactory, setupEntities, systemEntityFactory, systemFactory, userFactory } from '@shared/testing';
import {
schoolEntityFactory,
setupEntities,
systemEntityFactory,
systemFactory,
userFactory,
} from '@shared/testing/factory';
import { AuthorizationContextBuilder } from '../mapper';
import { AuthorizationHelper } from '../service/authorization.helper';
import { SystemRule } from './system.rule';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import { DeepPartial } from '@mikro-orm/core';
import { Test, TestingModule } from '@nestjs/testing';
import { Permission, RoleName } from '@shared/domain/interface';
import { courseFactory, lessonFactory, roleFactory, setupEntities, taskFactory, userFactory } from '@shared/testing';
import {
courseFactory,
lessonFactory,
roleFactory,
setupEntities,
taskFactory,
userFactory,
} from '@shared/testing/factory';
import { AuthorizationHelper } from '../service/authorization.helper';
import { Action } from '../type';
import { CourseGroupRule } from './course-group.rule';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Test, TestingModule } from '@nestjs/testing';
import { Permission } from '@shared/domain/interface';
import { roleFactory, setupEntities, userFactory, teamFactory } from '@shared/testing';
import { roleFactory, setupEntities, userFactory, teamFactory } from '@shared/testing/factory';
import { AuthorizationHelper } from '../service/authorization.helper';
import { TeamRule } from './team.rule';
import { AuthorizationContextBuilder } from '../mapper';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ObjectId } from '@mikro-orm/mongodb';
import { Test, TestingModule } from '@nestjs/testing';
import { UserLoginMigrationDO } from '@shared/domain/domainobject';
import { Permission } from '@shared/domain/interface';
import { schoolEntityFactory, setupEntities, userFactory, userLoginMigrationDOFactory } from '@shared/testing';
import { schoolEntityFactory, setupEntities, userFactory, userLoginMigrationDOFactory } from '@shared/testing/factory';
import { AuthorizationHelper } from '../service/authorization.helper';
import { Action, AuthorizationContext } from '../type';
import { UserLoginMigrationRule } from './user-login-migration.rule';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Test, TestingModule } from '@nestjs/testing';
import { Role, User } from '@shared/domain/entity';
import { Permission } from '@shared/domain/interface';
import { roleFactory, setupEntities, userFactory } from '@shared/testing';
import { roleFactory, setupEntities, userFactory } from '@shared/testing/factory';
import { Action } from '../type';
import { AuthorizationHelper } from '../service/authorization.helper';
import { UserRule } from './user.rule';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createMock, DeepMocked } from '@golevelup/ts-jest';
import { NotFoundException } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { courseFactory, setupEntities, userFactory } from '@shared/testing';
import { courseFactory, setupEntities, userFactory } from '@shared/testing/factory';
import { ObjectId } from '@mikro-orm/mongodb';
import { AuthorizableReferenceType } from '../type';
import { AuthorizationService } from './authorization.service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { UnauthorizedException } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { Permission } from '@shared/domain/interface';
import { UserRepo } from '@shared/repo';
import { setupEntities, userFactory } from '@shared/testing';
import { setupEntities, userFactory } from '@shared/testing/factory';
import { ForbiddenLoggableException } from '../error';
import { AuthorizationContextBuilder } from '../mapper';
import { Rule } from '../type';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
TeamsRepo,
UserRepo,
} from '@shared/repo';
import { setupEntities, userFactory } from '@shared/testing';
import { setupEntities, userFactory } from '@shared/testing/factory';
import { AuthorizableReferenceType } from '../type';
import { ReferenceLoader } from './reference.loader';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createMock, DeepMocked } from '@golevelup/ts-jest';
import { InternalServerErrorException, NotImplementedException } from '@nestjs/common';
import { Test } from '@nestjs/testing';
import { courseFactory, setupEntities, userFactory } from '@shared/testing';
import { courseFactory, setupEntities, userFactory } from '@shared/testing/factory';
import { AuthorizationContextBuilder } from '../mapper';
import {
BoardDoRule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { INestApplication } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { BoardExternalReferenceType, BoardLayout } from '@shared/domain/domainobject';
import { ColumnBoardNode } from '@shared/domain/entity';
import { cleanupCollections, courseFactory, TestApiClient, UserAndAccountTestFactory } from '@shared/testing';
import { cleanupCollections, courseFactory, TestApiClient, UserAndAccountTestFactory } from '@shared/testing/factory';
import { CreateBoardBodyParams } from '../dto';

const baseRouteName = '/boards';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import { HttpStatus, INestApplication } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { BoardExternalReferenceType } from '@shared/domain/domainobject';
import { BoardNode } from '@shared/domain/entity';
import { mediaBoardNodeFactory, mediaLineNodeFactory, TestApiClient, UserAndAccountTestFactory } from '@shared/testing';
import {
mediaBoardNodeFactory,
mediaLineNodeFactory,
TestApiClient,
UserAndAccountTestFactory,
} from '@shared/testing/factory';
import { MoveColumnBodyParams, RenameBodyParams } from '../../dto';

const baseRouteName = '/media-lines';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ObjectId } from '@mikro-orm/mongodb';
import { EventBus } from '@nestjs/cqrs';
import { Test, TestingModule } from '@nestjs/testing';
import { BoardExternalReferenceType } from '@shared/domain/domainobject';
import { mediaBoardFactory } from '@shared/testing';
import { mediaBoardFactory } from '@shared/testing/factory';
import { Logger } from '@src/core/logger';
import {
DataDeletedEvent,
Expand Down
Loading

0 comments on commit e09c19b

Please sign in to comment.