From da82e4bb3e24177303e7bcbc264fbd303bc612a8 Mon Sep 17 00:00:00 2001 From: marcellmueller Date: Mon, 2 Dec 2024 15:33:19 -0800 Subject: [PATCH] chore: fix backend tests --- .github/workflows/analysis.yml | 1 - backend/e2e/app.e2e-spec.ts | 2 +- backend/src/app.controller.spec.ts | 2 +- backend/src/app.controller.ts | 2 +- backend/src/app.module.ts | 2 +- backend/src/app.spec.ts | 4 ++-- backend/src/app.ts | 2 +- backend/src/common/logger.config.ts | 2 +- backend/src/health.controller.ts | 7 ++----- backend/src/main.ts | 2 +- backend/src/metrics.controller.ts | 4 ++-- backend/src/middleware/req.res.logger.spec.ts | 2 +- backend/src/middleware/req.res.logger.ts | 4 ++-- backend/src/users/users.controller.spec.ts | 10 +++++----- backend/src/users/users.controller.ts | 8 ++++---- backend/src/users/users.service.spec.ts | 2 +- backend/src/users/users.service.ts | 8 ++++---- backend/tsconfig.json | 2 +- eslint.config.mjs | 2 +- 19 files changed, 32 insertions(+), 36 deletions(-) diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index 847790a..91e270c 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -20,7 +20,6 @@ concurrency: jobs: tests: name: Tests - if: ${{ ! github.event.pull_request.draft }} runs-on: ubuntu-24.04 timeout-minutes: 5 services: diff --git a/backend/e2e/app.e2e-spec.ts b/backend/e2e/app.e2e-spec.ts index 331baa1..50d1cac 100644 --- a/backend/e2e/app.e2e-spec.ts +++ b/backend/e2e/app.e2e-spec.ts @@ -1,6 +1,6 @@ import request from "supertest"; import { Test } from "@nestjs/testing"; -import type { INestApplication } from "@nestjs/common"; +import { INestApplication } from "@nestjs/common"; import { AppModule } from "../src/app.module"; describe("AppController (e2e)", () => { diff --git a/backend/src/app.controller.spec.ts b/backend/src/app.controller.spec.ts index ce867d5..38dbcaa 100644 --- a/backend/src/app.controller.spec.ts +++ b/backend/src/app.controller.spec.ts @@ -1,4 +1,4 @@ -import type { TestingModule } from "@nestjs/testing"; +import { TestingModule } from "@nestjs/testing"; import { Test } from "@nestjs/testing"; import { AppController } from "./app.controller"; import { AppService } from "./app.service"; diff --git a/backend/src/app.controller.ts b/backend/src/app.controller.ts index 4f66879..1e7e628 100644 --- a/backend/src/app.controller.ts +++ b/backend/src/app.controller.ts @@ -1,5 +1,5 @@ import { Controller, Get } from "@nestjs/common"; -import type { AppService } from "./app.service"; +import { AppService } from "./app.service"; @Controller() export class AppController { diff --git a/backend/src/app.module.ts b/backend/src/app.module.ts index ff96e66..8d17791 100644 --- a/backend/src/app.module.ts +++ b/backend/src/app.module.ts @@ -1,5 +1,5 @@ import "dotenv/config"; -import type { MiddlewareConsumer } from "@nestjs/common"; +import { MiddlewareConsumer } from "@nestjs/common"; import { Logger, Module, RequestMethod } from "@nestjs/common"; import { HTTPLoggerMiddleware } from "./middleware/req.res.logger"; import { loggingMiddleware, PrismaModule } from "nestjs-prisma"; diff --git a/backend/src/app.spec.ts b/backend/src/app.spec.ts index 182266c..6a690c5 100644 --- a/backend/src/app.spec.ts +++ b/backend/src/app.spec.ts @@ -1,4 +1,4 @@ -import type { NestExpressApplication } from "@nestjs/platform-express"; +import { NestExpressApplication } from "@nestjs/platform-express"; import { bootstrap } from "./app"; vi.mock("prom-client", () => ({ @@ -11,7 +11,7 @@ vi.mock("express-prom-bundle", () => ({ })); vi.mock("./prom", () => ({ - metricsMiddleware: vi.fn().mockImplementation((req, res, next) => next()), + metricsMiddleware: vi.fn().mockImplementation((_req, _res, next) => next()), })); describe("main", () => { diff --git a/backend/src/app.ts b/backend/src/app.ts index 571f72e..3347c79 100644 --- a/backend/src/app.ts +++ b/backend/src/app.ts @@ -2,7 +2,7 @@ import { NestFactory } from "@nestjs/core"; import { DocumentBuilder, SwaggerModule } from "@nestjs/swagger"; import { AppModule } from "./app.module"; import { customLogger } from "./common/logger.config"; -import type { NestExpressApplication } from "@nestjs/platform-express"; +import { NestExpressApplication } from "@nestjs/platform-express"; import helmet from "helmet"; import { VersioningType } from "@nestjs/common"; import { metricsMiddleware } from "./prom"; diff --git a/backend/src/common/logger.config.ts b/backend/src/common/logger.config.ts index be77b11..7c1f488 100644 --- a/backend/src/common/logger.config.ts +++ b/backend/src/common/logger.config.ts @@ -1,6 +1,6 @@ import { WinstonModule, utilities } from "nest-winston"; import * as winston from "winston"; -import type { LoggerService } from "@nestjs/common"; +import { LoggerService } from "@nestjs/common"; const globalLoggerFormat: winston.Logform.Format = winston.format.timestamp({ format: "YYYY-MM-DD hh:mm:ss.SSS", diff --git a/backend/src/health.controller.ts b/backend/src/health.controller.ts index aa8ac37..e6b856a 100644 --- a/backend/src/health.controller.ts +++ b/backend/src/health.controller.ts @@ -1,10 +1,7 @@ import { Controller, Get } from "@nestjs/common"; -import type { - HealthCheckService, - PrismaHealthIndicator, -} from "@nestjs/terminus"; +import { HealthCheckService, PrismaHealthIndicator } from "@nestjs/terminus"; import { HealthCheck } from "@nestjs/terminus"; -import type { PrismaService } from "nestjs-prisma"; +import { PrismaService } from "nestjs-prisma"; @Controller("health") export class HealthController { diff --git a/backend/src/main.ts b/backend/src/main.ts index 16a8b32..466c504 100644 --- a/backend/src/main.ts +++ b/backend/src/main.ts @@ -1,4 +1,4 @@ -import type { NestExpressApplication } from "@nestjs/platform-express"; +import { NestExpressApplication } from "@nestjs/platform-express"; import { bootstrap } from "./app"; import { Logger } from "@nestjs/common"; const logger = new Logger("NestApplication"); diff --git a/backend/src/metrics.controller.ts b/backend/src/metrics.controller.ts index 264714b..62bc71d 100644 --- a/backend/src/metrics.controller.ts +++ b/backend/src/metrics.controller.ts @@ -1,7 +1,7 @@ import { Controller, Get, Res } from "@nestjs/common"; -import type { Response } from "express"; +import { Response } from "express"; import { register } from "./prom"; -import type { PrismaService } from "nestjs-prisma"; +import { PrismaService } from "nestjs-prisma"; @Controller("metrics") export class MetricsController { constructor(private prisma: PrismaService) {} diff --git a/backend/src/middleware/req.res.logger.spec.ts b/backend/src/middleware/req.res.logger.spec.ts index 789ff1a..14ddd72 100644 --- a/backend/src/middleware/req.res.logger.spec.ts +++ b/backend/src/middleware/req.res.logger.spec.ts @@ -1,6 +1,6 @@ import { Test } from "@nestjs/testing"; import { HTTPLoggerMiddleware } from "./req.res.logger"; -import type { Request, Response } from "express"; +import { Request, Response } from "express"; import { Logger } from "@nestjs/common"; describe("HTTPLoggerMiddleware", () => { diff --git a/backend/src/middleware/req.res.logger.ts b/backend/src/middleware/req.res.logger.ts index ee05bd6..984787b 100644 --- a/backend/src/middleware/req.res.logger.ts +++ b/backend/src/middleware/req.res.logger.ts @@ -1,5 +1,5 @@ -import type { Request, Response, NextFunction } from "express"; -import type { NestMiddleware } from "@nestjs/common"; +import { Request, Response, NextFunction } from "express"; +import { NestMiddleware } from "@nestjs/common"; import { Injectable, Logger } from "@nestjs/common"; @Injectable() diff --git a/backend/src/users/users.controller.spec.ts b/backend/src/users/users.controller.spec.ts index 753cdbf..bee6bdb 100644 --- a/backend/src/users/users.controller.spec.ts +++ b/backend/src/users/users.controller.spec.ts @@ -1,13 +1,13 @@ -import type { TestingModule } from "@nestjs/testing"; +import { TestingModule } from "@nestjs/testing"; import { Test } from "@nestjs/testing"; import { UsersController } from "./users.controller"; import { UsersService } from "./users.service"; import request from "supertest"; -import type { INestApplication } from "@nestjs/common"; +import { INestApplication } from "@nestjs/common"; import { HttpException } from "@nestjs/common"; -import type { CreateUserDto } from "./dto/create-user.dto"; -import type { UpdateUserDto } from "./dto/update-user.dto"; -import type { UserDto } from "./dto/user.dto"; +import { CreateUserDto } from "./dto/create-user.dto"; +import { UpdateUserDto } from "./dto/update-user.dto"; +import { UserDto } from "./dto/user.dto"; import { PrismaService } from "nestjs-prisma"; describe("UserController", () => { diff --git a/backend/src/users/users.controller.ts b/backend/src/users/users.controller.ts index 2cc626f..2f699be 100644 --- a/backend/src/users/users.controller.ts +++ b/backend/src/users/users.controller.ts @@ -10,10 +10,10 @@ import { HttpException, } from "@nestjs/common"; import { ApiTags } from "@nestjs/swagger"; -import type { UsersService } from "./users.service"; -import type { CreateUserDto } from "./dto/create-user.dto"; -import type { UpdateUserDto } from "./dto/update-user.dto"; -import type { UserDto } from "./dto/user.dto"; +import { UsersService } from "./users.service"; +import { CreateUserDto } from "./dto/create-user.dto"; +import { UpdateUserDto } from "./dto/update-user.dto"; +import { UserDto } from "./dto/user.dto"; @ApiTags("users") @Controller({ path: "users", version: "1" }) diff --git a/backend/src/users/users.service.spec.ts b/backend/src/users/users.service.spec.ts index 450e3a3..817a7ff 100644 --- a/backend/src/users/users.service.spec.ts +++ b/backend/src/users/users.service.spec.ts @@ -1,4 +1,4 @@ -import type { TestingModule } from "@nestjs/testing"; +import { TestingModule } from "@nestjs/testing"; import { Test } from "@nestjs/testing"; import { UsersService } from "./users.service"; import { PrismaService } from "nestjs-prisma"; diff --git a/backend/src/users/users.service.ts b/backend/src/users/users.service.ts index b359a39..ecbcdac 100644 --- a/backend/src/users/users.service.ts +++ b/backend/src/users/users.service.ts @@ -1,9 +1,9 @@ import { Injectable } from "@nestjs/common"; -import type { PrismaService } from "nestjs-prisma"; +import { PrismaService } from "nestjs-prisma"; -import type { CreateUserDto } from "./dto/create-user.dto"; -import type { UpdateUserDto } from "./dto/update-user.dto"; -import type { UserDto } from "./dto/user.dto"; +import { CreateUserDto } from "./dto/create-user.dto"; +import { UpdateUserDto } from "./dto/update-user.dto"; +import { UserDto } from "./dto/user.dto"; import { Prisma } from "@prisma/client"; @Injectable() diff --git a/backend/tsconfig.json b/backend/tsconfig.json index 0e2c359..99be5cb 100644 --- a/backend/tsconfig.json +++ b/backend/tsconfig.json @@ -21,5 +21,5 @@ "lib": ["es2022"], "types": ["vitest/globals", "node"] }, - "include": ["src/**/*.ts", "e2e/**/*.ts", "vitest.config.ts"] + "include": ["src/**/*.ts", "e2e/**/*.ts", "**/*.ts", "vitest.config.ts"] } diff --git a/eslint.config.mjs b/eslint.config.mjs index 0d832db..f9e5061 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -89,7 +89,7 @@ export default [ "@typescript-eslint/explicit-function-return-type": "off", "@typescript-eslint/consistent-type-imports": [ - "error", + "off", { prefer: "type-imports", },