test: comprehensive test suites and quality gates pass across backend, storefront and admin
- Backend (NestJS): 82 suites, 641 tests passing; 0 ESLint errors; 0 tsc errors. Hardened SSL cert/key matching, SSRF IP pinning, and eBank validation. - Admin Panel (Vite/React): 48 suites, 300 tests passing; 0 ESLint errors; 0 tsc errors. Full coverage across all pages and settings. - Storefront (Next.js): 62 suites, 368 tests passing; 0 ESLint errors; 0 tsc errors. - Fixed unmount lifecycle guards, promise error handling, and component edge cases.
This commit is contained in:
1 parent
1e73715169
commit
ddbf1ca026
439 files changed
+32911
-6107
No files matched your search
@@ -3,13 +3,13 @@ import {
|
||||
BadRequestException,
|
||||
NotFoundException,
|
||||
Optional,
|
||||
} from '@nestjs/common';
|
||||
import { Prisma } from '@prisma/client';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { SmsService } from '../common/services/sms.service';
|
||||
import * as bcrypt from 'bcryptjs';
|
||||
import { normalizeMobile } from '../common/utils/phone.utils';
|
||||
import { UpdateProfileDto } from './dto/update-profile.dto';
|
||||
} from "@nestjs/common";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { PrismaService } from "../prisma/prisma.service";
|
||||
import { SmsService } from "../common/services/sms.service";
|
||||
import * as bcrypt from "bcryptjs";
|
||||
import { normalizeMobile } from "../common/utils/phone.utils";
|
||||
import { UpdateProfileDto } from "./dto/update-profile.dto";
|
||||
|
||||
export interface UserAddressInput {
|
||||
title: string;
|
||||
@@ -45,7 +45,7 @@ export class UsersService {
|
||||
},
|
||||
},
|
||||
orders: {
|
||||
orderBy: { createdAt: 'desc' },
|
||||
orderBy: { createdAt: "desc" },
|
||||
include: {
|
||||
orderItems: {
|
||||
include: { product: true },
|
||||
@@ -54,7 +54,7 @@ export class UsersService {
|
||||
},
|
||||
addresses: true,
|
||||
walletTransactions: {
|
||||
orderBy: { createdAt: 'desc' },
|
||||
orderBy: { createdAt: "desc" },
|
||||
take: 50,
|
||||
},
|
||||
},
|
||||
@@ -72,7 +72,7 @@ export class UsersService {
|
||||
async update(id: string, dto: UpdateProfileDto) {
|
||||
const user = await this.prisma.user.findUnique({ where: { id } });
|
||||
if (!user) {
|
||||
throw new NotFoundException('کاربر یافت نشد');
|
||||
throw new NotFoundException("کاربر یافت نشد");
|
||||
}
|
||||
|
||||
const updateData: Prisma.UserUpdateInput = {};
|
||||
@@ -89,7 +89,7 @@ export class UsersService {
|
||||
});
|
||||
if (existing && existing.id !== id) {
|
||||
throw new BadRequestException(
|
||||
'این شماره موبایل قبلاً توسط کاربر دیگری ثبت شده است',
|
||||
"این شماره موبایل قبلاً توسط کاربر دیگری ثبت شده است",
|
||||
);
|
||||
}
|
||||
updateData.mobile = normalizedMobile;
|
||||
@@ -104,7 +104,7 @@ export class UsersService {
|
||||
});
|
||||
if (existing && existing.id !== id) {
|
||||
throw new BadRequestException(
|
||||
'این آدرس ایمیل قبلاً توسط کاربر دیگری ثبت شده است',
|
||||
"این آدرس ایمیل قبلاً توسط کاربر دیگری ثبت شده است",
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -116,7 +116,7 @@ export class UsersService {
|
||||
if (user.password) {
|
||||
if (!dto.currentPassword) {
|
||||
throw new BadRequestException(
|
||||
'برای تغییر رمز عبور، وارد کردن رمز عبور فعلی الزامی است',
|
||||
"برای تغییر رمز عبور، وارد کردن رمز عبور فعلی الزامی است",
|
||||
);
|
||||
}
|
||||
const isCurrentMatch = await bcrypt.compare(
|
||||
@@ -124,7 +124,7 @@ export class UsersService {
|
||||
user.password,
|
||||
);
|
||||
if (!isCurrentMatch) {
|
||||
throw new BadRequestException('رمز عبور فعلی اشتباه است');
|
||||
throw new BadRequestException("رمز عبور فعلی اشتباه است");
|
||||
}
|
||||
}
|
||||
updateData.password = await bcrypt.hash(dto.password.trim(), 10);
|
||||
@@ -221,7 +221,7 @@ export class UsersService {
|
||||
|
||||
async topUpWallet(userId: string, amount: number) {
|
||||
if (amount <= 0) {
|
||||
throw new Error('مبلغ شارژ باید بزرگتر از صفر باشد');
|
||||
throw new Error("مبلغ شارژ باید بزرگتر از صفر باشد");
|
||||
}
|
||||
|
||||
const [transaction, updatedUser] = await this.prisma.$transaction([
|
||||
@@ -229,9 +229,9 @@ export class UsersService {
|
||||
data: {
|
||||
userId,
|
||||
amount,
|
||||
type: 'deposit',
|
||||
status: 'completed',
|
||||
description: 'شارژ کیف پول',
|
||||
type: "deposit",
|
||||
status: "completed",
|
||||
description: "شارژ کیف پول",
|
||||
},
|
||||
}),
|
||||
this.prisma.user.update({
|
||||
@@ -244,22 +244,22 @@ export class UsersService {
|
||||
try {
|
||||
const customerFullName = (
|
||||
updatedUser.firstName
|
||||
? `${updatedUser.firstName} ${updatedUser.lastName || ''}`
|
||||
: 'کاربر گرامی'
|
||||
? `${updatedUser.firstName} ${updatedUser.lastName || ""}`
|
||||
: "کاربر گرامی"
|
||||
).trim();
|
||||
const topupData = {
|
||||
customerName: customerFullName,
|
||||
customerPhone: updatedUser.mobile,
|
||||
amount: Number(amount || 0).toLocaleString('fa-IR'),
|
||||
amount: Number(amount || 0).toLocaleString("fa-IR"),
|
||||
balance: Number(updatedUser.walletBalance || 0).toLocaleString(
|
||||
'fa-IR',
|
||||
"fa-IR",
|
||||
),
|
||||
reason: 'افزایش موجودی کیف پول',
|
||||
date: new Date().toLocaleDateString('fa-IR'),
|
||||
reason: "افزایش موجودی کیف پول",
|
||||
date: new Date().toLocaleDateString("fa-IR"),
|
||||
};
|
||||
|
||||
this.smsService
|
||||
.triggerEvent('WALLET_CHARGED', topupData)
|
||||
.triggerEvent("WALLET_CHARGED", topupData)
|
||||
.catch(() => {});
|
||||
} catch (err) {
|
||||
// Silently catch SMS error
|
||||
|
||||
Reference in new issue
Block a user