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,5 +1,5 @@
|
||||
import { Module, Global } from '@nestjs/common';
|
||||
import { RedisService } from './redis.service';
|
||||
import { Module, Global } from "@nestjs/common";
|
||||
import { RedisService } from "./redis.service";
|
||||
|
||||
@Global()
|
||||
@Module({
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { RedisService } from './redis.service';
|
||||
import { Test, TestingModule } from "@nestjs/testing";
|
||||
import { RedisService } from "./redis.service";
|
||||
|
||||
jest.mock('ioredis', () => {
|
||||
jest.mock("ioredis", () => {
|
||||
return jest.fn().mockImplementation(() => {
|
||||
return {
|
||||
set: jest.fn(),
|
||||
get: jest.fn().mockResolvedValue('mock-value'),
|
||||
get: jest.fn().mockResolvedValue("mock-value"),
|
||||
del: jest.fn(),
|
||||
disconnect: jest.fn(),
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
describe('RedisService', () => {
|
||||
describe("RedisService", () => {
|
||||
let service: RedisService;
|
||||
|
||||
beforeEach(async () => {
|
||||
@@ -28,29 +28,29 @@ describe('RedisService', () => {
|
||||
service.onModuleDestroy();
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
it("should be defined", () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
|
||||
it('should call set with or without ttl', async () => {
|
||||
const setSpy = jest.spyOn((service as any).client, 'set');
|
||||
await service.set('key', 'val');
|
||||
expect(setSpy).toHaveBeenCalledWith('key', 'val');
|
||||
it("should call set with or without ttl", async () => {
|
||||
const setSpy = jest.spyOn((service as any).client, "set");
|
||||
await service.set("key", "val");
|
||||
expect(setSpy).toHaveBeenCalledWith("key", "val");
|
||||
|
||||
await service.set('key', 'val', 60);
|
||||
expect(setSpy).toHaveBeenCalledWith('key', 'val', 'EX', 60);
|
||||
await service.set("key", "val", 60);
|
||||
expect(setSpy).toHaveBeenCalledWith("key", "val", "EX", 60);
|
||||
});
|
||||
|
||||
it('should call get', async () => {
|
||||
const getSpy = jest.spyOn((service as any).client, 'get');
|
||||
const result = await service.get('key');
|
||||
expect(getSpy).toHaveBeenCalledWith('key');
|
||||
expect(result).toBe('mock-value');
|
||||
it("should call get", async () => {
|
||||
const getSpy = jest.spyOn((service as any).client, "get");
|
||||
const result = await service.get("key");
|
||||
expect(getSpy).toHaveBeenCalledWith("key");
|
||||
expect(result).toBe("mock-value");
|
||||
});
|
||||
|
||||
it('should call del', async () => {
|
||||
const delSpy = jest.spyOn((service as any).client, 'del');
|
||||
await service.del('key');
|
||||
expect(delSpy).toHaveBeenCalledWith('key');
|
||||
it("should call del", async () => {
|
||||
const delSpy = jest.spyOn((service as any).client, "del");
|
||||
await service.del("key");
|
||||
expect(delSpy).toHaveBeenCalledWith("key");
|
||||
});
|
||||
});
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Injectable, OnModuleDestroy, OnModuleInit } from '@nestjs/common';
|
||||
import Redis from 'ioredis';
|
||||
import { Injectable, OnModuleDestroy, OnModuleInit } from "@nestjs/common";
|
||||
import Redis from "ioredis";
|
||||
|
||||
@Injectable()
|
||||
export class RedisService implements OnModuleInit, OnModuleDestroy {
|
||||
@@ -7,7 +7,7 @@ export class RedisService implements OnModuleInit, OnModuleDestroy {
|
||||
|
||||
onModuleInit() {
|
||||
this.client = new Redis({
|
||||
host: process.env.REDIS_HOST || 'localhost',
|
||||
host: process.env.REDIS_HOST || "localhost",
|
||||
port: Number(process.env.REDIS_PORT) || 16379,
|
||||
password: process.env.REDIS_PASSWORD || undefined,
|
||||
});
|
||||
@@ -19,7 +19,7 @@ export class RedisService implements OnModuleInit, OnModuleDestroy {
|
||||
|
||||
async set(key: string, value: string, ttlSeconds?: number): Promise<void> {
|
||||
if (ttlSeconds) {
|
||||
await this.client.set(key, value, 'EX', ttlSeconds);
|
||||
await this.client.set(key, value, "EX", ttlSeconds);
|
||||
} else {
|
||||
await this.client.set(key, value);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user