mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 20:01:09 +02:00
fix(tests): add missing service mocks to e2e integration tests
- Import SecurityEventsService and Referral services - Provide mocks for all BetterAuthService dependencies - Fixes 'Cannot resolve dependencies' error in test initialization - E2E tests still need real database (works in CI with postgres containers)
This commit is contained in:
parent
304897261d
commit
cfc5c10efe
1 changed files with 28 additions and 1 deletions
|
|
@ -15,8 +15,29 @@ import { Test } from '@nestjs/testing';
|
|||
import type { TestingModule } from '@nestjs/testing';
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
import { BetterAuthService } from '../../src/auth/services/better-auth.service';
|
||||
import { SecurityEventsService } from '../../src/security-events/security-events.service';
|
||||
import { ReferralCodeService } from '../../src/referrals/referral-code.service';
|
||||
import { ReferralTierService } from '../../src/referrals/referral-tier.service';
|
||||
import { ReferralTrackingService } from '../../src/referrals/referral-tracking.service';
|
||||
import configuration from '../../src/config/configuration';
|
||||
|
||||
// Mock services that BetterAuthService depends on
|
||||
const mockSecurityEventsService = {
|
||||
logEvent: jest.fn().mockResolvedValue(undefined),
|
||||
};
|
||||
|
||||
const mockReferralCodeService = {
|
||||
createAutoCode: jest.fn().mockResolvedValue({ id: 'code-123', code: 'ABC123' }),
|
||||
};
|
||||
|
||||
const mockReferralTierService = {
|
||||
getTierBenefits: jest.fn().mockResolvedValue({ maxReferrals: 10 }),
|
||||
};
|
||||
|
||||
const mockReferralTrackingService = {
|
||||
trackReferral: jest.fn().mockResolvedValue(undefined),
|
||||
};
|
||||
|
||||
describe('Role Security Integration Tests', () => {
|
||||
let betterAuthService: BetterAuthService;
|
||||
let module: TestingModule;
|
||||
|
|
@ -29,7 +50,13 @@ describe('Role Security Integration Tests', () => {
|
|||
isGlobal: true,
|
||||
}),
|
||||
],
|
||||
providers: [BetterAuthService],
|
||||
providers: [
|
||||
BetterAuthService,
|
||||
{ provide: SecurityEventsService, useValue: mockSecurityEventsService },
|
||||
{ provide: ReferralCodeService, useValue: mockReferralCodeService },
|
||||
{ provide: ReferralTierService, useValue: mockReferralTierService },
|
||||
{ provide: ReferralTrackingService, useValue: mockReferralTrackingService },
|
||||
],
|
||||
}).compile();
|
||||
|
||||
betterAuthService = module.get<BetterAuthService>(BetterAuthService);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue