From 07d82fa8d5846109bf88bf12c1f7d2abe578b592 Mon Sep 17 00:00:00 2001 From: dyedwiper Date: Wed, 1 Nov 2023 11:51:02 +0100 Subject: [PATCH] Fix tests --- .../apps/helpers/app-start-loggable.spec.ts | 2 ++ .../apps/helpers/prometheus-metrics.spec.ts | 11 +++++----- .../validation-error-detail.response.spec.ts | 2 ++ .../src/core/logger/error-logger.spec.ts | 2 ++ apps/server/src/core/logger/logger.spec.ts | 3 ++- .../controller/dto/password-patter.spec.ts | 2 ++ .../account-entity-to-dto.mapper.spec.ts | 4 ++++ .../mapper/account-response.mapper.spec.ts | 6 ++++++ .../src/modules/account/uc/account.uc.spec.ts | 3 +-- .../mapper/current-user.mapper.spec.ts | 2 +- .../strategy/jwt.strategy.spec.ts | 2 +- .../strategy/ldap.strategy.spec.ts | 3 ++- .../authorization-context.builder.spec.ts | 4 ++++ .../authorization.helper.spec.ts | 8 ++++++++ .../repo/recursive-delete.visitor.spec.ts | 2 +- .../service/submission-item.service.spec.ts | 1 + .../testing/class-source-options.do.spec.ts | 2 ++ .../class-source-options.entity.spec.ts | 2 ++ .../dto/copy-file.dto.spec.ts | 2 ++ .../files-storage-client/dto/file.dto.spec.ts | 3 +++ ...copy-files-of-parent-param.builder.spec.ts | 6 ++++++ .../files-storage-client.mapper.spec.ts | 5 +++++ .../files-storage-param.builder.spec.ts | 6 ++++++ .../files-storage-client.service.spec.ts | 9 +++++++++ .../service/files-storage.producer.spec.ts | 9 +++++++++ .../files-storage-download.service.spec.ts | 1 + .../api-test/h5p-editor.api.spec.ts | 3 +++ .../common-cartridge-file-builder.spec.ts | 4 ++++ .../common-cartridge-lti-resource.spec.ts | 2 ++ .../common-cartridge-manifest-element.spec.ts | 4 ++++ .../common-cartridge-metadata-element.spec.ts | 3 +++ ...ridge-organization-wrapper-element.spec.ts | 3 +++ ...cartridge-resource-wrapper-element.spec.ts | 3 +++ .../controller/api-test/course.api.spec.ts | 7 +++++++ .../controller/api-test/dashboard.api.spec.ts | 14 ++++++++++++- .../api-test/rooms-copy-timeout.api.spec.ts | 3 +-- .../controller/rooms.controller.spec.ts | 11 ++++++++++ .../mapper/room-board-response.mapper.spec.ts | 7 +++++++ .../column-board-target.service.spec.ts | 6 ++++++ .../learnroom/service/course.service.spec.ts | 7 +++++++ .../service/coursegroup.service.spec.ts | 6 ++++++ .../learnroom/service/rooms.service.spec.ts | 20 +++++++++++++++++++ .../learnroom/uc/course-copy.uc.spec.ts | 11 ++++++++++ .../learnroom/uc/course-export.uc.spec.ts | 4 ++++ .../modules/learnroom/uc/course.uc.spec.ts | 6 ++++++ .../learnroom/uc/lesson-copy.uc.spec.ts | 19 ++++++++++++++++++ .../uc/rooms.authorisation.service.spec.ts | 6 ++++++ .../src/modules/learnroom/uc/rooms.uc.spec.ts | 15 ++++++++++++++ .../service/lesson-copy.service.spec.ts | 2 +- .../console/board-management.console.spec.ts | 4 +++- .../database-management.console.spec.ts | 3 +++ .../api-test/database-management.api.spec.ts | 2 +- .../database-management.controller.spec.ts | 2 ++ .../converter/bson.converter.spec.ts | 1 + .../management/management.module.spec.ts | 3 +++ .../seed-data/generateSeedData.spec.ts | 2 ++ .../management/seed-data/roles.spec.ts | 2 ++ .../news/controller/api-test/news.api.spec.ts | 11 +++++++++- .../src/modules/news/uc/news.uc.spec.ts | 6 ++++++ ...-token-creation-exception.loggable.spec.ts | 2 ++ .../oauth-provider-request.mapper.spec.ts | 4 ++++ .../service/id-token.service.spec.ts | 17 ++++++++++++++++ .../oauth-provider.login-flow.service.spec.ts | 9 +++++++++ .../uc/oauth-provider.client-crud.uc.spec.ts | 9 +++++++++ .../uc/oauth-provider.logout-flow.uc.spec.ts | 2 ++ .../uc/oauth-provider.uc.spec.ts | 3 +++ .../oauth/mapper/token-request.mapper.spec.ts | 5 +++++ .../group-role-unknown.loggable.spec.ts | 4 ++++ ...chool-for-group-not-found.loggable.spec.ts | 4 ++++ .../user-for-group-not-found.loggable.spec.ts | 4 ++++ .../provisioning-system-input.mapper.spec.ts | 5 +++++ .../service/oidc-provisioning.service.spec.ts | 3 ++- ...many-pseudonyms.loggable-exception.spec.ts | 2 ++ ...al-tool-pseudonym.repo.integration.spec.ts | 13 +++++++++++- .../pseudonym/repo/pseudonyms.repo.spec.ts | 10 +++++++++- .../service/pseudonym.service.spec.ts | 14 +++++++++++++ .../modules/role/mapper/role.mapper.spec.ts | 7 +++++++ .../modules/role/service/role.service.spec.ts | 6 ++++++ .../src/modules/role/uc/role.uc.spec.ts | 4 ++++ .../controller/api-test/server.api.spec.ts | 2 +- .../controller/server.controller.spec.ts | 1 + .../controller/api-test/system.api.spec.ts | 9 ++++++++- .../system/mapper/system-oidc.mapper.spec.ts | 3 +++ .../system/mapper/system.mapper.spec.ts | 3 +++ .../service/system-oidc.service.spec.ts | 6 ++++++ .../system/service/system.service.spec.ts | 8 ++++++++ .../src/modules/system/uc/system.uc.spec.ts | 9 +++++++++ .../api-test/task-copy-timeout.api.spec.ts | 3 +-- .../task/mapper/submission.mapper.spec.ts | 5 +++++ .../task/service/submission.service.spec.ts | 2 +- .../teams/service/team.service.spec.ts | 5 +++++ .../external-tool-logo-service.spec.ts | 3 +-- ...-tool-parameter-validation.service.spec.ts | 2 +- .../external-tool-validation.service.spec.ts | 2 +- .../service/school-migration.service.spec.ts | 1 + .../modules/user/service/user.service.spec.ts | 2 +- .../bbb/builder/builder.spec.ts | 2 +- .../api-test/video-conference.api.spec.ts | 4 +--- .../common/error/validation.error.spec.ts | 1 + apps/server/src/shared/infra/metrics/index.ts | 1 + .../shared/infra/metrics/prometheus/index.ts | 4 ++++ .../shared/repo/base.repo.integration.spec.ts | 6 +++--- .../user/user-do.repo.integration.spec.ts | 2 +- 103 files changed, 477 insertions(+), 40 deletions(-) create mode 100644 apps/server/src/shared/infra/metrics/index.ts create mode 100644 apps/server/src/shared/infra/metrics/prometheus/index.ts diff --git a/apps/server/src/apps/helpers/app-start-loggable.spec.ts b/apps/server/src/apps/helpers/app-start-loggable.spec.ts index 9ba04f0351f..f78a263141c 100644 --- a/apps/server/src/apps/helpers/app-start-loggable.spec.ts +++ b/apps/server/src/apps/helpers/app-start-loggable.spec.ts @@ -1,3 +1,5 @@ +import { AppStartLoggable } from './app-start-loggable'; + describe('AppStartLoggable', () => { describe('getLogMessage', () => { const expectedMessage = 'Successfully started listening...'; diff --git a/apps/server/src/apps/helpers/prometheus-metrics.spec.ts b/apps/server/src/apps/helpers/prometheus-metrics.spec.ts index 925394d84ac..d18073baa69 100644 --- a/apps/server/src/apps/helpers/prometheus-metrics.spec.ts +++ b/apps/server/src/apps/helpers/prometheus-metrics.spec.ts @@ -1,12 +1,13 @@ import { createMock } from '@golevelup/ts-jest'; import { Configuration } from '@hpi-schul-cloud/commons'; import { IConfig } from '@hpi-schul-cloud/commons/lib/interfaces/IConfig'; -import { createPrometheusMetricsApp } from '@shared/infra/metrics/prometheus/app'; -import { PrometheusMetricsConfig } from '@shared/infra/metrics/prometheus/config'; -import { createAPIResponseTimeMetricMiddleware } from '@shared/infra/metrics/prometheus/middleware'; - +import { + createAPIResponseTimeMetricMiddleware, + createPrometheusMetricsApp, + PrometheusMetricsConfig, +} from '@shared/infra/metrics'; +import { Logger } from '@src/core/logger/logger'; import express, { Express, NextFunction, Request, RequestHandler, Response } from 'express'; -import { Logger } from 'winston'; import { addPrometheusMetricsMiddlewaresIfEnabled, createAndStartPrometheusMetricsAppIfEnabled, diff --git a/apps/server/src/core/error/dto/validation-error-detail.response.spec.ts b/apps/server/src/core/error/dto/validation-error-detail.response.spec.ts index 10bb93a942d..a010730f8b3 100644 --- a/apps/server/src/core/error/dto/validation-error-detail.response.spec.ts +++ b/apps/server/src/core/error/dto/validation-error-detail.response.spec.ts @@ -1,3 +1,5 @@ +import { ValidationErrorDetailResponse } from './validation-error-detail.response'; + describe('ValidationErrorDetailResponse', () => { describe('when creating a ValidationErrorDetailResponse instance', () => { it('should have field and errors defined', () => { diff --git a/apps/server/src/core/logger/error-logger.spec.ts b/apps/server/src/core/logger/error-logger.spec.ts index 7d1c3a6ba71..fcca1f048c9 100644 --- a/apps/server/src/core/logger/error-logger.spec.ts +++ b/apps/server/src/core/logger/error-logger.spec.ts @@ -2,6 +2,8 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; import { WINSTON_MODULE_PROVIDER } from 'nest-winston'; import { Logger as WinstonLogger } from 'winston'; +import { ErrorLoggable } from '../error/loggable/error.loggable'; +import { ErrorLogger } from './error-logger'; describe('ErrorLogger', () => { let module: TestingModule; diff --git a/apps/server/src/core/logger/logger.spec.ts b/apps/server/src/core/logger/logger.spec.ts index d74cdeea92c..c83f34a6a35 100644 --- a/apps/server/src/core/logger/logger.spec.ts +++ b/apps/server/src/core/logger/logger.spec.ts @@ -1,8 +1,9 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; import { WINSTON_MODULE_PROVIDER } from 'nest-winston'; -import { Logger, Logger as WinstonLogger } from 'winston'; +import { Logger as WinstonLogger } from 'winston'; import { Loggable } from './interfaces/loggable'; +import { Logger } from './logger'; import { ErrorLogMessage, LogMessage, ValidationErrorLogMessage } from './types/logging.types'; class SampleLoggable implements Loggable { diff --git a/apps/server/src/modules/account/controller/dto/password-patter.spec.ts b/apps/server/src/modules/account/controller/dto/password-patter.spec.ts index 4fc004867a0..82f2bc41506 100644 --- a/apps/server/src/modules/account/controller/dto/password-patter.spec.ts +++ b/apps/server/src/modules/account/controller/dto/password-patter.spec.ts @@ -1,3 +1,5 @@ +import { passwordPattern } from './password-pattern'; + describe('password patter', () => { it('should accept a valid password', () => { expect(passwordPattern.test('Asdf 1ds df!')).toBe(true); diff --git a/apps/server/src/modules/account/mapper/account-entity-to-dto.mapper.spec.ts b/apps/server/src/modules/account/mapper/account-entity-to-dto.mapper.spec.ts index 2c3e326d27e..1dd60cb757b 100644 --- a/apps/server/src/modules/account/mapper/account-entity-to-dto.mapper.spec.ts +++ b/apps/server/src/modules/account/mapper/account-entity-to-dto.mapper.spec.ts @@ -1,3 +1,7 @@ +import { Account } from '@shared/domain/entity/account.entity'; +import { accountFactory } from '@shared/testing/factory/account.factory'; +import { AccountEntityToDtoMapper } from './account-entity-to-dto.mapper'; + describe('AccountEntityToDtoMapper', () => { beforeEach(() => { jest.useFakeTimers(); diff --git a/apps/server/src/modules/account/mapper/account-response.mapper.spec.ts b/apps/server/src/modules/account/mapper/account-response.mapper.spec.ts index 7743fb2ba6d..cd108802550 100644 --- a/apps/server/src/modules/account/mapper/account-response.mapper.spec.ts +++ b/apps/server/src/modules/account/mapper/account-response.mapper.spec.ts @@ -1,3 +1,9 @@ +import { Account } from '@shared/domain/entity/account.entity'; +import { accountDtoFactory } from '@shared/testing/factory/account-dto.factory'; +import { accountFactory } from '@shared/testing/factory/account.factory'; +import { AccountDto } from '../services/dto/account.dto'; +import { AccountResponseMapper } from './account-response.mapper'; + describe('AccountResponseMapper', () => { describe('mapToResponseFromEntity', () => { describe('When mapping AccountEntity to AccountResponse', () => { diff --git a/apps/server/src/modules/account/uc/account.uc.spec.ts b/apps/server/src/modules/account/uc/account.uc.spec.ts index 717d88ef803..ca5a4f42e53 100644 --- a/apps/server/src/modules/account/uc/account.uc.spec.ts +++ b/apps/server/src/modules/account/uc/account.uc.spec.ts @@ -4,6 +4,7 @@ import { Test, TestingModule } from '@nestjs/testing'; import { AuthorizationError } from '@shared/common/error/authorization.error'; import { EntityNotFoundError } from '@shared/common/error/entity-not-found.error'; import { ForbiddenOperationError } from '@shared/common/error/forbidden-operation.error'; +import { ValidationError } from '@shared/common/error/validation.error'; import { Account } from '@shared/domain/entity/account.entity'; import { Role } from '@shared/domain/entity/role.entity'; import { SchoolRolePermission, SchoolRoles } from '@shared/domain/entity/school.entity'; @@ -20,9 +21,7 @@ import { userFactory } from '@shared/testing/factory/user.factory'; import { setupEntities } from '@shared/testing/setup-entities'; import { BruteForcePrevention } from '@src/imports-from-feathers'; import { ICurrentUser } from '@src/modules/authentication/interface/user'; - import { ObjectId } from 'bson'; -import { ValidationError } from 'class-validator'; import { AccountByIdBodyParams } from '../controller/dto/account-by-id.body.params'; import { AccountByIdParams } from '../controller/dto/account-by-id.params'; import { AccountSearchListResponse } from '../controller/dto/account-search-list.response'; diff --git a/apps/server/src/modules/authentication/mapper/current-user.mapper.spec.ts b/apps/server/src/modules/authentication/mapper/current-user.mapper.spec.ts index 2d6fdf11cf7..b6ce69b00b5 100644 --- a/apps/server/src/modules/authentication/mapper/current-user.mapper.spec.ts +++ b/apps/server/src/modules/authentication/mapper/current-user.mapper.spec.ts @@ -1,3 +1,4 @@ +import { ValidationError } from '@shared/common/error/validation.error'; import { UserDO } from '@shared/domain/domainobject/user.do'; import { Permission } from '@shared/domain/interface/permission.enum'; import { RoleName } from '@shared/domain/interface/rolename.enum'; @@ -6,7 +7,6 @@ import { schoolFactory } from '@shared/testing/factory/school.factory'; import { userDoFactory } from '@shared/testing/factory/user.do.factory'; import { userFactory } from '@shared/testing/factory/user.factory'; import { setupEntities } from '@shared/testing/setup-entities'; -import { ValidationError } from 'class-validator'; import { JwtPayload } from 'jsonwebtoken'; import { CreateJwtPayload } from '../interface/jwt-payload'; import { ICurrentUser, OauthCurrentUser } from '../interface/user'; diff --git a/apps/server/src/modules/authentication/strategy/jwt.strategy.spec.ts b/apps/server/src/modules/authentication/strategy/jwt.strategy.spec.ts index a589d259f7c..8d9507e2c07 100644 --- a/apps/server/src/modules/authentication/strategy/jwt.strategy.spec.ts +++ b/apps/server/src/modules/authentication/strategy/jwt.strategy.spec.ts @@ -6,8 +6,8 @@ import { Test, TestingModule } from '@nestjs/testing'; import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { UnauthorizedException } from '@nestjs/common'; import { setupEntities } from '@shared/testing/setup-entities'; -import { JwtPayload } from 'jsonwebtoken'; import { jwtConstants } from '../constants'; +import { JwtPayload } from '../interface/jwt-payload'; import { JwtValidationAdapter } from './jwt-validation.adapter'; import { JwtStrategy } from './jwt.strategy'; diff --git a/apps/server/src/modules/authentication/strategy/ldap.strategy.spec.ts b/apps/server/src/modules/authentication/strategy/ldap.strategy.spec.ts index 242c896de48..3de38e6ad3d 100644 --- a/apps/server/src/modules/authentication/strategy/ldap.strategy.spec.ts +++ b/apps/server/src/modules/authentication/strategy/ldap.strategy.spec.ts @@ -1,5 +1,5 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; -import { Logger, UnauthorizedException } from '@nestjs/common'; +import { UnauthorizedException } from '@nestjs/common'; import { PassportModule } from '@nestjs/passport'; import { Test, TestingModule } from '@nestjs/testing'; import { LegacySchoolDo } from '@shared/domain/domainobject/legacy-school.do'; @@ -16,6 +16,7 @@ import { schoolFactory } from '@shared/testing/factory/school.factory'; import { systemFactory } from '@shared/testing/factory/system.factory'; import { userFactory } from '@shared/testing/factory/user.factory'; import { setupEntities } from '@shared/testing/setup-entities'; +import { Logger } from '@src/core/logger/logger'; import { AccountDto } from '@src/modules/account/services/dto/account.dto'; import { LdapAuthorizationBodyParams } from '../controllers/dto/ldap-authorization.body.params'; import { ICurrentUser } from '../interface/user'; diff --git a/apps/server/src/modules/authorization/authorization-context.builder.spec.ts b/apps/server/src/modules/authorization/authorization-context.builder.spec.ts index da9a91595f6..a8aa2c9c2ac 100644 --- a/apps/server/src/modules/authorization/authorization-context.builder.spec.ts +++ b/apps/server/src/modules/authorization/authorization-context.builder.spec.ts @@ -1,3 +1,7 @@ +import { Permission } from '@shared/domain/interface/permission.enum'; +import { AuthorizationContextBuilder } from './authorization-context.builder'; +import { Action } from './types/action.enum'; + describe('AuthorizationContextBuilder', () => { it('Should allow to set required permissions.', () => { const permissionA = 'a' as Permission; diff --git a/apps/server/src/modules/authorization/authorization.helper.spec.ts b/apps/server/src/modules/authorization/authorization.helper.spec.ts index acf262bd2a2..c99cec50eb1 100644 --- a/apps/server/src/modules/authorization/authorization.helper.spec.ts +++ b/apps/server/src/modules/authorization/authorization.helper.spec.ts @@ -1,3 +1,11 @@ +import { Permission } from '@shared/domain/interface/permission.enum'; +import { courseFactory } from '@shared/testing/factory/course.factory'; +import { roleFactory } from '@shared/testing/factory/role.factory'; +import { taskFactory } from '@shared/testing/factory/task.factory'; +import { userFactory } from '@shared/testing/factory/user.factory'; +import { setupEntities } from '@shared/testing/setup-entities'; +import { AuthorizationHelper } from './authorization.helper'; + describe('AuthorizationHelper', () => { // If we have a class with no dependencies, do we still wanna build a testing module? Or is it fine like this? const service = new AuthorizationHelper(); diff --git a/apps/server/src/modules/board/repo/recursive-delete.visitor.spec.ts b/apps/server/src/modules/board/repo/recursive-delete.visitor.spec.ts index d4447dd76ce..c47f0e00944 100644 --- a/apps/server/src/modules/board/repo/recursive-delete.visitor.spec.ts +++ b/apps/server/src/modules/board/repo/recursive-delete.visitor.spec.ts @@ -9,8 +9,8 @@ import { linkElementFactory } from '@shared/testing/factory/domainobject/board/l import { submissionContainerElementFactory } from '@shared/testing/factory/domainobject/board/submission-container-element.do.factory'; import { submissionItemFactory } from '@shared/testing/factory/domainobject/board/submission-item.do.factory'; import { setupEntities } from '@shared/testing/setup-entities'; +import { FileDto } from '@src/modules/files-storage-client/dto/file.dto'; import { FilesStorageClientAdapterService } from '@src/modules/files-storage-client/service/files-storage-client.service'; -import { FileDto } from '@src/modules/files-storage/dto/file.dto'; import { FileRecordParentType } from '@src/modules/files-storage/entity/filerecord.entity'; import { RecursiveDeleteVisitor } from './recursive-delete.vistor'; diff --git a/apps/server/src/modules/board/service/submission-item.service.spec.ts b/apps/server/src/modules/board/service/submission-item.service.spec.ts index 37b3183bef7..139c92fb4f2 100644 --- a/apps/server/src/modules/board/service/submission-item.service.spec.ts +++ b/apps/server/src/modules/board/service/submission-item.service.spec.ts @@ -1,6 +1,7 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { NotFoundException, UnprocessableEntityException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; +import { ValidationError } from '@shared/common/error/validation.error'; import { SubmissionItem } from '@shared/domain/domainobject/board/submission-item.do'; import { cardFactory } from '@shared/testing/factory/domainobject/board/card.do.factory'; import { richTextElementFactory } from '@shared/testing/factory/domainobject/board/rich-text-element.do.factory'; diff --git a/apps/server/src/modules/class/domain/testing/class-source-options.do.spec.ts b/apps/server/src/modules/class/domain/testing/class-source-options.do.spec.ts index 9bca137f26d..6ca0b4a11aa 100644 --- a/apps/server/src/modules/class/domain/testing/class-source-options.do.spec.ts +++ b/apps/server/src/modules/class/domain/testing/class-source-options.do.spec.ts @@ -1,3 +1,5 @@ +import { ClassSourceOptions } from '../class-source-options.do'; + describe(ClassSourceOptions.name, () => { describe('constructor', () => { describe('When a contructor is called', () => { diff --git a/apps/server/src/modules/class/entity/testing/class-source-options.entity.spec.ts b/apps/server/src/modules/class/entity/testing/class-source-options.entity.spec.ts index 0b2d6d1dbc9..13cc083b162 100644 --- a/apps/server/src/modules/class/entity/testing/class-source-options.entity.spec.ts +++ b/apps/server/src/modules/class/entity/testing/class-source-options.entity.spec.ts @@ -1,3 +1,5 @@ +import { ClassSourceOptionsEntity } from '../class-source-options.entity'; + describe(ClassSourceOptionsEntity.name, () => { describe('constructor', () => { describe('When a contructor is called', () => { diff --git a/apps/server/src/modules/files-storage-client/dto/copy-file.dto.spec.ts b/apps/server/src/modules/files-storage-client/dto/copy-file.dto.spec.ts index b633f6a96e7..3c556a66c37 100644 --- a/apps/server/src/modules/files-storage-client/dto/copy-file.dto.spec.ts +++ b/apps/server/src/modules/files-storage-client/dto/copy-file.dto.spec.ts @@ -1,3 +1,5 @@ +import { CopyFileDto } from './copy-file.dto'; + describe('CopyFileDto', () => { it('Should create well formed copy file dto.', () => { const id = 'id123'; diff --git a/apps/server/src/modules/files-storage-client/dto/file.dto.spec.ts b/apps/server/src/modules/files-storage-client/dto/file.dto.spec.ts index 6c5b15ce9d0..12df06314c2 100644 --- a/apps/server/src/modules/files-storage-client/dto/file.dto.spec.ts +++ b/apps/server/src/modules/files-storage-client/dto/file.dto.spec.ts @@ -1,3 +1,6 @@ +import { FileRecordParentType } from '@shared/infra/rabbitmq/exchange/files-storage'; +import { FileDto } from './file.dto'; + describe('FileDto', () => { it('Should create well formed file dto.', () => { const id = 'id123'; diff --git a/apps/server/src/modules/files-storage-client/mapper/copy-files-of-parent-param.builder.spec.ts b/apps/server/src/modules/files-storage-client/mapper/copy-files-of-parent-param.builder.spec.ts index 8f381891408..4ddfbaa0250 100644 --- a/apps/server/src/modules/files-storage-client/mapper/copy-files-of-parent-param.builder.spec.ts +++ b/apps/server/src/modules/files-storage-client/mapper/copy-files-of-parent-param.builder.spec.ts @@ -1,4 +1,10 @@ import { ObjectId } from '@mikro-orm/mongodb'; +import { FileRecordParentType } from '@shared/infra/rabbitmq/exchange/files-storage'; +import { lessonFactory } from '@shared/testing/factory/lesson.factory'; +import { taskFactory } from '@shared/testing/factory/task.factory'; +import { setupEntities } from '@shared/testing/setup-entities'; +import { CopyFilesOfParentParamBuilder } from './copy-files-of-parent-param.builder'; +import { FileParamBuilder } from './files-storage-param.builder'; describe('CopyFilesOfParentParamBuilder', () => { beforeAll(async () => { diff --git a/apps/server/src/modules/files-storage-client/mapper/files-storage-client.mapper.spec.ts b/apps/server/src/modules/files-storage-client/mapper/files-storage-client.mapper.spec.ts index a9dfed005ff..d8478b0d7ef 100644 --- a/apps/server/src/modules/files-storage-client/mapper/files-storage-client.mapper.spec.ts +++ b/apps/server/src/modules/files-storage-client/mapper/files-storage-client.mapper.spec.ts @@ -1,3 +1,8 @@ +import { FileRecordParentType } from '@shared/infra/rabbitmq/exchange/files-storage'; +import { ICopyFileDomainObjectProps } from '../interfaces/copy-file-domain-object-props'; +import { IFileDomainObjectProps } from '../interfaces/file-domain-object-props'; +import { FilesStorageClientMapper } from './files-storage-client.mapper'; + describe('FilesStorageClientMapper', () => { describe('fileDto mapper', () => { const record = { diff --git a/apps/server/src/modules/files-storage-client/mapper/files-storage-param.builder.spec.ts b/apps/server/src/modules/files-storage-client/mapper/files-storage-param.builder.spec.ts index 86bcc2e7212..c9b6404a2c1 100644 --- a/apps/server/src/modules/files-storage-client/mapper/files-storage-param.builder.spec.ts +++ b/apps/server/src/modules/files-storage-client/mapper/files-storage-param.builder.spec.ts @@ -1,3 +1,9 @@ +import { FileRecordParentType } from '@shared/infra/rabbitmq/exchange/files-storage'; +import { lessonFactory } from '@shared/testing/factory/lesson.factory'; +import { taskFactory } from '@shared/testing/factory/task.factory'; +import { setupEntities } from '@shared/testing/setup-entities'; +import { FileParamBuilder } from './files-storage-param.builder'; + describe('FileParamBuilder', () => { beforeAll(async () => { await setupEntities(); diff --git a/apps/server/src/modules/files-storage-client/service/files-storage-client.service.spec.ts b/apps/server/src/modules/files-storage-client/service/files-storage-client.service.spec.ts index f186f4ce758..f640083ab6b 100644 --- a/apps/server/src/modules/files-storage-client/service/files-storage-client.service.spec.ts +++ b/apps/server/src/modules/files-storage-client/service/files-storage-client.service.spec.ts @@ -1,6 +1,15 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; +import { schoolFactory } from '@shared/testing/factory/school.factory'; +import { taskFactory } from '@shared/testing/factory/task.factory'; +import { setupEntities } from '@shared/testing/setup-entities'; +import { LegacyLogger } from '@src/core/logger/legacy-logger.service'; +import { CopyFilesOfParentParamBuilder } from '../mapper/copy-files-of-parent-param.builder'; +import { FilesStorageClientMapper } from '../mapper/files-storage-client.mapper'; +import { FileParamBuilder } from '../mapper/files-storage-param.builder'; +import { FilesStorageClientAdapterService } from './files-storage-client.service'; +import { FilesStorageProducer } from './files-storage.producer'; describe('FilesStorageClientAdapterService', () => { let module: TestingModule; diff --git a/apps/server/src/modules/files-storage-client/service/files-storage.producer.spec.ts b/apps/server/src/modules/files-storage-client/service/files-storage.producer.spec.ts index 8e026e84457..924b2bf8836 100644 --- a/apps/server/src/modules/files-storage-client/service/files-storage.producer.spec.ts +++ b/apps/server/src/modules/files-storage-client/service/files-storage.producer.spec.ts @@ -3,6 +3,15 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { ObjectId } from '@mikro-orm/mongodb'; import { ConfigService } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; +import { + FileRecordParentType, + FilesStorageExchange, + FilesStorageEvents, +} from '@shared/infra/rabbitmq/exchange/files-storage'; +import { setupEntities } from '@shared/testing/setup-entities'; +import { LegacyLogger } from '@src/core/logger/legacy-logger.service'; +import { ErrorMapper } from '../mapper/error.mapper'; +import { FilesStorageProducer } from './files-storage.producer'; describe('FilesStorageProducer', () => { let module: TestingModule; diff --git a/apps/server/src/modules/files-storage/service/files-storage-download.service.spec.ts b/apps/server/src/modules/files-storage/service/files-storage-download.service.spec.ts index 17608d71cf3..c450b34daf7 100644 --- a/apps/server/src/modules/files-storage/service/files-storage-download.service.spec.ts +++ b/apps/server/src/modules/files-storage/service/files-storage-download.service.spec.ts @@ -4,6 +4,7 @@ import { NotAcceptableException, NotFoundException } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; import { AntivirusService } from '@shared/infra/antivirus/antivirus.service'; +import { GetFile } from '@shared/infra/s3-client/interfaces'; import { S3ClientAdapter } from '@shared/infra/s3-client/s3-client.adapter'; import { fileRecordFactory } from '@shared/testing/factory/filerecord.factory'; import { setupEntities } from '@shared/testing/setup-entities'; diff --git a/apps/server/src/modules/h5p-editor/controller/api-test/h5p-editor.api.spec.ts b/apps/server/src/modules/h5p-editor/controller/api-test/h5p-editor.api.spec.ts index 72eb769eed0..8149a3ebdc6 100644 --- a/apps/server/src/modules/h5p-editor/controller/api-test/h5p-editor.api.spec.ts +++ b/apps/server/src/modules/h5p-editor/controller/api-test/h5p-editor.api.spec.ts @@ -1,6 +1,9 @@ import { EntityManager } from '@mikro-orm/core'; import { HttpStatus, INestApplication } from '@nestjs/common'; import { Test } from '@nestjs/testing'; +import { UserAndAccountTestFactory } from '@shared/testing/factory/user-and-account.test.factory'; +import { TestApiClient } from '@shared/testing/test-api-client'; +import { H5PEditorTestModule } from '../../h5p-editor-test.module'; describe('H5PEditor Controller (api)', () => { let app: INestApplication; diff --git a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-file-builder.spec.ts b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-file-builder.spec.ts index d86a77095fb..81c4b338f8f 100644 --- a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-file-builder.spec.ts +++ b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-file-builder.spec.ts @@ -1,5 +1,9 @@ import AdmZip from 'adm-zip'; import { parseStringPromise } from 'xml2js'; +import { CommonCartridgeVersion, CommonCartridgeResourceType } from './common-cartridge-enums'; +import { ICommonCartridgeFileBuilderOptions, CommonCartridgeFileBuilder } from './common-cartridge-file-builder'; +import { ICommonCartridgeOrganizationProps } from './common-cartridge-organization-item-element'; +import { ICommonCartridgeResourceProps } from './common-cartridge-resource-item-element'; describe('CommonCartridgeFileBuilder', () => { let archive: AdmZip; diff --git a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-lti-resource.spec.ts b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-lti-resource.spec.ts index bf69d0eec9f..8e58f76589f 100644 --- a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-lti-resource.spec.ts +++ b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-lti-resource.spec.ts @@ -1,4 +1,6 @@ import { Builder } from 'xml2js'; +import { CommonCartridgeResourceType, CommonCartridgeVersion } from './common-cartridge-enums'; +import { ICommonCartridgeLtiResourceProps, CommonCartridgeLtiResource } from './common-cartridge-lti-resource'; describe('CommonCartridgeLtiResource', () => { const propsVersion1: ICommonCartridgeLtiResourceProps = { diff --git a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-manifest-element.spec.ts b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-manifest-element.spec.ts index 634d433ac83..475f31ee93b 100644 --- a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-manifest-element.spec.ts +++ b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-manifest-element.spec.ts @@ -1,3 +1,7 @@ +import { CommonCartridgeVersion } from './common-cartridge-enums'; +import { CommonCartridgeManifestElement } from './common-cartridge-manifest-element'; +import { ICommonCartridgeMetadataProps } from './common-cartridge-metadata-element'; + describe('CommonCartridgeManifestElement', () => { const metadataPropsV3: ICommonCartridgeMetadataProps = { version: CommonCartridgeVersion.V_1_3_0, diff --git a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-metadata-element.spec.ts b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-metadata-element.spec.ts index fb8882a0235..9c5a0fb428a 100644 --- a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-metadata-element.spec.ts +++ b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-metadata-element.spec.ts @@ -1,3 +1,6 @@ +import { CommonCartridgeVersion } from './common-cartridge-enums'; +import { ICommonCartridgeMetadataProps, CommonCartridgeMetadataElement } from './common-cartridge-metadata-element'; + describe('CommonCartridgeMetadataElement', () => { describe('transform', () => { it('should return correct metadata regardless of common cartridge version', () => { diff --git a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-organization-wrapper-element.spec.ts b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-organization-wrapper-element.spec.ts index b35fdb3fdbb..6f3e08793af 100644 --- a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-organization-wrapper-element.spec.ts +++ b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-organization-wrapper-element.spec.ts @@ -1,3 +1,6 @@ +import { ICommonCartridgeElement } from './common-cartridge-element.interface'; +import { CommonCartridgeOrganizationWrapperElement } from './common-cartridge-organization-wrapper-element'; + describe('CommonCartridgeOrganizationWrapperElement', () => { it('should transform the organization elements into the expected structure', () => { const organizationElementsMock: ICommonCartridgeElement[] = [ diff --git a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-resource-wrapper-element.spec.ts b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-resource-wrapper-element.spec.ts index d33b3d3e702..8e267b33b11 100644 --- a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-resource-wrapper-element.spec.ts +++ b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-resource-wrapper-element.spec.ts @@ -1,3 +1,6 @@ +import { ICommonCartridgeElement } from './common-cartridge-element.interface'; +import { CommonCartridgeResourceWrapperElement } from './common-cartridge-resource-wrapper-element'; + describe('CommonCartridgeResourceWrapperElement', () => { it('should transform the resource elements into an array of transformed objects', () => { const resourceElementsMock: ICommonCartridgeElement[] = [ diff --git a/apps/server/src/modules/learnroom/controller/api-test/course.api.spec.ts b/apps/server/src/modules/learnroom/controller/api-test/course.api.spec.ts index fb7aacd12b1..d55a2ee1123 100644 --- a/apps/server/src/modules/learnroom/controller/api-test/course.api.spec.ts +++ b/apps/server/src/modules/learnroom/controller/api-test/course.api.spec.ts @@ -1,6 +1,13 @@ import { EntityManager } from '@mikro-orm/mongodb'; import { INestApplication, StreamableFile } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; +import { Permission } from '@shared/domain/interface/permission.enum'; +import { cleanupCollections } from '@shared/testing/cleanup-collections'; +import { courseFactory } from '@shared/testing/factory/course.factory'; +import { UserAndAccountTestFactory } from '@shared/testing/factory/user-and-account.test.factory'; +import { TestApiClient } from '@shared/testing/test-api-client'; +import { ServerTestModule } from '@src/modules/server/server.module'; +import { CourseMetadataListResponse } from '../dto/course-metadata.response'; const createStudent = () => { const { studentUser, studentAccount } = UserAndAccountTestFactory.buildStudent({}, [Permission.COURSE_VIEW]); diff --git a/apps/server/src/modules/learnroom/controller/api-test/dashboard.api.spec.ts b/apps/server/src/modules/learnroom/controller/api-test/dashboard.api.spec.ts index 5ba9822d557..7733a891122 100644 --- a/apps/server/src/modules/learnroom/controller/api-test/dashboard.api.spec.ts +++ b/apps/server/src/modules/learnroom/controller/api-test/dashboard.api.spec.ts @@ -1,9 +1,21 @@ import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; - +import { DashboardEntity, GridElement } from '@shared/domain/entity/dashboard.entity'; +import { User } from '@shared/domain/entity/user.entity'; +import { Permission } from '@shared/domain/interface/permission.enum'; +import { RoleName } from '@shared/domain/interface/rolename.enum'; +import { IDashboardRepo } from '@shared/repo/dashboard/dashboard.repo'; +import { courseFactory } from '@shared/testing/factory/course.factory'; +import { roleFactory } from '@shared/testing/factory/role.factory'; +import { userFactory } from '@shared/testing/factory/user.factory'; +import { mapUserToCurrentUser } from '@shared/testing/map-user-to-current-user'; +import { JwtAuthGuard } from '@src/modules/authentication/guard/jwt-auth.guard'; +import { ICurrentUser } from '@src/modules/authentication/interface/user'; +import { ServerTestModule } from '@src/modules/server/server.module'; import { Request } from 'express'; import request from 'supertest'; +import { DashboardResponse } from '../dto/dashboard.response'; describe('Dashboard Controller (API)', () => { let app: INestApplication; diff --git a/apps/server/src/modules/learnroom/controller/api-test/rooms-copy-timeout.api.spec.ts b/apps/server/src/modules/learnroom/controller/api-test/rooms-copy-timeout.api.spec.ts index b3798993d97..d63bfbbcd68 100644 --- a/apps/server/src/modules/learnroom/controller/api-test/rooms-copy-timeout.api.spec.ts +++ b/apps/server/src/modules/learnroom/controller/api-test/rooms-copy-timeout.api.spec.ts @@ -12,14 +12,13 @@ import { userFactory } from '@shared/testing/factory/user.factory'; import { mapUserToCurrentUser } from '@shared/testing/map-user-to-current-user'; import { JwtAuthGuard } from '@src/modules/authentication/guard/jwt-auth.guard'; import { ICurrentUser } from '@src/modules/authentication/interface/user'; -import { ServerTestModule } from '@src/modules/server/server.module'; - import { Request } from 'express'; import request from 'supertest'; Configuration.set('FEATURE_COPY_SERVICE_ENABLED', true); Configuration.set('INCOMING_REQUEST_TIMEOUT_COPY_API', 1); // eslint-disable-next-line import/first +import { ServerTestModule } from '@src/modules/server/server.module'; // This needs to be in a separate test file because of the above configuration. // When we find a way to mock the config, it should be moved alongside the other API tests. diff --git a/apps/server/src/modules/learnroom/controller/rooms.controller.spec.ts b/apps/server/src/modules/learnroom/controller/rooms.controller.spec.ts index be4ee995859..134e033ea95 100644 --- a/apps/server/src/modules/learnroom/controller/rooms.controller.spec.ts +++ b/apps/server/src/modules/learnroom/controller/rooms.controller.spec.ts @@ -1,5 +1,16 @@ import { createMock } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; +import { EntityId } from '@shared/domain/types/entity-id'; +import { ICurrentUser } from '@src/modules/authentication/interface/user'; +import { CopyApiResponse } from '@src/modules/copy-helper/dto/copy.response'; +import { CopyElementType, CopyStatusEnum, CopyStatus } from '@src/modules/copy-helper/types/copy.types'; +import { RoomBoardResponseMapper } from '../mapper/room-board-response.mapper'; +import { RoomBoardDTO } from '../types/room-board.types'; +import { CourseCopyUC } from '../uc/course-copy.uc'; +import { LessonCopyUC } from '../uc/lesson-copy.uc'; +import { RoomsUc } from '../uc/rooms.uc'; +import { SingleColumnBoardResponse } from './dto/single-column-board/board.response'; +import { RoomsController } from './rooms.controller'; describe('rooms controller', () => { let controller: RoomsController; diff --git a/apps/server/src/modules/learnroom/mapper/room-board-response.mapper.spec.ts b/apps/server/src/modules/learnroom/mapper/room-board-response.mapper.spec.ts index 1021e6c9e80..24b05054ad5 100644 --- a/apps/server/src/modules/learnroom/mapper/room-board-response.mapper.spec.ts +++ b/apps/server/src/modules/learnroom/mapper/room-board-response.mapper.spec.ts @@ -1,6 +1,13 @@ import { Test, TestingModule } from '@nestjs/testing'; +import { courseFactory } from '@shared/testing/factory/course.factory'; +import { taskFactory } from '@shared/testing/factory/task.factory'; +import { setupEntities } from '@shared/testing/setup-entities'; import { ObjectId } from 'bson'; +import { BoardElementResponse } from '../controller/dto/single-column-board/board-element.response'; +import { SingleColumnBoardResponse } from '../controller/dto/single-column-board/board.response'; +import { RoomBoardElementTypes } from '../types/room-board.types'; +import { RoomBoardResponseMapper } from './room-board-response.mapper'; describe('room board response mapper', () => { let mapper: RoomBoardResponseMapper; diff --git a/apps/server/src/modules/learnroom/service/column-board-target.service.spec.ts b/apps/server/src/modules/learnroom/service/column-board-target.service.spec.ts index 9d8b271907f..4b08f1e5a32 100644 --- a/apps/server/src/modules/learnroom/service/column-board-target.service.spec.ts +++ b/apps/server/src/modules/learnroom/service/column-board-target.service.spec.ts @@ -1,6 +1,12 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; +import { ColumnBoardTarget } from '@shared/domain/entity/legacy-board/column-board-target.entity'; +import { MongoMemoryDatabaseModule } from '@shared/infra/database/mongo-memory-database/mongo-memory-database.module'; +import { cleanupCollections } from '@shared/testing/cleanup-collections'; +import { columnBoardTargetFactory } from '@shared/testing/factory/boardelement.factory'; +import { ColumnBoardService } from '@src/modules/board/service/column-board.service'; +import { ColumnBoardTargetService } from './column-board-target.service'; describe(ColumnBoardTargetService.name, () => { let module: TestingModule; diff --git a/apps/server/src/modules/learnroom/service/course.service.spec.ts b/apps/server/src/modules/learnroom/service/course.service.spec.ts index 5969395a5ee..6fc8a2c7ba6 100644 --- a/apps/server/src/modules/learnroom/service/course.service.spec.ts +++ b/apps/server/src/modules/learnroom/service/course.service.spec.ts @@ -1,5 +1,12 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; +import { Course } from '@shared/domain/entity/course.entity'; +import { CourseRepo } from '@shared/repo/course/course.repo'; +import { UserRepo } from '@shared/repo/user/user.repo'; +import { courseFactory } from '@shared/testing/factory/course.factory'; +import { userFactory } from '@shared/testing/factory/user.factory'; +import { setupEntities } from '@shared/testing/setup-entities'; +import { CourseService } from './course.service'; describe('CourseService', () => { let module: TestingModule; diff --git a/apps/server/src/modules/learnroom/service/coursegroup.service.spec.ts b/apps/server/src/modules/learnroom/service/coursegroup.service.spec.ts index 2677a68c6a4..909dbe43bb1 100644 --- a/apps/server/src/modules/learnroom/service/coursegroup.service.spec.ts +++ b/apps/server/src/modules/learnroom/service/coursegroup.service.spec.ts @@ -1,5 +1,11 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; +import { CourseGroupRepo } from '@shared/repo/coursegroup/coursegroup.repo'; +import { UserRepo } from '@shared/repo/user/user.repo'; +import { courseGroupFactory } from '@shared/testing/factory/coursegroup.factory'; +import { userFactory } from '@shared/testing/factory/user.factory'; +import { setupEntities } from '@shared/testing/setup-entities'; +import { CourseGroupService } from './coursegroup.service'; describe('CourseGroupService', () => { let module: TestingModule; diff --git a/apps/server/src/modules/learnroom/service/rooms.service.spec.ts b/apps/server/src/modules/learnroom/service/rooms.service.spec.ts index dc6f80a618f..7d7fa1223bf 100644 --- a/apps/server/src/modules/learnroom/service/rooms.service.spec.ts +++ b/apps/server/src/modules/learnroom/service/rooms.service.spec.ts @@ -3,6 +3,26 @@ import { Configuration } from '@hpi-schul-cloud/commons/lib'; import { IConfig } from '@hpi-schul-cloud/commons/lib/interfaces/IConfig'; import { ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; +import { + BoardExternalReference, + BoardExternalReferenceType, +} from '@shared/domain/domainobject/board/types/board-external-reference'; +import { EntityId } from '@shared/domain/types/entity-id'; +import { BoardRepo } from '@shared/repo/board/board.repo'; +import { LessonRepo } from '@shared/repo/lesson/lesson.repo'; +import { boardFactory } from '@shared/testing/factory/board.factory'; +import { courseFactory } from '@shared/testing/factory/course.factory'; +import { lessonFactory } from '@shared/testing/factory/lesson.factory'; +import { taskFactory } from '@shared/testing/factory/task.factory'; +import { userFactory } from '@shared/testing/factory/user.factory'; +import { setupEntities } from '@shared/testing/setup-entities'; +import { CardService } from '@src/modules/board/service/card.service'; +import { ColumnBoardService } from '@src/modules/board/service/column-board.service'; +import { ColumnService } from '@src/modules/board/service/column.service'; +import { ContentElementService } from '@src/modules/board/service/content-element.service'; +import { TaskService } from '@src/modules/task/service/task.service'; +import { ColumnBoardTargetService } from './column-board-target.service'; +import { RoomsService } from './rooms.service'; describe('rooms service', () => { let module: TestingModule; diff --git a/apps/server/src/modules/learnroom/uc/course-copy.uc.spec.ts b/apps/server/src/modules/learnroom/uc/course-copy.uc.spec.ts index a9b1c3feb06..7e676084436 100644 --- a/apps/server/src/modules/learnroom/uc/course-copy.uc.spec.ts +++ b/apps/server/src/modules/learnroom/uc/course-copy.uc.spec.ts @@ -2,6 +2,17 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Configuration } from '@hpi-schul-cloud/commons'; import { ForbiddenException, InternalServerErrorException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; +import { Permission } from '@shared/domain/interface/permission.enum'; +import { boardFactory } from '@shared/testing/factory/board.factory'; +import { courseFactory } from '@shared/testing/factory/course.factory'; +import { userFactory } from '@shared/testing/factory/user.factory'; +import { setupEntities } from '@shared/testing/setup-entities'; +import { AuthorizationService } from '@src/modules/authorization/authorization.service'; +import { Action } from '@src/modules/authorization/types/action.enum'; +import { AuthorizableReferenceType } from '@src/modules/authorization/types/allowed-authorization-object-type.enum'; +import { CopyElementType, CopyStatusEnum } from '@src/modules/copy-helper/types/copy.types'; +import { CourseCopyService } from '../service/course-copy.service'; +import { CourseCopyUC } from './course-copy.uc'; describe('course copy uc', () => { let module: TestingModule; diff --git a/apps/server/src/modules/learnroom/uc/course-export.uc.spec.ts b/apps/server/src/modules/learnroom/uc/course-export.uc.spec.ts index 69507b7d10d..69940bdb0e8 100644 --- a/apps/server/src/modules/learnroom/uc/course-export.uc.spec.ts +++ b/apps/server/src/modules/learnroom/uc/course-export.uc.spec.ts @@ -1,5 +1,9 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; +import { AuthorizationService } from '@src/modules/authorization/authorization.service'; +import { CommonCartridgeVersion } from '../common-cartridge/common-cartridge-enums'; +import { CommonCartridgeExportService } from '../service/common-cartridge-export.service'; +import { CourseExportUc } from './course-export.uc'; describe('CourseExportUc', () => { let module: TestingModule; diff --git a/apps/server/src/modules/learnroom/uc/course.uc.spec.ts b/apps/server/src/modules/learnroom/uc/course.uc.spec.ts index 7b52da6a6a6..67c3030d22b 100644 --- a/apps/server/src/modules/learnroom/uc/course.uc.spec.ts +++ b/apps/server/src/modules/learnroom/uc/course.uc.spec.ts @@ -1,5 +1,11 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; +import { SortOrder } from '@shared/domain/interface/find-options'; +import { CourseRepo } from '@shared/repo/course/course.repo'; +import { LessonRepo } from '@shared/repo/lesson/lesson.repo'; +import { courseFactory } from '@shared/testing/factory/course.factory'; +import { setupEntities } from '@shared/testing/setup-entities'; +import { CourseUc } from './course.uc'; describe('CourseUc', () => { let module: TestingModule; diff --git a/apps/server/src/modules/learnroom/uc/lesson-copy.uc.spec.ts b/apps/server/src/modules/learnroom/uc/lesson-copy.uc.spec.ts index 467d6cea1e5..0fcb0287aab 100644 --- a/apps/server/src/modules/learnroom/uc/lesson-copy.uc.spec.ts +++ b/apps/server/src/modules/learnroom/uc/lesson-copy.uc.spec.ts @@ -3,6 +3,25 @@ import { Configuration } from '@hpi-schul-cloud/commons'; import { ObjectId } from '@mikro-orm/mongodb'; import { ForbiddenException, InternalServerErrorException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; +import { AuthorizableObject } from '@shared/domain/domain-object'; +import { BaseDO } from '@shared/domain/domainobject/base.do'; +import { User } from '@shared/domain/entity/user.entity'; +import { Permission } from '@shared/domain/interface/permission.enum'; +import { CourseRepo } from '@shared/repo/course/course.repo'; +import { LessonRepo } from '@shared/repo/lesson/lesson.repo'; +import { UserRepo } from '@shared/repo/user/user.repo'; +import { courseFactory } from '@shared/testing/factory/course.factory'; +import { lessonFactory } from '@shared/testing/factory/lesson.factory'; +import { userFactory } from '@shared/testing/factory/user.factory'; +import { setupEntities } from '@shared/testing/setup-entities'; +import { AuthorizationService } from '@src/modules/authorization/authorization.service'; +import { Action } from '@src/modules/authorization/types/action.enum'; +import { AuthorizableReferenceType } from '@src/modules/authorization/types/allowed-authorization-object-type.enum'; +import { CopyHelperService } from '@src/modules/copy-helper/service/copy-helper.service'; +import { CopyElementType, CopyStatusEnum } from '@src/modules/copy-helper/types/copy.types'; +import { EtherpadService } from '@src/modules/lesson/service/etherpad.service'; +import { LessonCopyService } from '@src/modules/lesson/service/lesson-copy.service'; +import { LessonCopyUC } from './lesson-copy.uc'; describe('lesson copy uc', () => { let module: TestingModule; diff --git a/apps/server/src/modules/learnroom/uc/rooms.authorisation.service.spec.ts b/apps/server/src/modules/learnroom/uc/rooms.authorisation.service.spec.ts index 4a2d2fb3313..79a341337a8 100644 --- a/apps/server/src/modules/learnroom/uc/rooms.authorisation.service.spec.ts +++ b/apps/server/src/modules/learnroom/uc/rooms.authorisation.service.spec.ts @@ -1,5 +1,11 @@ import { NotImplementedException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; +import { courseFactory } from '@shared/testing/factory/course.factory'; +import { lessonFactory } from '@shared/testing/factory/lesson.factory'; +import { taskFactory } from '@shared/testing/factory/task.factory'; +import { userFactory } from '@shared/testing/factory/user.factory'; +import { setupEntities } from '@shared/testing/setup-entities'; +import { RoomsAuthorisationService } from './rooms.authorisation.service'; describe('rooms authorisation service', () => { let module: TestingModule; diff --git a/apps/server/src/modules/learnroom/uc/rooms.uc.spec.ts b/apps/server/src/modules/learnroom/uc/rooms.uc.spec.ts index 2722b778991..02c8e056aec 100644 --- a/apps/server/src/modules/learnroom/uc/rooms.uc.spec.ts +++ b/apps/server/src/modules/learnroom/uc/rooms.uc.spec.ts @@ -1,6 +1,21 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { ForbiddenException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; +import { BoardRepo } from '@shared/repo/board/board.repo'; +import { CourseRepo } from '@shared/repo/course/course.repo'; +import { LessonRepo } from '@shared/repo/lesson/lesson.repo'; +import { TaskRepo } from '@shared/repo/task/task.repo'; +import { UserRepo } from '@shared/repo/user/user.repo'; +import { boardFactory } from '@shared/testing/factory/board.factory'; +import { courseFactory } from '@shared/testing/factory/course.factory'; +import { lessonFactory } from '@shared/testing/factory/lesson.factory'; +import { taskFactory } from '@shared/testing/factory/task.factory'; +import { userFactory } from '@shared/testing/factory/user.factory'; +import { setupEntities } from '@shared/testing/setup-entities'; +import { RoomsService } from '../service/rooms.service'; +import { RoomBoardDTOFactory } from './room-board-dto.factory'; +import { RoomsAuthorisationService } from './rooms.authorisation.service'; +import { RoomsUc } from './rooms.uc'; describe('rooms usecase', () => { let uc: RoomsUc; diff --git a/apps/server/src/modules/lesson/service/lesson-copy.service.spec.ts b/apps/server/src/modules/lesson/service/lesson-copy.service.spec.ts index 9d8082a4707..4596fa65818 100644 --- a/apps/server/src/modules/lesson/service/lesson-copy.service.spec.ts +++ b/apps/server/src/modules/lesson/service/lesson-copy.service.spec.ts @@ -1,8 +1,8 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Configuration } from '@hpi-schul-cloud/commons'; -import { BaseEntity } from '@mikro-orm/core'; import { Test, TestingModule } from '@nestjs/testing'; import { AuthorizableObject } from '@shared/domain/domain-object'; +import { BaseEntity } from '@shared/domain/entity/base.entity'; import { ComponentType, IComponentEtherpadProperties, diff --git a/apps/server/src/modules/management/console/board-management.console.spec.ts b/apps/server/src/modules/management/console/board-management.console.spec.ts index 52ef7239802..cb458411239 100644 --- a/apps/server/src/modules/management/console/board-management.console.spec.ts +++ b/apps/server/src/modules/management/console/board-management.console.spec.ts @@ -1,7 +1,9 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; - +import { ConsoleWriterService } from '@shared/infra/console/console-writer/console-writer.service'; import { ObjectId } from 'bson'; +import { BoardManagementUc } from '../uc/board-management.uc'; +import { BoardManagementConsole } from './board-management.console'; describe(BoardManagementConsole.name, () => { let service: BoardManagementConsole; diff --git a/apps/server/src/modules/management/console/database-management.console.spec.ts b/apps/server/src/modules/management/console/database-management.console.spec.ts index 148eb015680..d5e067c691b 100644 --- a/apps/server/src/modules/management/console/database-management.console.spec.ts +++ b/apps/server/src/modules/management/console/database-management.console.spec.ts @@ -1,5 +1,8 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; +import { ConsoleWriterService } from '@shared/infra/console/console-writer/console-writer.service'; +import { DatabaseManagementUc } from '../uc/database-management.uc'; +import { DatabaseManagementConsole } from './database-management.console'; describe('DatabaseManagementConsole', () => { let service: DatabaseManagementConsole; diff --git a/apps/server/src/modules/management/controller/api-test/database-management.api.spec.ts b/apps/server/src/modules/management/controller/api-test/database-management.api.spec.ts index 3b9a59380ea..68399d4a9d3 100644 --- a/apps/server/src/modules/management/controller/api-test/database-management.api.spec.ts +++ b/apps/server/src/modules/management/controller/api-test/database-management.api.spec.ts @@ -1,8 +1,8 @@ import { MikroORM } from '@mikro-orm/core'; import { INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; - import request from 'supertest'; +import { ManagementServerTestModule } from '../../management-server.module'; describe('Database Management Controller (API)', () => { let app: INestApplication; diff --git a/apps/server/src/modules/management/controller/database-management.controller.spec.ts b/apps/server/src/modules/management/controller/database-management.controller.spec.ts index 97eeaa892ef..e2461abd5c5 100644 --- a/apps/server/src/modules/management/controller/database-management.controller.spec.ts +++ b/apps/server/src/modules/management/controller/database-management.controller.spec.ts @@ -1,4 +1,6 @@ import { Test, TestingModule } from '@nestjs/testing'; +import { DatabaseManagementUc } from '../uc/database-management.uc'; +import { DatabaseManagementController } from './database-management.controller'; describe('DatabaseManagementController', () => { let controller: DatabaseManagementController; diff --git a/apps/server/src/modules/management/converter/bson.converter.spec.ts b/apps/server/src/modules/management/converter/bson.converter.spec.ts index 7b8a602cda2..dd9d09e0b7b 100644 --- a/apps/server/src/modules/management/converter/bson.converter.spec.ts +++ b/apps/server/src/modules/management/converter/bson.converter.spec.ts @@ -1,5 +1,6 @@ import { Test, TestingModule } from '@nestjs/testing'; import { ObjectId } from 'bson'; +import { BsonConverter } from './bson.converter'; describe('BsonConverter', () => { let converter: BsonConverter; diff --git a/apps/server/src/modules/management/management.module.spec.ts b/apps/server/src/modules/management/management.module.spec.ts index 04ab454d230..12aeb23406d 100644 --- a/apps/server/src/modules/management/management.module.spec.ts +++ b/apps/server/src/modules/management/management.module.spec.ts @@ -1,4 +1,7 @@ import { Test, TestingModule } from '@nestjs/testing'; +import { DatabaseManagementController } from './controller/database-management.controller'; +import { ManagementServerModule, ManagementServerTestModule } from './management-server.module'; +import { DatabaseManagementUc } from './uc/database-management.uc'; describe('ManagementModule', () => { let module: TestingModule; diff --git a/apps/server/src/modules/management/seed-data/generateSeedData.spec.ts b/apps/server/src/modules/management/seed-data/generateSeedData.spec.ts index 0e865d24cc1..33173cb7792 100644 --- a/apps/server/src/modules/management/seed-data/generateSeedData.spec.ts +++ b/apps/server/src/modules/management/seed-data/generateSeedData.spec.ts @@ -1,3 +1,5 @@ +import { setupEntities } from '@shared/testing/setup-entities'; +import { generateSeedData } from './generateSeedData'; import * as roleModule from './roles'; describe('Seed Data generation', () => { diff --git a/apps/server/src/modules/management/seed-data/roles.spec.ts b/apps/server/src/modules/management/seed-data/roles.spec.ts index c2753ffb101..bf2c2858036 100644 --- a/apps/server/src/modules/management/seed-data/roles.spec.ts +++ b/apps/server/src/modules/management/seed-data/roles.spec.ts @@ -1,3 +1,5 @@ +import { RoleName } from '@shared/domain/interface/rolename.enum'; +import { setupEntities } from '@shared/testing/setup-entities'; import * as roleModule from './roles'; describe('Role seed data generation', () => { diff --git a/apps/server/src/modules/news/controller/api-test/news.api.spec.ts b/apps/server/src/modules/news/controller/api-test/news.api.spec.ts index 57dfb895db7..12fe62045cc 100644 --- a/apps/server/src/modules/news/controller/api-test/news.api.spec.ts +++ b/apps/server/src/modules/news/controller/api-test/news.api.spec.ts @@ -1,10 +1,19 @@ import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; - +import { News } from '@shared/domain/entity/news.entity'; +import { EntityId } from '@shared/domain/types/entity-id'; +import { NewsTargetModel } from '@shared/domain/types/news.types'; +import { API_VALIDATION_ERROR_TYPE } from '@src/core/error/server-error-types'; +import { JwtAuthGuard } from '@src/modules/authentication/guard/jwt-auth.guard'; +import { FeathersAuthorizationService } from '@src/modules/authorization/feathers/feathers-authorization.service'; +import { ServerTestModule } from '@src/modules/server/server.module'; import { Request } from 'express'; import moment from 'moment'; import request from 'supertest'; +import { CreateNewsParams } from '../dto/create-news.params'; +import { NewsListResponse, NewsResponse } from '../dto/news.response'; +import { UpdateNewsParams } from '../dto/update-news.params'; describe('News Controller (API)', () => { let app: INestApplication; diff --git a/apps/server/src/modules/news/uc/news.uc.spec.ts b/apps/server/src/modules/news/uc/news.uc.spec.ts index e09395b8eb2..83f49e2809c 100644 --- a/apps/server/src/modules/news/uc/news.uc.spec.ts +++ b/apps/server/src/modules/news/uc/news.uc.spec.ts @@ -3,6 +3,12 @@ import { ObjectId } from '@mikro-orm/mongodb'; import { UnauthorizedException } from '@nestjs/common'; import { NotFoundException } from '@nestjs/common/exceptions/not-found.exception'; import { Test, TestingModule } from '@nestjs/testing'; +import { Permission } from '@shared/domain/interface/permission.enum'; +import { ICreateNews, NewsTargetModel } from '@shared/domain/types/news.types'; +import { NewsRepo } from '@shared/repo/news/news.repo'; +import { Logger } from '@src/core/logger/logger'; +import { FeathersAuthorizationService } from '@src/modules/authorization/feathers/feathers-authorization.service'; +import { NewsUc } from './news.uc'; describe('NewsUc', () => { let module: TestingModule; diff --git a/apps/server/src/modules/oauth-provider/error/id-token-creation-exception.loggable.spec.ts b/apps/server/src/modules/oauth-provider/error/id-token-creation-exception.loggable.spec.ts index 23feb660fba..921049458e4 100644 --- a/apps/server/src/modules/oauth-provider/error/id-token-creation-exception.loggable.spec.ts +++ b/apps/server/src/modules/oauth-provider/error/id-token-creation-exception.loggable.spec.ts @@ -1,3 +1,5 @@ +import { IdTokenCreationLoggableException } from './id-token-creation-exception.loggable'; + describe('IdTokenCreationExceptionLoggable', () => { describe('constructor', () => { const setup = () => { diff --git a/apps/server/src/modules/oauth-provider/mapper/oauth-provider-request.mapper.spec.ts b/apps/server/src/modules/oauth-provider/mapper/oauth-provider-request.mapper.spec.ts index 861eda49bcc..97b338c7342 100644 --- a/apps/server/src/modules/oauth-provider/mapper/oauth-provider-request.mapper.spec.ts +++ b/apps/server/src/modules/oauth-provider/mapper/oauth-provider-request.mapper.spec.ts @@ -1,3 +1,7 @@ +import { AcceptLoginRequestBody } from '@shared/infra/oauth-provider/dto/request/accept-login-request.body'; +import { LoginRequestBody } from '../controller/dto/request/login-request.body'; +import { OauthProviderRequestMapper } from './oauth-provider-request.mapper'; + describe('OauthProviderRequestMapper', () => { describe('mapCreateAcceptLoginRequestBody', () => { it('should create the AcceptLoginRequestBody', () => { diff --git a/apps/server/src/modules/oauth-provider/service/id-token.service.spec.ts b/apps/server/src/modules/oauth-provider/service/id-token.service.spec.ts index 9e4c0cb15a0..3d7aadd4cb9 100644 --- a/apps/server/src/modules/oauth-provider/service/id-token.service.spec.ts +++ b/apps/server/src/modules/oauth-provider/service/id-token.service.spec.ts @@ -1,5 +1,22 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; +import { Pseudonym } from '@shared/domain/domainobject/pseudonym.do'; +import { UserDO } from '@shared/domain/domainobject/user.do'; +import { TeamEntity } from '@shared/domain/entity/team.entity'; +import { TeamsRepo } from '@shared/repo/teams/teams.repo'; +import { pseudonymFactory } from '@shared/testing/factory/domainobject/pseudonym.factory'; +import { externalToolFactory } from '@shared/testing/factory/domainobject/tool/external-tool.factory'; +import { teamFactory } from '@shared/testing/factory/team.factory'; +import { userDoFactory } from '@shared/testing/factory/user.do.factory'; +import { setupEntities } from '@shared/testing/setup-entities'; +import { PseudonymService } from '@src/modules/pseudonym/service/pseudonym.service'; +import { ExternalTool } from '@src/modules/tool/external-tool/domain/external-tool.do'; +import { UserService } from '@src/modules/user/service/user.service'; +import { IdTokenCreationLoggableException } from '../error/id-token-creation-exception.loggable'; +import { IdToken } from '../interface/id-token'; +import { OauthScope } from '../interface/oauth-scope.enum'; +import { IdTokenService } from './id-token.service'; +import { OauthProviderLoginFlowService } from './oauth-provider.login-flow.service'; import resetAllMocks = jest.resetAllMocks; diff --git a/apps/server/src/modules/oauth-provider/service/oauth-provider.login-flow.service.spec.ts b/apps/server/src/modules/oauth-provider/service/oauth-provider.login-flow.service.spec.ts index 59e1a5d9a39..d6429e2e14d 100644 --- a/apps/server/src/modules/oauth-provider/service/oauth-provider.login-flow.service.spec.ts +++ b/apps/server/src/modules/oauth-provider/service/oauth-provider.login-flow.service.spec.ts @@ -1,6 +1,15 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { NotFoundException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; +import { LtiToolDO } from '@shared/domain/domainobject/ltitool.do'; +import { ltiToolDOFactory } from '@shared/testing/factory/domainobject/lti-tool.factory'; +import { externalToolFactory } from '@shared/testing/factory/domainobject/tool/external-tool.factory'; +import { setupEntities } from '@shared/testing/setup-entities'; +import { LtiToolService } from '@src/modules/lti-tool/service/lti-tool.service'; +import { ExternalTool } from '@src/modules/tool/external-tool/domain/external-tool.do'; +import { ExternalToolService } from '@src/modules/tool/external-tool/service/external-tool.service'; +import { IToolFeatures, ToolFeatures } from '@src/modules/tool/tool-config'; +import { OauthProviderLoginFlowService } from './oauth-provider.login-flow.service'; describe('OauthProviderLoginFlowService', () => { let module: TestingModule; diff --git a/apps/server/src/modules/oauth-provider/uc/oauth-provider.client-crud.uc.spec.ts b/apps/server/src/modules/oauth-provider/uc/oauth-provider.client-crud.uc.spec.ts index c39a20d67f5..47cf8a31d04 100644 --- a/apps/server/src/modules/oauth-provider/uc/oauth-provider.client-crud.uc.spec.ts +++ b/apps/server/src/modules/oauth-provider/uc/oauth-provider.client-crud.uc.spec.ts @@ -1,6 +1,15 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { UnauthorizedException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; +import { User } from '@shared/domain/entity/user.entity'; +import { Permission } from '@shared/domain/interface/permission.enum'; +import { ProviderOauthClient } from '@shared/infra/oauth-provider/dto/interface/oauth-client.interface'; +import { OauthProviderService } from '@shared/infra/oauth-provider/oauth-provider.service'; +import { userFactory } from '@shared/testing/factory/user.factory'; +import { setupEntities } from '@shared/testing/setup-entities'; +import { ICurrentUser } from '@src/modules/authentication/interface/user'; +import { AuthorizationService } from '@src/modules/authorization/authorization.service'; +import { OauthProviderClientCrudUc } from './oauth-provider.client-crud.uc'; import resetAllMocks = jest.resetAllMocks; diff --git a/apps/server/src/modules/oauth-provider/uc/oauth-provider.logout-flow.uc.spec.ts b/apps/server/src/modules/oauth-provider/uc/oauth-provider.logout-flow.uc.spec.ts index 80bea7c811b..669a3b82767 100644 --- a/apps/server/src/modules/oauth-provider/uc/oauth-provider.logout-flow.uc.spec.ts +++ b/apps/server/src/modules/oauth-provider/uc/oauth-provider.logout-flow.uc.spec.ts @@ -1,6 +1,8 @@ import { Test, TestingModule } from '@nestjs/testing'; import { createMock, DeepMocked } from '@golevelup/ts-jest'; +import { OauthProviderService } from '@shared/infra/oauth-provider/oauth-provider.service'; +import { OauthProviderLogoutFlowUc } from './oauth-provider.logout-flow.uc'; describe('OauthProviderUc', () => { let module: TestingModule; diff --git a/apps/server/src/modules/oauth-provider/uc/oauth-provider.uc.spec.ts b/apps/server/src/modules/oauth-provider/uc/oauth-provider.uc.spec.ts index 8a4b204142b..82d9b2c084c 100644 --- a/apps/server/src/modules/oauth-provider/uc/oauth-provider.uc.spec.ts +++ b/apps/server/src/modules/oauth-provider/uc/oauth-provider.uc.spec.ts @@ -1,6 +1,9 @@ import { Test, TestingModule } from '@nestjs/testing'; import { createMock, DeepMocked } from '@golevelup/ts-jest'; +import { ProviderConsentSessionResponse } from '@shared/infra/oauth-provider/dto/response/consent-session.response'; +import { OauthProviderService } from '@shared/infra/oauth-provider/oauth-provider.service'; +import { OauthProviderUc } from './oauth-provider.uc'; describe('OauthProviderUc', () => { let module: TestingModule; diff --git a/apps/server/src/modules/oauth/mapper/token-request.mapper.spec.ts b/apps/server/src/modules/oauth/mapper/token-request.mapper.spec.ts index 128f954e5b5..016de71d0fa 100644 --- a/apps/server/src/modules/oauth/mapper/token-request.mapper.spec.ts +++ b/apps/server/src/modules/oauth/mapper/token-request.mapper.spec.ts @@ -1,3 +1,8 @@ +import { OAuthGrantType } from '../interface/oauth-grant-type.enum'; +import { OAuthTokenDto } from '../interface/oauth-token.dto'; +import { AuthenticationCodeGrantTokenRequest } from '../service/dto/authentication-code-grant-token.request'; +import { TokenRequestMapper } from './token-request.mapper'; + describe('TokenRequestMapper', () => { describe('createAuthenticationCodeGrantTokenRequestPayload', () => { it('should map the Payload to dto', () => { diff --git a/apps/server/src/modules/provisioning/loggable/group-role-unknown.loggable.spec.ts b/apps/server/src/modules/provisioning/loggable/group-role-unknown.loggable.spec.ts index 1c7172fc4b0..a1487e80fe4 100644 --- a/apps/server/src/modules/provisioning/loggable/group-role-unknown.loggable.spec.ts +++ b/apps/server/src/modules/provisioning/loggable/group-role-unknown.loggable.spec.ts @@ -1,3 +1,7 @@ +import { SanisGroupRole } from '../strategy/sanis/response/sanis-group-role'; +import { SanisSonstigeGruppenzugehoerigeResponse } from '../strategy/sanis/response/sanis-sonstige-gruppenzugehoerige-response'; +import { GroupRoleUnknownLoggable } from './group-role-unknown.loggable'; + describe('GroupRoleUnknownLoggable', () => { describe('constructor', () => { const setup = () => { diff --git a/apps/server/src/modules/provisioning/loggable/school-for-group-not-found.loggable.spec.ts b/apps/server/src/modules/provisioning/loggable/school-for-group-not-found.loggable.spec.ts index 5230943003e..9c76cda1e18 100644 --- a/apps/server/src/modules/provisioning/loggable/school-for-group-not-found.loggable.spec.ts +++ b/apps/server/src/modules/provisioning/loggable/school-for-group-not-found.loggable.spec.ts @@ -1,3 +1,7 @@ +import { externalGroupDtoFactory } from '@shared/testing/factory/external-group-dto.factory'; +import { ExternalGroupDto } from '../dto/external-group.dto'; +import { SchoolForGroupNotFoundLoggable } from './school-for-group-not-found.loggable'; + describe('SchoolForGroupNotFoundLoggable', () => { describe('constructor', () => { const setup = () => { diff --git a/apps/server/src/modules/provisioning/loggable/user-for-group-not-found.loggable.spec.ts b/apps/server/src/modules/provisioning/loggable/user-for-group-not-found.loggable.spec.ts index 3730559af99..b8a4ea7628c 100644 --- a/apps/server/src/modules/provisioning/loggable/user-for-group-not-found.loggable.spec.ts +++ b/apps/server/src/modules/provisioning/loggable/user-for-group-not-found.loggable.spec.ts @@ -1,3 +1,7 @@ +import { RoleName } from '@shared/domain/interface/rolename.enum'; +import { ExternalGroupUserDto } from '../dto/external-group-user.dto'; +import { UserForGroupNotFoundLoggable } from './user-for-group-not-found.loggable'; + describe('UserForGroupNotFoundLoggable', () => { describe('constructor', () => { const setup = () => { diff --git a/apps/server/src/modules/provisioning/mapper/provisioning-system-input.mapper.spec.ts b/apps/server/src/modules/provisioning/mapper/provisioning-system-input.mapper.spec.ts index b81b42fb1de..5d68a2bdae7 100644 --- a/apps/server/src/modules/provisioning/mapper/provisioning-system-input.mapper.spec.ts +++ b/apps/server/src/modules/provisioning/mapper/provisioning-system-input.mapper.spec.ts @@ -1,3 +1,8 @@ +import { SystemProvisioningStrategy } from '@shared/domain/interface/system-provisioning.strategy'; +import { SystemDto } from '@src/modules/system/service/dto/system.dto'; +import { ProvisioningSystemDto } from '../dto/provisioning-system.dto'; +import { ProvisioningSystemInputMapper } from './provisioning-system-input.mapper'; + describe('SchoolUcMapper', () => { describe('mapToInternal', () => { it('should map provisioningStrategy', () => { diff --git a/apps/server/src/modules/provisioning/strategy/oidc/service/oidc-provisioning.service.spec.ts b/apps/server/src/modules/provisioning/strategy/oidc/service/oidc-provisioning.service.spec.ts index 19aa7c481e2..5077a43b366 100644 --- a/apps/server/src/modules/provisioning/strategy/oidc/service/oidc-provisioning.service.spec.ts +++ b/apps/server/src/modules/provisioning/strategy/oidc/service/oidc-provisioning.service.spec.ts @@ -1,5 +1,5 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; -import { Logger, UnprocessableEntityException } from '@nestjs/common'; +import { UnprocessableEntityException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { NotFoundLoggableException } from '@shared/common/loggable-exception/not-found.loggable-exception'; import { ExternalSource } from '@shared/domain/domainobject/external-source'; @@ -16,6 +16,7 @@ import { roleDtoFactory } from '@shared/testing/factory/role-dto.factory'; import { roleFactory } from '@shared/testing/factory/role.factory'; import { schoolYearFactory } from '@shared/testing/factory/schoolyear.factory'; import { userDoFactory } from '@shared/testing/factory/user.do.factory'; +import { Logger } from '@src/core/logger/logger'; import { AccountService } from '@src/modules/account/services/account.service'; import { AccountSaveDto } from '@src/modules/account/services/dto/account-save.dto'; import { Group } from '@src/modules/group/domain/group'; diff --git a/apps/server/src/modules/pseudonym/loggable/too-many-pseudonyms.loggable-exception.spec.ts b/apps/server/src/modules/pseudonym/loggable/too-many-pseudonyms.loggable-exception.spec.ts index de09af6a38a..b03350c38ba 100644 --- a/apps/server/src/modules/pseudonym/loggable/too-many-pseudonyms.loggable-exception.spec.ts +++ b/apps/server/src/modules/pseudonym/loggable/too-many-pseudonyms.loggable-exception.spec.ts @@ -1,3 +1,5 @@ +import { TooManyPseudonymsLoggableException } from './too-many-pseudonyms.loggable-exception'; + describe('TooManyPseudonymsLoggableException', () => { describe('constructor', () => { const setup = () => { diff --git a/apps/server/src/modules/pseudonym/repo/external-tool-pseudonym.repo.integration.spec.ts b/apps/server/src/modules/pseudonym/repo/external-tool-pseudonym.repo.integration.spec.ts index 672c4aae287..1f1483b40f3 100644 --- a/apps/server/src/modules/pseudonym/repo/external-tool-pseudonym.repo.integration.spec.ts +++ b/apps/server/src/modules/pseudonym/repo/external-tool-pseudonym.repo.integration.spec.ts @@ -2,8 +2,19 @@ import { createMock } from '@golevelup/ts-jest'; import { NotFoundError } from '@mikro-orm/core'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; - +import { Page } from '@shared/domain/domainobject/page'; +import { Pseudonym } from '@shared/domain/domainobject/pseudonym.do'; +import { MongoMemoryDatabaseModule } from '@shared/infra/database/mongo-memory-database/mongo-memory-database.module'; +import { cleanupCollections } from '@shared/testing/cleanup-collections'; +import { pseudonymFactory } from '@shared/testing/factory/domainobject/pseudonym.factory'; +import { externalToolPseudonymEntityFactory } from '@shared/testing/factory/external-tool-pseudonym.factory'; +import { pseudonymEntityFactory } from '@shared/testing/factory/pseudonym.factory'; +import { userFactory } from '@shared/testing/factory/user.factory'; +import { LegacyLogger } from '@src/core/logger/legacy-logger.service'; import { v4 as uuidv4 } from 'uuid'; +import { PseudonymSearchQuery } from '../domain/pseudonym-search-query'; +import { ExternalToolPseudonymEntity } from '../entity/external-tool-pseudonym.entity'; +import { ExternalToolPseudonymRepo } from './external-tool-pseudonym.repo'; describe('ExternalToolPseudonymRepo', () => { let module: TestingModule; diff --git a/apps/server/src/modules/pseudonym/repo/pseudonyms.repo.spec.ts b/apps/server/src/modules/pseudonym/repo/pseudonyms.repo.spec.ts index df3c5ffe8a7..8d3507b59f7 100644 --- a/apps/server/src/modules/pseudonym/repo/pseudonyms.repo.spec.ts +++ b/apps/server/src/modules/pseudonym/repo/pseudonyms.repo.spec.ts @@ -2,8 +2,16 @@ import { createMock } from '@golevelup/ts-jest'; import { NotFoundError } from '@mikro-orm/core'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; - +import { Pseudonym } from '@shared/domain/domainobject/pseudonym.do'; +import { MongoMemoryDatabaseModule } from '@shared/infra/database/mongo-memory-database/mongo-memory-database.module'; +import { cleanupCollections } from '@shared/testing/cleanup-collections'; +import { pseudonymFactory } from '@shared/testing/factory/domainobject/pseudonym.factory'; +import { pseudonymEntityFactory } from '@shared/testing/factory/pseudonym.factory'; +import { userFactory } from '@shared/testing/factory/user.factory'; +import { LegacyLogger } from '@src/core/logger/legacy-logger.service'; import { v4 as uuidv4 } from 'uuid'; +import { PseudonymEntity } from '../entity/pseudonym.entity'; +import { PseudonymsRepo } from './pseudonyms.repo'; describe('PseudonymRepo', () => { let module: TestingModule; diff --git a/apps/server/src/modules/pseudonym/service/pseudonym.service.spec.ts b/apps/server/src/modules/pseudonym/service/pseudonym.service.spec.ts index d91b5e8c1d6..7adf004f830 100644 --- a/apps/server/src/modules/pseudonym/service/pseudonym.service.spec.ts +++ b/apps/server/src/modules/pseudonym/service/pseudonym.service.spec.ts @@ -2,6 +2,20 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Configuration } from '@hpi-schul-cloud/commons/lib'; import { InternalServerErrorException, NotFoundException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; +import { LtiToolDO } from '@shared/domain/domainobject/ltitool.do'; +import { Page } from '@shared/domain/domainobject/page'; +import { Pseudonym } from '@shared/domain/domainobject/pseudonym.do'; +import { UserDO } from '@shared/domain/domainobject/user.do'; +import { IFindOptions } from '@shared/domain/interface/find-options'; +import { ltiToolDOFactory } from '@shared/testing/factory/domainobject/lti-tool.factory'; +import { pseudonymFactory } from '@shared/testing/factory/domainobject/pseudonym.factory'; +import { externalToolFactory } from '@shared/testing/factory/domainobject/tool/external-tool.factory'; +import { userDoFactory } from '@shared/testing/factory/user.do.factory'; +import { ExternalTool } from '@src/modules/tool/external-tool/domain/external-tool.do'; +import { PseudonymSearchQuery } from '../domain/pseudonym-search-query'; +import { ExternalToolPseudonymRepo } from '../repo/external-tool-pseudonym.repo'; +import { PseudonymsRepo } from '../repo/pseudonyms.repo'; +import { PseudonymService } from './pseudonym.service'; describe('PseudonymService', () => { let module: TestingModule; diff --git a/apps/server/src/modules/role/mapper/role.mapper.spec.ts b/apps/server/src/modules/role/mapper/role.mapper.spec.ts index 6699f44c73d..6c44a04afeb 100644 --- a/apps/server/src/modules/role/mapper/role.mapper.spec.ts +++ b/apps/server/src/modules/role/mapper/role.mapper.spec.ts @@ -1,3 +1,10 @@ +import { Role } from '@shared/domain/entity/role.entity'; +import { Permission } from '@shared/domain/interface/permission.enum'; +import { roleFactory } from '@shared/testing/factory/role.factory'; +import { setupEntities } from '@shared/testing/setup-entities'; +import { RoleDto } from '../service/dto/role.dto'; +import { RoleMapper } from './role.mapper'; + describe('RoleMapper', () => { beforeAll(async () => { await setupEntities(); diff --git a/apps/server/src/modules/role/service/role.service.spec.ts b/apps/server/src/modules/role/service/role.service.spec.ts index 5200c947321..cff7ad7d74c 100644 --- a/apps/server/src/modules/role/service/role.service.spec.ts +++ b/apps/server/src/modules/role/service/role.service.spec.ts @@ -1,6 +1,12 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { NotFoundError } from '@mikro-orm/core'; import { Test, TestingModule } from '@nestjs/testing'; +import { Role } from '@shared/domain/entity/role.entity'; +import { RoleName } from '@shared/domain/interface/rolename.enum'; +import { RoleRepo } from '@shared/repo/role/role.repo'; +import { roleFactory } from '@shared/testing/factory/role.factory'; +import { RoleDto } from './dto/role.dto'; +import { RoleService } from './role.service'; import resetAllMocks = jest.resetAllMocks; diff --git a/apps/server/src/modules/role/uc/role.uc.spec.ts b/apps/server/src/modules/role/uc/role.uc.spec.ts index 80eb94ddc2d..74537920cb2 100644 --- a/apps/server/src/modules/role/uc/role.uc.spec.ts +++ b/apps/server/src/modules/role/uc/role.uc.spec.ts @@ -1,5 +1,9 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; +import { RoleName } from '@shared/domain/interface/rolename.enum'; +import { RoleDto } from '../service/dto/role.dto'; +import { RoleService } from '../service/role.service'; +import { RoleUc } from './role.uc'; describe('RoleUc', () => { let module: TestingModule; diff --git a/apps/server/src/modules/server/controller/api-test/server.api.spec.ts b/apps/server/src/modules/server/controller/api-test/server.api.spec.ts index fdf2ad55a87..8952f875dbe 100644 --- a/apps/server/src/modules/server/controller/api-test/server.api.spec.ts +++ b/apps/server/src/modules/server/controller/api-test/server.api.spec.ts @@ -1,7 +1,7 @@ import { INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; - import request from 'supertest'; +import { ServerTestModule } from '../../server.module'; describe('Server Controller (API)', () => { let app: INestApplication; diff --git a/apps/server/src/modules/server/controller/server.controller.spec.ts b/apps/server/src/modules/server/controller/server.controller.spec.ts index 79295ab0223..d5397ce241a 100644 --- a/apps/server/src/modules/server/controller/server.controller.spec.ts +++ b/apps/server/src/modules/server/controller/server.controller.spec.ts @@ -1,4 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; +import { ServerController } from './server.controller'; describe('ServerController', () => { let module: TestingModule; diff --git a/apps/server/src/modules/system/controller/api-test/system.api.spec.ts b/apps/server/src/modules/system/controller/api-test/system.api.spec.ts index 7f8b1225653..a7211120978 100644 --- a/apps/server/src/modules/system/controller/api-test/system.api.spec.ts +++ b/apps/server/src/modules/system/controller/api-test/system.api.spec.ts @@ -1,9 +1,16 @@ import { EntityManager } from '@mikro-orm/mongodb'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; - +import { SystemEntity, OauthConfig } from '@shared/domain/entity/system.entity'; +import { cleanupCollections } from '@shared/testing/cleanup-collections'; +import { systemFactory } from '@shared/testing/factory/system.factory'; +import { JwtAuthGuard } from '@src/modules/authentication/guard/jwt-auth.guard'; +import { ICurrentUser } from '@src/modules/authentication/interface/user'; +import { ServerTestModule } from '@src/modules/server/server.module'; import { Request } from 'express'; import request, { Response } from 'supertest'; +import { PublicSystemListResponse } from '../dto/public-system-list.response'; +import { PublicSystemResponse } from '../dto/public-system-response'; describe('System (API)', () => { let app: INestApplication; diff --git a/apps/server/src/modules/system/mapper/system-oidc.mapper.spec.ts b/apps/server/src/modules/system/mapper/system-oidc.mapper.spec.ts index a443c842a24..6b2f4fc258a 100644 --- a/apps/server/src/modules/system/mapper/system-oidc.mapper.spec.ts +++ b/apps/server/src/modules/system/mapper/system-oidc.mapper.spec.ts @@ -1,4 +1,7 @@ import { Test, TestingModule } from '@nestjs/testing'; +import { SystemEntity } from '@shared/domain/entity/system.entity'; +import { systemFactory } from '@shared/testing/factory/system.factory'; +import { SystemOidcMapper } from './system-oidc.mapper'; describe('SystemOidcMapper', () => { let module: TestingModule; diff --git a/apps/server/src/modules/system/mapper/system.mapper.spec.ts b/apps/server/src/modules/system/mapper/system.mapper.spec.ts index 162998b951c..40bea74ab24 100644 --- a/apps/server/src/modules/system/mapper/system.mapper.spec.ts +++ b/apps/server/src/modules/system/mapper/system.mapper.spec.ts @@ -1,4 +1,7 @@ import { Test, TestingModule } from '@nestjs/testing'; +import { SystemEntity } from '@shared/domain/entity/system.entity'; +import { systemFactory } from '@shared/testing/factory/system.factory'; +import { SystemMapper } from './system.mapper'; describe('SystemMapper', () => { let module: TestingModule; diff --git a/apps/server/src/modules/system/service/system-oidc.service.spec.ts b/apps/server/src/modules/system/service/system-oidc.service.spec.ts index c558a9cb13b..673a3a3c6f3 100644 --- a/apps/server/src/modules/system/service/system-oidc.service.spec.ts +++ b/apps/server/src/modules/system/service/system-oidc.service.spec.ts @@ -1,5 +1,11 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; +import { EntityNotFoundError } from '@shared/common/error/entity-not-found.error'; +import { SystemEntity } from '@shared/domain/entity/system.entity'; +import { SystemRepo } from '@shared/repo/system/system.repo'; +import { systemFactory } from '@shared/testing/factory/system.factory'; +import { SystemOidcMapper } from '../mapper/system-oidc.mapper'; +import { SystemOidcService } from './system-oidc.service'; describe('SystemService', () => { let module: TestingModule; diff --git a/apps/server/src/modules/system/service/system.service.spec.ts b/apps/server/src/modules/system/service/system.service.spec.ts index 4a9505dca3f..699c5df1701 100644 --- a/apps/server/src/modules/system/service/system.service.spec.ts +++ b/apps/server/src/modules/system/service/system.service.spec.ts @@ -1,5 +1,13 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; +import { EntityNotFoundError } from '@shared/common/error/entity-not-found.error'; +import { SystemEntity, OauthConfig } from '@shared/domain/entity/system.entity'; +import { SystemTypeEnum } from '@shared/domain/types/system.type'; +import { IdentityManagementOauthService } from '@shared/infra/identity-management/identity-management-oauth.service'; +import { SystemRepo } from '@shared/repo/system/system.repo'; +import { systemFactory } from '@shared/testing/factory/system.factory'; +import { SystemMapper } from '../mapper/system.mapper'; +import { SystemService } from './system.service'; describe('SystemService', () => { let module: TestingModule; diff --git a/apps/server/src/modules/system/uc/system.uc.spec.ts b/apps/server/src/modules/system/uc/system.uc.spec.ts index 314ba65c870..bc4afa5cbde 100644 --- a/apps/server/src/modules/system/uc/system.uc.spec.ts +++ b/apps/server/src/modules/system/uc/system.uc.spec.ts @@ -1,5 +1,14 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; +import { EntityNotFoundError } from '@shared/common/error/entity-not-found.error'; +import { SystemEntity } from '@shared/domain/entity/system.entity'; +import { EntityId } from '@shared/domain/types/entity-id'; +import { SystemTypeEnum } from '@shared/domain/types/system.type'; +import { systemFactory } from '@shared/testing/factory/system.factory'; +import { SystemMapper } from '../mapper/system.mapper'; +import { SystemDto } from '../service/dto/system.dto'; +import { SystemService } from '../service/system.service'; +import { SystemUc } from './system.uc'; describe('SystemUc', () => { let module: TestingModule; diff --git a/apps/server/src/modules/task/controller/api-test/task-copy-timeout.api.spec.ts b/apps/server/src/modules/task/controller/api-test/task-copy-timeout.api.spec.ts index 839bb7132a9..9eeabef68c3 100644 --- a/apps/server/src/modules/task/controller/api-test/task-copy-timeout.api.spec.ts +++ b/apps/server/src/modules/task/controller/api-test/task-copy-timeout.api.spec.ts @@ -11,14 +11,13 @@ import { userFactory } from '@shared/testing/factory/user.factory'; import { mapUserToCurrentUser } from '@shared/testing/map-user-to-current-user'; import { JwtAuthGuard } from '@src/modules/authentication/guard/jwt-auth.guard'; import { ICurrentUser } from '@src/modules/authentication/interface/user'; -import { ServerTestModule } from '@src/modules/server/server.module'; - import { Request } from 'express'; import request from 'supertest'; Configuration.set('FEATURE_COPY_SERVICE_ENABLED', true); Configuration.set('INCOMING_REQUEST_TIMEOUT_COPY_API', 1); // eslint-disable-next-line import/first +import { ServerTestModule } from '@src/modules/server/server.module'; // This needs to be in a separate test file because of the above configuration. // When we find a way to mock the config, it should be moved alongside the other API tests. diff --git a/apps/server/src/modules/task/mapper/submission.mapper.spec.ts b/apps/server/src/modules/task/mapper/submission.mapper.spec.ts index 5951f004e39..bf85135da39 100644 --- a/apps/server/src/modules/task/mapper/submission.mapper.spec.ts +++ b/apps/server/src/modules/task/mapper/submission.mapper.spec.ts @@ -1,3 +1,8 @@ +import { submissionFactory } from '@shared/testing/factory/submission.factory'; +import { setupEntities } from '@shared/testing/setup-entities'; +import { SubmissionStatusResponse } from '../controller/dto/submission.response'; +import { SubmissionMapper } from './submission.mapper'; + describe('Submission Mapper', () => { beforeAll(async () => { await setupEntities(); diff --git a/apps/server/src/modules/task/service/submission.service.spec.ts b/apps/server/src/modules/task/service/submission.service.spec.ts index 4db7a08535a..947950c6dcd 100644 --- a/apps/server/src/modules/task/service/submission.service.spec.ts +++ b/apps/server/src/modules/task/service/submission.service.spec.ts @@ -7,8 +7,8 @@ import { SubmissionRepo } from '@shared/repo/submission/submission.repo'; import { submissionFactory } from '@shared/testing/factory/submission.factory'; import { taskFactory } from '@shared/testing/factory/task.factory'; import { setupEntities } from '@shared/testing/setup-entities'; +import { FileDto } from '@src/modules/files-storage-client/dto/file.dto'; import { FilesStorageClientAdapterService } from '@src/modules/files-storage-client/service/files-storage-client.service'; -import { FileDto } from '@src/modules/files-storage/dto/file.dto'; import { SubmissionService } from './submission.service'; describe('Submission Service', () => { diff --git a/apps/server/src/modules/teams/service/team.service.spec.ts b/apps/server/src/modules/teams/service/team.service.spec.ts index 20ed40ba250..4defbc56dd3 100644 --- a/apps/server/src/modules/teams/service/team.service.spec.ts +++ b/apps/server/src/modules/teams/service/team.service.spec.ts @@ -1,5 +1,10 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; +import { TeamsRepo } from '@shared/repo/teams/teams.repo'; +import { teamFactory } from '@shared/testing/factory/team.factory'; +import { teamUserFactory } from '@shared/testing/factory/teamuser.factory'; +import { setupEntities } from '@shared/testing/setup-entities'; +import { TeamService } from './team.service'; describe('TeamService', () => { let module: TestingModule; diff --git a/apps/server/src/modules/tool/external-tool/service/external-tool-logo-service.spec.ts b/apps/server/src/modules/tool/external-tool/service/external-tool-logo-service.spec.ts index b4beae6a279..93301872663 100644 --- a/apps/server/src/modules/tool/external-tool/service/external-tool-logo-service.spec.ts +++ b/apps/server/src/modules/tool/external-tool/service/external-tool-logo-service.spec.ts @@ -1,11 +1,10 @@ -import { createMock, DeepMocked, DeepMocked } from '@golevelup/ts-jest'; +import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { HttpService } from '@nestjs/axios'; import { HttpException, HttpStatus } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { axiosResponseFactory } from '@shared/testing/factory/axios-response.factory'; import { externalToolFactory } from '@shared/testing/factory/domainobject/tool/external-tool.factory'; import { Logger } from '@src/core/logger/logger'; - import { of, throwError } from 'rxjs'; import { IToolFeatures, ToolFeatures } from '../../tool-config'; import { ExternalToolLogo } from '../domain/external-tool-logo'; diff --git a/apps/server/src/modules/tool/external-tool/service/external-tool-parameter-validation.service.spec.ts b/apps/server/src/modules/tool/external-tool/service/external-tool-parameter-validation.service.spec.ts index e7e67cd8a3b..836759cc08e 100644 --- a/apps/server/src/modules/tool/external-tool/service/external-tool-parameter-validation.service.spec.ts +++ b/apps/server/src/modules/tool/external-tool/service/external-tool-parameter-validation.service.spec.ts @@ -1,10 +1,10 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; +import { ValidationError } from '@shared/common/error/validation.error'; import { customParameterFactory, externalToolFactory, } from '@shared/testing/factory/domainobject/tool/external-tool.factory'; -import { ValidationError } from 'class-validator'; import { CustomParameter } from '../../common/domain/custom-parameter.do'; import { CustomParameterScope } from '../../common/enum/custom-parameter-scope.enum'; import { CustomParameterType } from '../../common/enum/custom-parameter-type.enum'; diff --git a/apps/server/src/modules/tool/external-tool/service/external-tool-validation.service.spec.ts b/apps/server/src/modules/tool/external-tool/service/external-tool-validation.service.spec.ts index 341d62803a3..18dd8b60ed3 100644 --- a/apps/server/src/modules/tool/external-tool/service/external-tool-validation.service.spec.ts +++ b/apps/server/src/modules/tool/external-tool/service/external-tool-validation.service.spec.ts @@ -1,7 +1,7 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; +import { ValidationError } from '@shared/common/error/validation.error'; import { externalToolFactory } from '@shared/testing/factory/domainobject/tool/external-tool.factory'; -import { ValidationError } from 'class-validator'; import { IToolFeatures, ToolFeatures } from '../../tool-config'; import { ExternalTool } from '../domain/external-tool.do'; import { ExternalToolLogoService } from './external-tool-logo.service'; diff --git a/apps/server/src/modules/user-login-migration/service/school-migration.service.spec.ts b/apps/server/src/modules/user-login-migration/service/school-migration.service.spec.ts index 0b2330d3e91..0f81bbddc5e 100644 --- a/apps/server/src/modules/user-login-migration/service/school-migration.service.spec.ts +++ b/apps/server/src/modules/user-login-migration/service/school-migration.service.spec.ts @@ -2,6 +2,7 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { ObjectId } from '@mikro-orm/mongodb'; import { UnprocessableEntityException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; +import { ValidationError } from '@shared/common/error/validation.error'; import { LegacySchoolDo } from '@shared/domain/domainobject/legacy-school.do'; import { Page } from '@shared/domain/domainobject/page'; import { UserLoginMigrationDO } from '@shared/domain/domainobject/user-login-migration.do'; diff --git a/apps/server/src/modules/user/service/user.service.spec.ts b/apps/server/src/modules/user/service/user.service.spec.ts index 2fd54b40fb0..01720a32f82 100644 --- a/apps/server/src/modules/user/service/user.service.spec.ts +++ b/apps/server/src/modules/user/service/user.service.spec.ts @@ -3,6 +3,7 @@ import { EntityManager } from '@mikro-orm/core'; import { ConfigService } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; import { UserDO } from '@shared/domain/domainobject/user.do'; +import { Role } from '@shared/domain/entity/role.entity'; import { LanguageType, User } from '@shared/domain/entity/user.entity'; import { IFindOptions, SortOrder } from '@shared/domain/interface/find-options'; import { Permission } from '@shared/domain/interface/permission.enum'; @@ -18,7 +19,6 @@ import { AccountService } from '@src/modules/account/services/account.service'; import { AccountDto } from '@src/modules/account/services/dto/account.dto'; import { ICurrentUser } from '@src/modules/authentication/interface/user'; import { RoleService } from '@src/modules/role/service/role.service'; -import { Role } from '../controller/dto/resolved-user.response'; import { UserDto } from '../uc/dto/user.dto'; import { UserQuery } from './user-query.type'; import { UserService } from './user.service'; diff --git a/apps/server/src/modules/video-conference/bbb/builder/builder.spec.ts b/apps/server/src/modules/video-conference/bbb/builder/builder.spec.ts index 3cfec8110ac..0e23683a8fa 100644 --- a/apps/server/src/modules/video-conference/bbb/builder/builder.spec.ts +++ b/apps/server/src/modules/video-conference/bbb/builder/builder.spec.ts @@ -1,4 +1,4 @@ -import { Builder } from 'xml2js'; +import { Builder } from './builder'; interface TestObject { test: string; diff --git a/apps/server/src/modules/video-conference/controller/api-test/video-conference.api.spec.ts b/apps/server/src/modules/video-conference/controller/api-test/video-conference.api.spec.ts index 20f10181bdd..d686c325681 100644 --- a/apps/server/src/modules/video-conference/controller/api-test/video-conference.api.spec.ts +++ b/apps/server/src/modules/video-conference/controller/api-test/video-conference.api.spec.ts @@ -6,7 +6,7 @@ import { Course } from '@shared/domain/entity/course.entity'; import { Role } from '@shared/domain/entity/role.entity'; import { SchoolEntity, SchoolFeatures } from '@shared/domain/entity/school.entity'; import { User } from '@shared/domain/entity/user.entity'; -import { TargetModels } from '@shared/domain/entity/video-conference.entity'; +import { TargetModels, VideoConference } from '@shared/domain/entity/video-conference.entity'; import { Permission } from '@shared/domain/interface/permission.enum'; import { RoleName } from '@shared/domain/interface/rolename.enum'; import { VideoConferenceScope } from '@shared/domain/interface/video-conference-scope.enum'; @@ -20,11 +20,9 @@ import { userFactory } from '@shared/testing/factory/user.factory'; import { videoConferenceFactory } from '@shared/testing/factory/video-conference.factory'; import { TestApiClient } from '@shared/testing/test-api-client'; import { ServerTestModule } from '@src/modules/server/server.module'; - import axios from 'axios'; import MockAdapter from 'axios-mock-adapter'; import { Response } from 'supertest'; -import { VideoConference } from '../../uc/dto/video-conference'; import { VideoConferenceCreateParams } from '../dto/request/video-conference-create.params'; import { VideoConferenceJoinResponse } from '../dto/response/video-conference-join.response'; diff --git a/apps/server/src/shared/common/error/validation.error.spec.ts b/apps/server/src/shared/common/error/validation.error.spec.ts index c8799af8262..7b1d1e7fdd8 100644 --- a/apps/server/src/shared/common/error/validation.error.spec.ts +++ b/apps/server/src/shared/common/error/validation.error.spec.ts @@ -1,4 +1,5 @@ import { HttpStatus } from '@nestjs/common'; +import { ValidationError } from './validation.error'; describe('Validation Error', () => { it('should possible to create', () => { diff --git a/apps/server/src/shared/infra/metrics/index.ts b/apps/server/src/shared/infra/metrics/index.ts new file mode 100644 index 00000000000..733729d5b2e --- /dev/null +++ b/apps/server/src/shared/infra/metrics/index.ts @@ -0,0 +1 @@ +export * from './prometheus'; diff --git a/apps/server/src/shared/infra/metrics/prometheus/index.ts b/apps/server/src/shared/infra/metrics/prometheus/index.ts new file mode 100644 index 00000000000..b58a10b3277 --- /dev/null +++ b/apps/server/src/shared/infra/metrics/prometheus/index.ts @@ -0,0 +1,4 @@ +export * from './app'; +export * from './config'; +export * from './handler'; +export * from './middleware'; diff --git a/apps/server/src/shared/repo/base.repo.integration.spec.ts b/apps/server/src/shared/repo/base.repo.integration.spec.ts index f9b96bfeb82..3636def3712 100644 --- a/apps/server/src/shared/repo/base.repo.integration.spec.ts +++ b/apps/server/src/shared/repo/base.repo.integration.spec.ts @@ -1,8 +1,8 @@ -import { BaseEntity, Entity, EntityName, Property } from '@mikro-orm/core'; +import { Entity, EntityName, Property } from '@mikro-orm/core'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; -import { Test, TestingModule } from '@nestjs/testing'; - import { Injectable } from '@nestjs/common'; +import { Test, TestingModule } from '@nestjs/testing'; +import { BaseEntity } from '@shared/domain/entity/base.entity'; import { MongoMemoryDatabaseModule } from '@shared/infra/database/mongo-memory-database/mongo-memory-database.module'; import { BaseRepo } from './base.repo'; diff --git a/apps/server/src/shared/repo/user/user-do.repo.integration.spec.ts b/apps/server/src/shared/repo/user/user-do.repo.integration.spec.ts index 3153c8f04f4..495361ab609 100644 --- a/apps/server/src/shared/repo/user/user-do.repo.integration.spec.ts +++ b/apps/server/src/shared/repo/user/user-do.repo.integration.spec.ts @@ -1,5 +1,4 @@ import { createMock } from '@golevelup/ts-jest'; -import { UserQuery } from '@keycloak/keycloak-admin-client/lib/resources/users'; import { FindOptions, NotFoundError, QueryOrderMap } from '@mikro-orm/core'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; @@ -20,6 +19,7 @@ import { systemFactory } from '@shared/testing/factory/system.factory'; import { userDoFactory } from '@shared/testing/factory/user.do.factory'; import { userFactory } from '@shared/testing/factory/user.factory'; import { LegacyLogger } from '@src/core/logger/legacy-logger.service'; +import { UserQuery } from '@src/modules/user/service/user-query.type'; import { UserDORepo } from './user-do.repo'; describe('UserRepo', () => {