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,20 +1,20 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { UsersController } from './users.controller';
|
||||
import { UsersService } from './users.service';
|
||||
import { Test, TestingModule } from "@nestjs/testing";
|
||||
import { UsersController } from "./users.controller";
|
||||
import { UsersService } from "./users.service";
|
||||
|
||||
describe('UsersController', () => {
|
||||
describe("UsersController", () => {
|
||||
let controller: UsersController;
|
||||
let service: UsersService;
|
||||
|
||||
const mockUsersService = {
|
||||
findById: jest.fn().mockResolvedValue({ id: 'user-id', firstName: 'Test' }),
|
||||
findById: jest.fn().mockResolvedValue({ id: "user-id", firstName: "Test" }),
|
||||
update: jest
|
||||
.fn()
|
||||
.mockResolvedValue({ id: 'user-id', firstName: 'Updated' }),
|
||||
addAddress: jest.fn().mockResolvedValue({ id: 'addr-id', title: 'Home' }),
|
||||
.mockResolvedValue({ id: "user-id", firstName: "Updated" }),
|
||||
addAddress: jest.fn().mockResolvedValue({ id: "addr-id", title: "Home" }),
|
||||
updateAddress: jest
|
||||
.fn()
|
||||
.mockResolvedValue({ id: 'addr-id', title: 'Work' }),
|
||||
.mockResolvedValue({ id: "addr-id", title: "Work" }),
|
||||
deleteAddress: jest.fn().mockResolvedValue({ success: true }),
|
||||
setDefaultAddress: jest.fn().mockResolvedValue({ success: true }),
|
||||
};
|
||||
@@ -33,74 +33,74 @@ describe('UsersController', () => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
it("should be defined", () => {
|
||||
expect(controller).toBeDefined();
|
||||
});
|
||||
|
||||
it('should getProfile', async () => {
|
||||
const req = { user: { id: 'user-id' } };
|
||||
it("should getProfile", async () => {
|
||||
const req = { user: { id: "user-id" } };
|
||||
const result = await controller.getProfile(req);
|
||||
expect(service.findById).toHaveBeenCalledWith('user-id');
|
||||
expect(result?.id).toBe('user-id');
|
||||
expect(service.findById).toHaveBeenCalledWith("user-id");
|
||||
expect(result?.id).toBe("user-id");
|
||||
});
|
||||
|
||||
it('should updateProfile', async () => {
|
||||
const req = { user: { id: 'user-id' } };
|
||||
const dto = { firstName: 'Updated' };
|
||||
it("should updateProfile", async () => {
|
||||
const req = { user: { id: "user-id" } };
|
||||
const dto = { firstName: "Updated" };
|
||||
const result = await controller.updateProfile(req, dto);
|
||||
expect(service.update).toHaveBeenCalledWith('user-id', dto);
|
||||
expect(result.firstName).toBe('Updated');
|
||||
expect(service.update).toHaveBeenCalledWith("user-id", dto);
|
||||
expect(result.firstName).toBe("Updated");
|
||||
});
|
||||
|
||||
it('should addAddress', async () => {
|
||||
const req = { user: { id: 'user-id' } };
|
||||
it("should addAddress", async () => {
|
||||
const req = { user: { id: "user-id" } };
|
||||
const dto = {
|
||||
title: 'Home',
|
||||
receptorName: 'Ali',
|
||||
phone: '0912',
|
||||
province: 'Teh',
|
||||
city: 'Teh',
|
||||
detail: 'Det',
|
||||
zipCode: '123',
|
||||
title: "Home",
|
||||
receptorName: "Ali",
|
||||
phone: "0912",
|
||||
province: "Teh",
|
||||
city: "Teh",
|
||||
detail: "Det",
|
||||
zipCode: "123",
|
||||
};
|
||||
const result = await controller.addAddress(req, dto);
|
||||
expect(service.addAddress).toHaveBeenCalledWith('user-id', dto);
|
||||
expect(result.id).toBe('addr-id');
|
||||
expect(service.addAddress).toHaveBeenCalledWith("user-id", dto);
|
||||
expect(result.id).toBe("addr-id");
|
||||
});
|
||||
|
||||
it('should updateAddress', async () => {
|
||||
const req = { user: { id: 'user-id' } };
|
||||
it("should updateAddress", async () => {
|
||||
const req = { user: { id: "user-id" } };
|
||||
const dto = {
|
||||
title: 'Work',
|
||||
receptorName: 'Ali',
|
||||
phone: '0912',
|
||||
province: 'Teh',
|
||||
city: 'Teh',
|
||||
detail: 'Det',
|
||||
zipCode: '123',
|
||||
title: "Work",
|
||||
receptorName: "Ali",
|
||||
phone: "0912",
|
||||
province: "Teh",
|
||||
city: "Teh",
|
||||
detail: "Det",
|
||||
zipCode: "123",
|
||||
};
|
||||
const result = await controller.updateAddress(req, 'addr-id', dto);
|
||||
const result = await controller.updateAddress(req, "addr-id", dto);
|
||||
expect(service.updateAddress).toHaveBeenCalledWith(
|
||||
'user-id',
|
||||
'addr-id',
|
||||
"user-id",
|
||||
"addr-id",
|
||||
dto,
|
||||
);
|
||||
expect(result.title).toBe('Work');
|
||||
expect(result.title).toBe("Work");
|
||||
});
|
||||
|
||||
it('should deleteAddress', async () => {
|
||||
const req = { user: { id: 'user-id' } };
|
||||
const result = await controller.deleteAddress(req, 'addr-id');
|
||||
expect(service.deleteAddress).toHaveBeenCalledWith('user-id', 'addr-id');
|
||||
it("should deleteAddress", async () => {
|
||||
const req = { user: { id: "user-id" } };
|
||||
const result = await controller.deleteAddress(req, "addr-id");
|
||||
expect(service.deleteAddress).toHaveBeenCalledWith("user-id", "addr-id");
|
||||
expect(result).toBeDefined();
|
||||
});
|
||||
|
||||
it('should setDefaultAddress', async () => {
|
||||
const req = { user: { id: 'user-id' } };
|
||||
const result = await controller.setDefaultAddress(req, 'addr-id');
|
||||
it("should setDefaultAddress", async () => {
|
||||
const req = { user: { id: "user-id" } };
|
||||
const result = await controller.setDefaultAddress(req, "addr-id");
|
||||
expect(service.setDefaultAddress).toHaveBeenCalledWith(
|
||||
'user-id',
|
||||
'addr-id',
|
||||
"user-id",
|
||||
"addr-id",
|
||||
);
|
||||
expect(result).toBeDefined();
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user