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
@@ -5,31 +5,31 @@
|
||||
* 3. Converts +98 or 0098 prefixes to 0
|
||||
*/
|
||||
export function normalizeMobile(mobile: string | undefined | null): string {
|
||||
if (!mobile) return '';
|
||||
if (!mobile) return "";
|
||||
|
||||
const persianDigits = '۰۱۲۳۴۵۶۷۸۹';
|
||||
const arabicDigits = '٠١٢٣٤٥٦٧٨٩';
|
||||
const persianDigits = "۰۱۲۳۴۵۶۷۸۹";
|
||||
const arabicDigits = "٠١٢٣٤٥٦٧٨٩";
|
||||
|
||||
let clean = String(mobile).trim();
|
||||
|
||||
// Convert Persian & Arabic numbers
|
||||
for (let i = 0; i < 10; i++) {
|
||||
clean = clean.replace(new RegExp(persianDigits[i], 'g'), String(i));
|
||||
clean = clean.replace(new RegExp(arabicDigits[i], 'g'), String(i));
|
||||
clean = clean.replace(new RegExp(persianDigits[i], "g"), String(i));
|
||||
clean = clean.replace(new RegExp(arabicDigits[i], "g"), String(i));
|
||||
}
|
||||
|
||||
// Remove non-digits except +
|
||||
clean = clean.replace(/[^\d+]/g, '');
|
||||
clean = clean.replace(/[^\d+]/g, "");
|
||||
|
||||
// Normalize prefix
|
||||
if (clean.startsWith('+98')) {
|
||||
clean = '0' + clean.slice(3);
|
||||
} else if (clean.startsWith('0098')) {
|
||||
clean = '0' + clean.slice(4);
|
||||
} else if (clean.startsWith('98') && clean.length === 12) {
|
||||
clean = '0' + clean.slice(2);
|
||||
} else if (clean.length === 10 && !clean.startsWith('0')) {
|
||||
clean = '0' + clean;
|
||||
if (clean.startsWith("+98")) {
|
||||
clean = "0" + clean.slice(3);
|
||||
} else if (clean.startsWith("0098")) {
|
||||
clean = "0" + clean.slice(4);
|
||||
} else if (clean.startsWith("98") && clean.length === 12) {
|
||||
clean = "0" + clean.slice(2);
|
||||
} else if (clean.length === 10 && !clean.startsWith("0")) {
|
||||
clean = "0" + clean;
|
||||
}
|
||||
|
||||
return clean;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export type RoundingMode = 'UP' | 'DOWN' | 'NEAREST';
|
||||
export type RoundingMode = "UP" | "DOWN" | "NEAREST";
|
||||
|
||||
export interface PricingSettings {
|
||||
roundingStep: number;
|
||||
@@ -9,7 +9,7 @@ export interface PricingSettings {
|
||||
|
||||
export const DEFAULT_PRICING_SETTINGS: PricingSettings = {
|
||||
roundingStep: 5000,
|
||||
roundingMode: 'UP',
|
||||
roundingMode: "UP",
|
||||
defaultRetailMarginPercent: 30,
|
||||
defaultWholesaleMarginPercent: 15,
|
||||
};
|
||||
@@ -23,14 +23,14 @@ export const DEFAULT_PRICING_SETTINGS: PricingSettings = {
|
||||
export function applyRounding(
|
||||
price: number,
|
||||
step: number = 5000,
|
||||
mode: RoundingMode = 'UP',
|
||||
mode: RoundingMode = "UP",
|
||||
): number {
|
||||
if (isNaN(price) || price <= 0) return 0;
|
||||
if (!step || step <= 1) return Math.round(price);
|
||||
|
||||
if (mode === 'UP') {
|
||||
if (mode === "UP") {
|
||||
return Math.ceil(price / step) * step;
|
||||
} else if (mode === 'DOWN') {
|
||||
} else if (mode === "DOWN") {
|
||||
return Math.floor(price / step) * step;
|
||||
} else {
|
||||
return Math.round(price / step) * step;
|
||||
@@ -44,7 +44,7 @@ export function calculateSellingPrice(
|
||||
buyPrice: number,
|
||||
marginPercent: number,
|
||||
roundingStep: number = 5000,
|
||||
roundingMode: RoundingMode = 'UP',
|
||||
roundingMode: RoundingMode = "UP",
|
||||
): number {
|
||||
if (isNaN(buyPrice) || buyPrice <= 0) return 0;
|
||||
const rawPrice = buyPrice * (1 + (marginPercent || 0) / 100);
|
||||
|
||||
Reference in new issue
Block a user