Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b20d3a2
🔧 Configuration: Disable padding-line-between-statements rule in ESLi…
grananda Apr 2, 2025
0534d83
🔧 Configuration: Add lint script and update dependencies for improved…
grananda Apr 2, 2025
f9ea8b9
🔧 Configuration: Add esModuleInterop to TypeScript configuration for …
grananda Apr 2, 2025
c211390
✨ Birthdate Implementation: Add DatepickerComponent with template, st…
grananda Apr 2, 2025
6649642
✨ Birthdate Implementation: Integrate DatepickerComponent into input …
grananda Apr 2, 2025
36668bd
✨ Birthdate Implementation: Update quote service tests to include geb…
grananda Apr 2, 2025
564c4bb
✨ Birthdate Implementation: Add geburtsdatum field to InputState stor…
grananda Apr 2, 2025
7659faf
✨ Birthdate Implementation: Add geburtsdatum validation schema to enf…
grananda Apr 2, 2025
98fe492
✨ Birthdate Implementation: Update backend getQuote test to validate …
grananda Apr 2, 2025
73c24d3
✨ Birthdate Implementation: Update backend getQuote method to include…
grananda Apr 2, 2025
c362592
✨ Loading State Feedback: Add loading spinner to InputLibComponent du…
grananda Apr 2, 2025
4bf5bd3
✨ Infrastructure: Generate UI library for common Angular UI components
grananda Apr 3, 2025
a85b433
✨ Error Handling: Add error handling component to display error API r…
grananda Apr 3, 2025
54423c7
✨ Quote Summary Page: Quote state store decoupling from quote
grananda Apr 4, 2025
1f078e3
✨ Quote Summary Page: create quote summary component lib
grananda Apr 4, 2025
bfdfafa
✨ Quote Summary Page: extend quote summary for data fetching
grananda Apr 4, 2025
8152270
✨ Quote Summary Page: remove form submission result
grananda Apr 4, 2025
b5e35be
✨ Quote Summary Page: Long String Generator: add service and unit tes…
Apr 7, 2025
2b31d9d
Quote Summary Page:Implement quote view flow
Apr 7, 2025
f56afa7
Quote Summary Page:Implement quote view resolver
Apr 7, 2025
94cb7a9
Code Cleanup: input-lib refactoring
Apr 8, 2025
9d7013c
Test Refactoring: Enhance tests and remove unused code
Apr 10, 2025
9f7febc
Code Cleanup: clean up interfaces and arrange FE libs
grananda Apr 10, 2025
8e1c534
Code Cleanup: move code classes to new libs
grananda Apr 10, 2025
04b0330
Fix: fix validation message
grananda Apr 10, 2025
c5b78d8
Fix: add missing service test
grananda Apr 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 0 additions & 57 deletions backend/apps/bff/src/app/__tests__/app.controller.spec.ts

This file was deleted.

16 changes: 0 additions & 16 deletions backend/apps/bff/src/app/app.controller.ts

This file was deleted.

7 changes: 2 additions & 5 deletions backend/apps/bff/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { Module } from '@nestjs/common';

import { AppController } from './app.controller';
import { QuoteService } from './services/quote/quote.service';
import { QuoteModule } from '../quote/quote.module';

@Module({
imports: [],
controllers: [AppController],
providers: [QuoteService],
imports: [QuoteModule],
})
export class AppModule {}

This file was deleted.

33 changes: 0 additions & 33 deletions backend/apps/bff/src/app/services/quote/quote.service.ts

This file was deleted.

10 changes: 10 additions & 0 deletions backend/apps/bff/src/common/common.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Module } from '@nestjs/common';

import { LongStringGeneratorService } from './services/long-string-generator/long-string-generator.service';
import { TimingService } from './services/timing/timing.service';

@Module({
providers: [LongStringGeneratorService, TimingService],
exports: [LongStringGeneratorService, TimingService],
})
export class CommonModule {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Test, TestingModule } from '@nestjs/testing';

import { LongStringGeneratorService } from './long-string-generator.service';

describe('LongStringGeneratorService', () => {
let service: LongStringGeneratorService;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [LongStringGeneratorService],
}).compile();

service = module.get<LongStringGeneratorService>(
LongStringGeneratorService
);
});

