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
@@ -10,11 +10,11 @@ import {
|
||||
Req,
|
||||
HttpStatus,
|
||||
BadRequestException,
|
||||
} from '@nestjs/common';
|
||||
import { UsersService } from './users.service';
|
||||
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||
import { RolesGuard } from '../common/guards/roles.guard';
|
||||
import { Roles } from '../common/decorators/roles.decorator';
|
||||
} from "@nestjs/common";
|
||||
import { UsersService } from "./users.service";
|
||||
import { JwtAuthGuard } from "../auth/jwt-auth.guard";
|
||||
import { RolesGuard } from "../common/guards/roles.guard";
|
||||
import { Roles } from "../common/decorators/roles.decorator";
|
||||
import {
|
||||
ApiTags,
|
||||
ApiBearerAuth,
|
||||
@@ -23,21 +23,21 @@ import {
|
||||
ApiOkResponse,
|
||||
ApiCreatedResponse,
|
||||
ApiBadRequestResponse,
|
||||
} from '@nestjs/swagger';
|
||||
import { UpdateProfileDto } from './dto/update-profile.dto';
|
||||
import { AddressDto } from './dto/address.dto';
|
||||
} from "@nestjs/swagger";
|
||||
import { UpdateProfileDto } from "./dto/update-profile.dto";
|
||||
import { AddressDto } from "./dto/address.dto";
|
||||
|
||||
@ApiTags('Users - مدیریت کاربران و آدرسها')
|
||||
@ApiTags("Users - مدیریت کاربران و آدرسها")
|
||||
@ApiBearerAuth()
|
||||
@Controller('users')
|
||||
@Controller("users")
|
||||
@ApiResponse({
|
||||
status: HttpStatus.UNAUTHORIZED,
|
||||
description: 'عدم احراز هویت - توکن معتبر نیست یا ارسال نشده است',
|
||||
description: "عدم احراز هویت - توکن معتبر نیست یا ارسال نشده است",
|
||||
schema: {
|
||||
example: {
|
||||
success: false,
|
||||
message: 'Unauthorized',
|
||||
code: 'UNAUTHORIZED',
|
||||
message: "Unauthorized",
|
||||
code: "UNAUTHORIZED",
|
||||
details: {},
|
||||
},
|
||||
},
|
||||
@@ -46,24 +46,24 @@ export class UsersController {
|
||||
constructor(private readonly usersService: UsersService) {}
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Get('profile')
|
||||
@ApiOperation({ summary: 'دریافت پروفایل کاربر فعلی' })
|
||||
@Get("profile")
|
||||
@ApiOperation({ summary: "دریافت پروفایل کاربر فعلی" })
|
||||
@ApiOkResponse({
|
||||
description: 'مشخصات کامل کاربر به همراه آدرسها و اطلاعات حیوانات خانگی',
|
||||
description: "مشخصات کامل کاربر به همراه آدرسها و اطلاعات حیوانات خانگی",
|
||||
schema: {
|
||||
example: {
|
||||
id: 'd8c4e428-cd2f-4c55-bfa3-dfa312bb6480',
|
||||
firstName: 'کاربر',
|
||||
lastName: 'جدید',
|
||||
email: '09123456789@temp.local',
|
||||
mobile: '09123456789',
|
||||
role: 'User_PetOwner',
|
||||
walletBalance: '1500000.00',
|
||||
charityDonationTotal: '25000.00',
|
||||
id: "d8c4e428-cd2f-4c55-bfa3-dfa312bb6480",
|
||||
firstName: "کاربر",
|
||||
lastName: "جدید",
|
||||
email: "09123456789@temp.local",
|
||||
mobile: "09123456789",
|
||||
role: "User_PetOwner",
|
||||
walletBalance: "1500000.00",
|
||||
charityDonationTotal: "25000.00",
|
||||
addresses: [],
|
||||
pets: [],
|
||||
createdAt: '2026-05-26T15:20:00.000Z',
|
||||
updatedAt: '2026-05-26T15:20:00.000Z',
|
||||
createdAt: "2026-05-26T15:20:00.000Z",
|
||||
updatedAt: "2026-05-26T15:20:00.000Z",
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -72,32 +72,32 @@ export class UsersController {
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Patch('profile')
|
||||
@ApiOperation({ summary: 'ویرایش پروفایل کاربر فعلی' })
|
||||
@Patch("profile")
|
||||
@ApiOperation({ summary: "ویرایش پروفایل کاربر فعلی" })
|
||||
@ApiOkResponse({
|
||||
description: 'پروفایل با موفقیت ویرایش شد',
|
||||
description: "پروفایل با موفقیت ویرایش شد",
|
||||
schema: {
|
||||
example: {
|
||||
id: 'd8c4e428-cd2f-4c55-bfa3-dfa312bb6480',
|
||||
firstName: 'علی',
|
||||
lastName: 'احمدی',
|
||||
email: 'ali@example.com',
|
||||
mobile: '09123456789',
|
||||
role: 'User_PetOwner',
|
||||
walletBalance: '1500000.00',
|
||||
charityDonationTotal: '25000.00',
|
||||
id: "d8c4e428-cd2f-4c55-bfa3-dfa312bb6480",
|
||||
firstName: "علی",
|
||||
lastName: "احمدی",
|
||||
email: "ali@example.com",
|
||||
mobile: "09123456789",
|
||||
role: "User_PetOwner",
|
||||
walletBalance: "1500000.00",
|
||||
charityDonationTotal: "25000.00",
|
||||
},
|
||||
},
|
||||
})
|
||||
@ApiBadRequestResponse({
|
||||
description: 'خطا در صحتسنجی فیلدهای ورودی',
|
||||
description: "خطا در صحتسنجی فیلدهای ورودی",
|
||||
schema: {
|
||||
example: {
|
||||
success: false,
|
||||
message: 'ایمیل نامعتبر است',
|
||||
code: 'BAD_REQUEST',
|
||||
message: "ایمیل نامعتبر است",
|
||||
code: "BAD_REQUEST",
|
||||
details: {
|
||||
message: ['ایمیل نامعتبر است'],
|
||||
message: ["ایمیل نامعتبر است"],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -110,23 +110,23 @@ export class UsersController {
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post('addresses')
|
||||
@ApiOperation({ summary: 'ایجاد آدرس جدید برای کاربر' })
|
||||
@Post("addresses")
|
||||
@ApiOperation({ summary: "ایجاد آدرس جدید برای کاربر" })
|
||||
@ApiCreatedResponse({
|
||||
description: 'آدرس جدید با موفقیت ایجاد شد',
|
||||
description: "آدرس جدید با موفقیت ایجاد شد",
|
||||
schema: {
|
||||
example: {
|
||||
id: 'b5a6c7d8-1234-5678-abcd-ef1234567890',
|
||||
userId: 'd8c4e428-cd2f-4c55-bfa3-dfa312bb6480',
|
||||
title: 'خانه',
|
||||
receptorName: 'علی احمدی',
|
||||
phone: '09123456789',
|
||||
province: 'تهران',
|
||||
city: 'تهران',
|
||||
detail: 'خیابان آزادی، کوچه مریم، پلاک ۱۰',
|
||||
zipCode: '1456789012',
|
||||
id: "b5a6c7d8-1234-5678-abcd-ef1234567890",
|
||||
userId: "d8c4e428-cd2f-4c55-bfa3-dfa312bb6480",
|
||||
title: "خانه",
|
||||
receptorName: "علی احمدی",
|
||||
phone: "09123456789",
|
||||
province: "تهران",
|
||||
city: "تهران",
|
||||
detail: "خیابان آزادی، کوچه مریم، پلاک ۱۰",
|
||||
zipCode: "1456789012",
|
||||
isDefault: false,
|
||||
createdAt: '2026-05-26T18:00:00.000Z',
|
||||
createdAt: "2026-05-26T18:00:00.000Z",
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -138,99 +138,99 @@ export class UsersController {
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Patch('addresses/:addressId')
|
||||
@ApiOperation({ summary: 'ویرایش آدرس کاربر' })
|
||||
@Patch("addresses/:addressId")
|
||||
@ApiOperation({ summary: "ویرایش آدرس کاربر" })
|
||||
@ApiOkResponse({
|
||||
description: 'آدرس با موفقیت ویرایش شد',
|
||||
description: "آدرس با موفقیت ویرایش شد",
|
||||
schema: {
|
||||
example: {
|
||||
id: 'b5a6c7d8-1234-5678-abcd-ef1234567890',
|
||||
userId: 'd8c4e428-cd2f-4c55-bfa3-dfa312bb6480',
|
||||
title: 'دفتر کار',
|
||||
receptorName: 'علی احمدی',
|
||||
phone: '09123456789',
|
||||
province: 'تهران',
|
||||
city: 'تهران',
|
||||
detail: 'خیابان ولیعصر، برج سپهر، طبقه ۴',
|
||||
zipCode: '1456789012',
|
||||
id: "b5a6c7d8-1234-5678-abcd-ef1234567890",
|
||||
userId: "d8c4e428-cd2f-4c55-bfa3-dfa312bb6480",
|
||||
title: "دفتر کار",
|
||||
receptorName: "علی احمدی",
|
||||
phone: "09123456789",
|
||||
province: "تهران",
|
||||
city: "تهران",
|
||||
detail: "خیابان ولیعصر، برج سپهر، طبقه ۴",
|
||||
zipCode: "1456789012",
|
||||
isDefault: false,
|
||||
createdAt: '2026-05-26T18:00:00.000Z',
|
||||
createdAt: "2026-05-26T18:00:00.000Z",
|
||||
},
|
||||
},
|
||||
})
|
||||
updateAddress(
|
||||
@Req() req: { user: { id: string } },
|
||||
@Param('addressId') addressId: string,
|
||||
@Param("addressId") addressId: string,
|
||||
@Body() addressDto: AddressDto,
|
||||
) {
|
||||
return this.usersService.updateAddress(req.user.id, addressId, addressDto);
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Delete('addresses/:addressId')
|
||||
@ApiOperation({ summary: 'حذف آدرس کاربر' })
|
||||
@Delete("addresses/:addressId")
|
||||
@ApiOperation({ summary: "حذف آدرس کاربر" })
|
||||
@ApiOkResponse({
|
||||
description: 'آدرس با موفقیت حذف شد',
|
||||
description: "آدرس با موفقیت حذف شد",
|
||||
schema: {
|
||||
example: {
|
||||
success: true,
|
||||
message: 'آدرس با موفقیت حذف شد',
|
||||
message: "آدرس با موفقیت حذف شد",
|
||||
},
|
||||
},
|
||||
})
|
||||
deleteAddress(
|
||||
@Req() req: { user: { id: string } },
|
||||
@Param('addressId') addressId: string,
|
||||
@Param("addressId") addressId: string,
|
||||
) {
|
||||
return this.usersService.deleteAddress(req.user.id, addressId);
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Patch('addresses/:addressId/default')
|
||||
@ApiOperation({ summary: 'انتخاب آدرس به عنوان پیشفرض' })
|
||||
@Patch("addresses/:addressId/default")
|
||||
@ApiOperation({ summary: "انتخاب آدرس به عنوان پیشفرض" })
|
||||
@ApiOkResponse({
|
||||
description: 'آدرس به عنوان پیشفرض ثبت شد',
|
||||
description: "آدرس به عنوان پیشفرض ثبت شد",
|
||||
schema: {
|
||||
example: {
|
||||
success: true,
|
||||
message: 'آدرس پیشفرض با موفقیت تغییر کرد',
|
||||
message: "آدرس پیشفرض با موفقیت تغییر کرد",
|
||||
},
|
||||
},
|
||||
})
|
||||
setDefaultAddress(
|
||||
@Req() req: { user: { id: string } },
|
||||
@Param('addressId') addressId: string,
|
||||
@Param("addressId") addressId: string,
|
||||
) {
|
||||
return this.usersService.setDefaultAddress(req.user.id, addressId);
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('Admin', 'ADMIN', 'SuperAdmin')
|
||||
@Roles("Admin", "ADMIN", "SuperAdmin")
|
||||
@ApiBearerAuth()
|
||||
@Post('wallet/top-up')
|
||||
@ApiOperation({ summary: 'شارژ دستی کیف پول کاربر (فقط مدیر سیستم)' })
|
||||
@Post("wallet/top-up")
|
||||
@ApiOperation({ summary: "شارژ دستی کیف پول کاربر (فقط مدیر سیستم)" })
|
||||
@ApiCreatedResponse({
|
||||
description: 'کیف پول با موفقیت شارژ شد',
|
||||
description: "کیف پول با موفقیت شارژ شد",
|
||||
schema: {
|
||||
example: {
|
||||
id: 'txn-uuid',
|
||||
userId: 'user-uuid',
|
||||
amount: '500000.00',
|
||||
type: 'deposit',
|
||||
status: 'completed',
|
||||
description: 'شارژ کیف پول',
|
||||
createdAt: '2026-07-11T08:00:00.000Z',
|
||||
id: "txn-uuid",
|
||||
userId: "user-uuid",
|
||||
amount: "500000.00",
|
||||
type: "deposit",
|
||||
status: "completed",
|
||||
description: "شارژ کیف پول",
|
||||
createdAt: "2026-07-11T08:00:00.000Z",
|
||||
},
|
||||
},
|
||||
})
|
||||
@ApiBadRequestResponse({ description: 'مبلغ نامعتبر است' })
|
||||
@ApiBadRequestResponse({ description: "مبلغ نامعتبر است" })
|
||||
async topUpWallet(
|
||||
@Req() req: { user: { id: string } },
|
||||
@Body() body: { amount: number; targetUserId?: string },
|
||||
) {
|
||||
const amount = Number(body.amount);
|
||||
if (!amount || amount <= 0) {
|
||||
throw new BadRequestException('مبلغ شارژ باید بزرگتر از صفر باشد');
|
||||
throw new BadRequestException("مبلغ شارژ باید بزرگتر از صفر باشد");
|
||||
}
|
||||
const targetUserId = body.targetUserId || req.user.id;
|
||||
return this.usersService.topUpWallet(targetUserId, amount);
|
||||
|
||||
Reference in new issue
Block a user