Skip to content

Commit ae3f787

Browse files
fix(test): make tsconfig.spec typecheck pass with zero errors
Widen tsconfig.spec rootDir so test/ files are covered, then repair every type error that surfaced: - Make query DTO page/limit optional to match their @IsOptional() decorators (services already default them with ?? 1) - Add I18nService arg to AdminController construction in specs - Add missing tier to AuthUserPayload literals in e2e specs - Type execFile spy against Node's overloads; wire the CacheMonitoringService into CacheHeadersInterceptor spec - Break readStream circular inference, fix implicit-any mock params and getResponse() string|object access - Track auth.service's family count() query in the reuse spec (service stopped fetching rows for the log line) 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
1 parent 3b476aa commit ae3f787

15 files changed

Lines changed: 43 additions & 26 deletions

‎src/admin/dto/admin.dto.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ export class AdminUsersQueryDto {
3737
@Type(() => Number)
3838
@IsInt()
3939
@Min(1)
40-
page: number = 1;
40+
page?: number = 1;
4141

4242
@IsOptional()
4343
@Type(() => Number)
4444
@IsInt()
4545
@Min(1)
4646
@Max(100)
47-
limit: number = 20;
47+
limit?: number = 20;
4848

4949
@IsOptional()
5050
@IsString()
@@ -84,14 +84,14 @@ export class ModerationQueueQueryDto {
8484
@Type(() => Number)
8585
@IsInt()
8686
@Min(1)
87-
page: number = 1;
87+
page?: number = 1;
8888

8989
@IsOptional()
9090
@Type(() => Number)
9191
@IsInt()
9292
@Min(1)
9393
@Max(100)
94-
limit: number = 20;
94+
limit?: number = 20;
9595

9696
@IsOptional()
9797
@IsString()
@@ -141,14 +141,14 @@ export class TransactionMonitoringQueryDto {
141141
@Type(() => Number)
142142
@IsInt()
143143
@Min(1)
144-
page: number = 1;
144+
page?: number = 1;
145145

146146
@IsOptional()
147147
@Type(() => Number)
148148
@IsInt()
149149
@Min(1)
150150
@Max(100)
151-
limit: number = 20;
151+
limit?: number = 20;
152152

153153
@IsOptional()
154154
@IsString()

‎src/fraud/dto/fraud.dto.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ export class FraudAlertsQueryDto {
4343
@Type(() => Number)
4444
@IsInt()
4545
@Min(1)
46-
page: number = 1;
46+
page?: number = 1;
4747

4848
@IsOptional()
4949
@Type(() => Number)
5050
@IsInt()
5151
@Min(1)
5252
@Max(100)
53-
limit: number = 20;
53+
limit?: number = 20;
5454
}
5555

5656
export class ReviewFraudAlertDto {

‎test/admin/admin.controller.spec.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { AdminService } from '../../src/admin/admin.service';
55
import { EmailService } from '../../src/email/email.service';
66
import { ArchiveService } from '../../src/archive/archive.service';
77
import { CleanupService } from '../../src/database/cleanup.service';
8+
import { I18nService } from '../../src/i18n/i18n.service';
89
import { RolesGuard } from '../../src/auth/guards/roles.guard';
910
import { ROLES_KEY } from '../../src/auth/decorators/roles.decorator';
1011
import { AuthUserPayload } from '../../src/auth/types/auth-user.type';
@@ -69,6 +70,7 @@ describe('AdminController - role enforcement', () => {
6970
{} as unknown as EmailService,
7071
{} as unknown as ArchiveService,
7172
{} as unknown as CleanupService,
73+
{} as unknown as I18nService,
7274
);
7375

7476
reflector = new Reflector();

‎test/backup/backup.service.e2e-spec.ts‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -298,16 +298,21 @@ describe('BackupService e2e — schedule, status, and restore flows', () => {
298298

299299
it('handles restore failure correctly and updates database status', async () => {
300300
// Mock execFile to simulate failure
301+
type ExecFileParams = Parameters<typeof childProcess.execFile>;
301302
const execFileSpy = jest
302303
.spyOn(childProcess, 'execFile')
303304
.mockImplementationOnce(
304305
(
305-
cmd: string,
306-
args: string[],
307-
callback: (error: any, stdout: string, stderr: string) => void,
308-
) => {
309-
callback(new Error('psql command failed'), '', 'psql: error: connection failed');
310-
return {};
306+
_file: ExecFileParams[0],
307+
_args: ExecFileParams[1],
308+
options: ExecFileParams[2],
309+
callback: ExecFileParams[3],
310+
): ReturnType<typeof childProcess.execFile> => {
311+
// promisify() invokes execFile(file, args, callback) — the callback can
312+
// arrive in the options slot, so accept both call shapes.
313+
const cb = typeof options === 'function' ? options : callback;
314+
cb?.(new Error('psql command failed'), '', 'psql: error: connection failed');
315+
return {} as ReturnType<typeof childProcess.execFile>;
311316
},
312317
);
313318

‎test/cache/cache-stats.spec.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe('CacheStatsController', () => {
5353

5454
describe('CacheHeadersInterceptor', () => {
5555
it('sets cache headers on response', (done) => {
56-
const interceptor = new CacheHeadersInterceptor();
56+
const interceptor = new CacheHeadersInterceptor(new CacheMonitoringService());
5757
const mockRes = { setHeader: jest.fn(), getHeader: jest.fn() };
5858
const mockReq = { path: '/' };
5959
const ctx = {

‎test/e2e/auth-property.e2e-spec.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { PrismaService } from '../../src/database/prisma.service';
88
class FakePrismaService {
99
users = new Map<string, any>();
1010
properties = new Map<string, any>();
11-
blacklistedToken = new Map<string, any>();
1211

1312
async $connect() {}
1413
async $disconnect() {}

‎test/e2e/duplicate-detection-merge.e2e.spec.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { DuplicateDetectionService } from '../../src/duplicate-detection/duplica
1212
import { FraudService } from '../../src/fraud/fraud.service';
1313
import { JwtAuthGuard } from '../../src/auth/guards/jwt-auth.guard';
1414
import { AuthUserPayload } from '../../src/auth/types/auth-user.type';
15+
import { UserTier } from '../../src/types/prisma.types';
1516
import { PrismaService } from '../../src/database/prisma.service';
1617

1718
const OWNER_ID = '11111111-1111-4111-a111-111111111111';
@@ -29,6 +30,7 @@ class MockJwtAuthGuard implements CanActivate {
2930
sub: OWNER_ID,
3031
email: 'owner@example.com',
3132
role: 'USER' as any,
33+
tier: UserTier.FREE,
3234
type: 'access',
3335
};
3436
requestContext.user = user;

‎test/e2e/property-crud-search-favorite.e2e.spec.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { AuthService } from '../../src/auth/auth.service';
3030
import { JwtAuthGuard } from '../../src/auth/guards/jwt-auth.guard';
3131
import { RolesGuard } from '../../src/auth/guards/roles.guard';
3232
import { AuthUserPayload } from '../../src/auth/types/auth-user.type';
33+
import { UserTier } from '../../src/types/prisma.types';
3334

3435
const OWNER_ID = '11111111-1111-4111-a111-111111111111';
3536

@@ -45,6 +46,7 @@ class MockJwtAuthGuard implements CanActivate {
4546
sub: OWNER_ID,
4647
email: 'owner@example.com',
4748
role: role as any,
49+
tier: UserTier.FREE,
4850
type: 'access',
4951
};
5052
req.user = user;

‎test/e2e/sessions-management.e2e.spec.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { SessionsService } from '../../src/sessions/sessions.service';
2626
import { ConfigService } from '@nestjs/config';
2727
import { JwtAuthGuard } from '../../src/auth/guards/jwt-auth.guard';
2828
import { AuthUserPayload } from '../../src/auth/types/auth-user.type';
29+
import { UserTier } from '../../src/types/prisma.types';
2930

3031
const TEST_USER_ID = 'sessions-user-001';
3132

@@ -38,6 +39,7 @@ class MockJwtAuthGuard implements CanActivate {
3839
sub: TEST_USER_ID,
3940
email: 'sessions@example.com',
4041
role: 'USER',
42+
tier: UserTier.FREE,
4143
type: 'access',
4244
};
4345
req.user = user;

‎test/e2e/user-registration-login.e2e.spec.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { SessionsService } from '../../src/sessions/sessions.service';
2727
import { AuthService } from '../../src/auth/auth.service';
2828
import { JwtAuthGuard } from '../../src/auth/guards/jwt-auth.guard';
2929
import { AuthUserPayload } from '../../src/auth/types/auth-user.type';
30+
import { UserTier } from '../../src/types/prisma.types';
3031

3132
const TEST_USER_ID = 'test-user-profile-001';
3233

@@ -41,6 +42,7 @@ class MockJwtAuthGuard implements CanActivate {
4142
sub: TEST_USER_ID,
4243
email: 'user@example.com',
4344
role: 'USER',
45+
tier: UserTier.FREE,
4446
type: 'access',
4547
};
4648
req.user = user;

0 commit comments

Comments
 (0)