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,17 +1,17 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { OrdersController } from './orders.controller';
|
||||
import { OrdersService } from './orders.service';
|
||||
import { Test, TestingModule } from "@nestjs/testing";
|
||||
import { OrdersController } from "./orders.controller";
|
||||
import { OrdersService } from "./orders.service";
|
||||
|
||||
describe('OrdersController', () => {
|
||||
describe("OrdersController", () => {
|
||||
let controller: OrdersController;
|
||||
let service: OrdersService;
|
||||
|
||||
const mockOrdersService = {
|
||||
create: jest.fn().mockResolvedValue({ id: 'order-id', totalAmount: 1000 }),
|
||||
create: jest.fn().mockResolvedValue({ id: "order-id", totalAmount: 1000 }),
|
||||
findAllByUser: jest
|
||||
.fn()
|
||||
.mockResolvedValue([{ id: 'order-id', totalAmount: 1000 }]),
|
||||
findOne: jest.fn().mockResolvedValue({ id: 'order-id', totalAmount: 1000 }),
|
||||
.mockResolvedValue([{ id: "order-id", totalAmount: 1000 }]),
|
||||
findOne: jest.fn().mockResolvedValue({ id: "order-id", totalAmount: 1000 }),
|
||||
};
|
||||
|
||||
beforeEach(async () => {
|
||||
@@ -28,29 +28,29 @@ describe('OrdersController', () => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
it("should be defined", () => {
|
||||
expect(controller).toBeDefined();
|
||||
});
|
||||
|
||||
it('should create order', async () => {
|
||||
const req = { user: { id: 'user-id' } };
|
||||
const dto = { items: [{ productId: 'prod-1', quantity: 2 }] };
|
||||
it("should create order", async () => {
|
||||
const req = { user: { id: "user-id" } };
|
||||
const dto = { items: [{ productId: "prod-1", quantity: 2 }] };
|
||||
const result = await controller.create(req, dto);
|
||||
expect(service.create).toHaveBeenCalledWith('user-id', dto);
|
||||
expect(result.id).toBe('order-id');
|
||||
expect(service.create).toHaveBeenCalledWith("user-id", dto);
|
||||
expect(result.id).toBe("order-id");
|
||||
});
|
||||
|
||||
it('should list orders of user', async () => {
|
||||
const req = { user: { id: 'user-id' } };
|
||||
it("should list orders of user", async () => {
|
||||
const req = { user: { id: "user-id" } };
|
||||
const result = await controller.findAll(req, {});
|
||||
expect(service.findAllByUser).toHaveBeenCalledWith('user-id', {});
|
||||
expect(service.findAllByUser).toHaveBeenCalledWith("user-id", {});
|
||||
expect(result).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('should find one order', async () => {
|
||||
const req = { user: { id: 'user-id' } };
|
||||
const result = await controller.findOne(req, 'order-id');
|
||||
expect(service.findOne).toHaveBeenCalledWith('order-id', 'user-id');
|
||||
expect(result.id).toBe('order-id');
|
||||
it("should find one order", async () => {
|
||||
const req = { user: { id: "user-id" } };
|
||||
const result = await controller.findOne(req, "order-id");
|
||||
expect(service.findOne).toHaveBeenCalledWith("order-id", "user-id");
|
||||
expect(result.id).toBe("order-id");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user