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
@@ -1,4 +1,4 @@
|
||||
import { ComponentType, lazy } from 'react';
|
||||
import { type ComponentType,lazy } from 'react';
|
||||
|
||||
/**
|
||||
* Wraps dynamic React.lazy imports with retry logic and auto cache-busting
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
import { describe,expect,it } from 'vitest';
|
||||
import { applyRounding,calculateSellingPrice,DEFAULT_PRICING_SETTINGS } from './pricing';
|
||||
|
||||
describe('pricing utilities', () => {
|
||||
describe('applyRounding', () => {
|
||||
it('returns 0 for negative, 0, or NaN prices', () => {
|
||||
expect(applyRounding(0)).toBe(0);
|
||||
expect(applyRounding(-1000)).toBe(0);
|
||||
expect(applyRounding(NaN)).toBe(0);
|
||||
});
|
||||
|
||||
it('rounds price UP according to step', () => {
|
||||
expect(applyRounding(10200, 5000, 'UP')).toBe(15000);
|
||||
expect(applyRounding(10000, 5000, 'UP')).toBe(10000);
|
||||
expect(applyRounding(10001, 1000, 'UP')).toBe(11000);
|
||||
});
|
||||
|
||||
it('rounds price DOWN according to step', () => {
|
||||
expect(applyRounding(14800, 5000, 'DOWN')).toBe(10000);
|
||||
expect(applyRounding(15000, 5000, 'DOWN')).toBe(15000);
|
||||
expect(applyRounding(12900, 1000, 'DOWN')).toBe(12000);
|
||||
});
|
||||
|
||||
it('rounds price NEAREST according to step', () => {
|
||||
expect(applyRounding(12499, 5000, 'NEAREST')).toBe(10000);
|
||||
expect(applyRounding(12500, 5000, 'NEAREST')).toBe(15000);
|
||||
expect(applyRounding(12700, 5000, 'NEAREST')).toBe(15000);
|
||||
});
|
||||
|
||||
it('handles step <= 1 by Math.round', () => {
|
||||
expect(applyRounding(123.4, 1)).toBe(123);
|
||||
expect(applyRounding(123.6, 0)).toBe(124);
|
||||
});
|
||||
});
|
||||
|
||||
describe('calculateSellingPrice', () => {
|
||||
it('returns 0 for non-positive or NaN buyPrice', () => {
|
||||
expect(calculateSellingPrice(0, 20)).toBe(0);
|
||||
expect(calculateSellingPrice(-500, 20)).toBe(0);
|
||||
expect(calculateSellingPrice(NaN, 20)).toBe(0);
|
||||
});
|
||||
|
||||
it('calculates selling price with retail margin and default UP rounding', () => {
|
||||
// 100,000 * 1.30 = 130,000 -> already multiple of 5000
|
||||
expect(calculateSellingPrice(100000, 30, 5000, 'UP')).toBe(130000);
|
||||
|
||||
// 100,000 * 1.15 = 115,000
|
||||
expect(calculateSellingPrice(100000, 15, 5000, 'UP')).toBe(115000);
|
||||
|
||||
// 10,000 * 1.23 = 12,300 -> round UP with step 5000 -> 15,000
|
||||
expect(calculateSellingPrice(10000, 23, 5000, 'UP')).toBe(15000);
|
||||
|
||||
// 10,000 * 1.23 = 12,300 -> round DOWN with step 5000 -> 10,000
|
||||
expect(calculateSellingPrice(10000, 23, 5000, 'DOWN')).toBe(10000);
|
||||
});
|
||||
|
||||
it('handles 0% margin correctly', () => {
|
||||
expect(calculateSellingPrice(10000, 0, 5000, 'UP')).toBe(10000);
|
||||
});
|
||||
|
||||
it('uses DEFAULT_PRICING_SETTINGS defaults properly', () => {
|
||||
expect(DEFAULT_PRICING_SETTINGS.roundingStep).toBe(5000);
|
||||
expect(DEFAULT_PRICING_SETTINGS.roundingMode).toBe('UP');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useCallback,useMemo } from 'react';
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
|
||||
export interface UseTableParamsOptions {
|
||||
defaultSortBy?: string;
|
||||
|
||||
Reference in new issue
Block a user