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

@@ -3,6 +3,7 @@ import {
Controller,
Delete,
Get,
HttpCode,
Param,
ParseIntPipe,
Post,
@@ -25,6 +26,20 @@ export class SaleReceiptsController {
return this.saleReceiptApplication.createSaleReceipt(saleReceiptDTO);
}
@Put(':id/mail')
@HttpCode(200)
@ApiOperation({ summary: 'Send the sale receipt mail.' })
sendSaleReceiptMail(@Param('id', ParseIntPipe) id: number) {
return this.saleReceiptApplication.getSaleReceiptMail(id);
}
@Get(':id/mail')
@HttpCode(200)
@ApiOperation({ summary: 'Retrieves the sale receipt mail.' })
getSaleReceiptMail(@Param('id', ParseIntPipe) id: number) {
return this.saleReceiptApplication.getSaleReceiptMail(id);
}
@Put(':id')
@ApiOperation({ summary: 'Edit the given sale receipt.' })
editSaleReceipt(

View File

@@ -4,7 +4,7 @@ import {
} from '../constants';
import { mergeAndValidateMailOptions } from '@/modules/MailNotification/utils';
import { transformReceiptToMailDataArgs } from '../utils';
import { Injectable } from '@nestjs/common';
import { Inject, Injectable } from '@nestjs/common';
import { GetSaleReceipt } from '../queries/GetSaleReceipt.service';
import { SaleReceiptsPdfService } from '../queries/SaleReceiptsPdf.service';
import { ContactMailNotification } from '@/modules/MailNotification/ContactMailNotification';
@@ -34,6 +34,9 @@ export class SaleReceiptMailNotification {
private readonly contactMailNotification: ContactMailNotification,
private readonly eventEmitter: EventEmitter2,
private readonly mailTransporter: MailTransporter,
@Inject(SaleReceipt.name)
private readonly saleReceiptModel: typeof SaleReceipt
) {}
/**
@@ -67,7 +70,7 @@ export class SaleReceiptMailNotification {
public async getMailOptions(
saleReceiptId: number,
): Promise<SaleReceiptMailOpts> {
const saleReceipt = await SaleReceipt.query()
const saleReceipt = await this.saleReceiptModel.query()
.findById(saleReceiptId)
.throwIfNotFound();