refactor: e2e test cases

This commit is contained in:
Ahmed Bouhuolia
2025-01-15 17:02:42 +02:00
parent 271c46ea3b
commit 108d286f62
14 changed files with 362 additions and 115 deletions

View File

@@ -13,7 +13,7 @@ import { CreateAccountDTO } from './CreateAccount.dto';
import { EditAccountDTO } from './EditAccount.dto';
import { PublicRoute } from '../Auth/Jwt.guard';
import { IAccountsFilter, IAccountsTransactionsFilter } from './Accounts.types';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
// import { IAccountsFilter, IAccountsTransactionsFilter } from './Accounts.types';
// import { ZodValidationPipe } from '@/common/pipes/ZodValidation.pipe';
@@ -25,12 +25,20 @@ export class AccountsController {
@Post()
@ApiOperation({ summary: 'Create an account' })
@ApiResponse({
status: 200,
description: 'The account has been successfully created.',
})
async createAccount(@Body() accountDTO: CreateAccountDTO) {
return this.accountsApplication.createAccount(accountDTO);
}
@Post(':id')
@ApiOperation({ summary: 'Edit the given account.' })
@ApiResponse({
status: 200,
description: 'The account has been successfully updated.',
})
async editAccount(
@Param('id', ParseIntPipe) id: number,
@Body() accountDTO: EditAccountDTO,
@@ -40,12 +48,20 @@ export class AccountsController {
@Delete(':id')
@ApiOperation({ summary: 'Delete the given account.' })
@ApiResponse({
status: 200,
description: 'The account has been successfully deleted.',
})
async deleteAccount(@Param('id', ParseIntPipe) id: number) {
return this.accountsApplication.deleteAccount(id);
}
@Post(':id/activate')
@ApiOperation({ summary: 'Activate the given account.' })
@ApiResponse({
status: 200,
description: 'The account has been successfully activated.',
})
async activateAccount(@Param('id', ParseIntPipe) id: number) {
return this.accountsApplication.activateAccount(id);
}
@@ -58,26 +74,41 @@ export class AccountsController {
@Get('types')
@ApiOperation({ summary: 'Retrieves the account types.' })
@ApiResponse({
status: 200,
description: 'The account types have been successfully retrieved.',
})
async getAccountTypes() {
return this.accountsApplication.getAccountTypes();
}
@Get('transactions')
@ApiOperation({ summary: 'Retrieves the account transactions.' })
@ApiResponse({
status: 200,
description: 'The account transactions have been successfully retrieved.',
})
async getAccountTransactions(@Query() filter: IAccountsTransactionsFilter) {
return this.accountsApplication.getAccountsTransactions(filter);
}
@Get(':id')
@ApiOperation({ summary: 'Retrieves the account details.' })
@ApiResponse({
status: 200,
description: 'The account details have been successfully retrieved.',
})
async getAccount(@Param('id', ParseIntPipe) id: number) {
return this.accountsApplication.getAccount(id);
}
@Get()
@ApiOperation({ summary: 'Retrieves the accounts.' })
@ApiResponse({
status: 200,
description: 'The accounts have been successfully retrieved.',
})
async getAccounts(@Query() filter: IAccountsFilter) {
return this.accountsApplication.getAccounts(filter);
}
}