it('should be defined', () => {
expect(service).toBeDefined();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Injectable } from '@nestjs/common';
import { randomBytes } from 'crypto';

@Injectable()
export class LongStringGeneratorService {
generate(size = 10) {
return randomBytes(size).toString('hex');
}
}
18 changes: 18 additions & 0 deletions backend/apps/bff/src/common/services/timing/timing.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { TimingService } from './timing.service';

describe('TimingService', () => {
let service: TimingService;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [TimingService],
}).compile();

service = module.get<TimingService>(TimingService);
});

it('should be defined', () => {
expect(service).toBeDefined();
});
});
5 changes: 5 additions & 0 deletions backend/apps/bff/src/common/services/timing/timing.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export class TimingService {
static async sleep(ms: number = 4000): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import { fakerEN } from '@faker-js/faker';
import { Test, TestingModule } from '@nestjs/testing';
import { QuoteRequestDto } from '@target/interfaces';

import { QuoteSchema } from '../../data/schema/quote.schema';
import { QuoteService } from '../../services/quote/quote.service';
import { QuoteController } from '../quoteController';

describe('QuotaController', () => {
let appController: QuoteController;
let quoteService: jest.Mocked<QuoteService>;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [QuoteController],
providers: [
{
provide: QuoteService,
useValue: { calculateQuote: jest.fn(), createQuote: jest.fn() },
},
],
}).compile();

appController = module.get<QuoteController>(QuoteController);
quoteService = module.get(QuoteService);
});

it('should be defined', () => {
expect(appController).toBeDefined();
expect(quoteService).toBeDefined();
});

describe('getQuote', () => {
it('should call process quote with a valid birthday', async () => {
const mockQuoteDto: QuoteRequestDto = {
geburtsdatum: '2020-01-01',
leistungsVorgabe: 'Beitrag',
beitrag: 1000,
berechnungDerLaufzeit: 'Alter bei Rentenbeginn',
laufzeit: 10,
beitragszahlungsweise: 'Einmalbeitrag',
rentenzahlungsweise: 'Monatliche Renten',
};

const calculatedQuote: Omit<QuoteSchema, 'id'> = {
basisdaten: {
geburtsdatum: '2020-01-01',
versicherungsbeginn: '2024-01-01',
garantieniveau: '100%',
alterBeiRentenbeginn: 67,
aufschubdauer: 30,
beitragszahlungsdauer: 30,
},
leistungsmerkmale: {
garantierteMindestrente: 1000,
einmaligesGarantiekapital: 50000,
todesfallleistungAbAltersrentenbezug: 40000,
},
beitrag: {
einmalbeitrag: 50000,
beitragsdynamik: '3%',
},
};

const expectedQuote = {
...calculatedQuote,
id: fakerEN.string.alpha({ length: 15 }),
};

jest
.spyOn(quoteService, 'calculateQuote')
.mockReturnValueOnce(calculatedQuote);
jest
.spyOn(quoteService, 'createQuote')
.mockResolvedValueOnce(expectedQuote);

const result = await appController.post(mockQuoteDto);

expect(quoteService.calculateQuote).toHaveBeenCalledWith({
beitrag: mockQuoteDto.beitrag,
geburtsdatum: mockQuoteDto.geburtsdatum,
});
expect(quoteService.calculateQuote).toHaveBeenCalledTimes(1);

expect(quoteService.createQuote).toHaveBeenCalledWith(calculatedQuote);
expect(quoteService.createQuote).toHaveBeenCalledTimes(1);

expect(result).toBe(expectedQuote);
});
});
});
29 changes: 29 additions & 0 deletions backend/apps/bff/src/quote/controllers/quoteController.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Body, Controller, Get, Param, Post } from '@nestjs/common';
import { QuoteRequestDto, QuoteResponseDto } from '@target/interfaces';
import { InputDtoSchema } from '@target/validations';

import { QuoteSchema } from '../data/schema/quote.schema';
import { ValidationPipe } from '../pipes/validation.pipe';
import { QuoteService } from '../services/quote/quote.service';

@Controller('/quote')
export class QuoteController {
constructor(private readonly quoteService: QuoteService) {}

@Post()
async post(
@Body(new ValidationPipe(InputDtoSchema)) quoteDto: QuoteRequestDto
): Promise<QuoteResponseDto> {
const quote = this.quoteService.calculateQuote({
beitrag: quoteDto.beitrag,
geburtsdatum: quoteDto.geburtsdatum,
});

return await this.quoteService.createQuote(quote);
}

@Get('/:id')
async get(@Param('id') id: string): Promise<QuoteSchema> {
return await this.quoteService.findOnById(id);
}
}
Loading