test: comprehensive test suites and quality gates pass across backend, storefront and admin
Deploy Canina / deploy (push) Successful in 4m1s
E2E Playwright Tests / Run Full E2E & Security Suites (push) Failing after 7s

- 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:
devops committed 2026-10-13 16:01:00 +00:00
1 parent 1e73715169
commit ddbf1ca026
439 files changed
+32911 -6107

No files matched your search

+2 -2
View File
@@ -1,5 +1,5 @@
import { Global, Module } from '@nestjs/common';
import { PrismaService } from './prisma.service';
import { Global, Module } from "@nestjs/common";
import { PrismaService } from "./prisma.service";
@Global()
@Module({
+102
View File
@@ -0,0 +1,102 @@
import { PrismaService } from "./prisma.service";
// Replace the client class before importing the service: no native engine or DB.
jest.mock("@prisma/client", () => ({
PrismaClient: class {
$connect = jest.fn();
$disconnect = jest.fn();
$executeRawUnsafe = jest.fn();
},
}));
describe("PrismaService lifecycle", () => {
let service: PrismaService;
beforeEach(() => {
service = new PrismaService();
});
afterEach(() => jest.restoreAllMocks());
it("waits for connection before running idempotent DDL sequentially", async () => {
let connected = false;
let active = false;
jest.spyOn(service, "$connect").mockImplementation(async () => {
await Promise.resolve();
connected = true;
});
const execute = jest
.spyOn(
service as unknown as {
$executeRawUnsafe: (sql: string) => Promise<number>;
},
"$executeRawUnsafe",
)
.mockImplementation(async () => {
expect(connected).toBe(true);
expect(active).toBe(false);
active = true;
await Promise.resolve();
active = false;
return 0;
});
await service.onModuleInit();
expect(service.$connect).toHaveBeenCalledTimes(1);
const sql = execute.mock.calls.map(([statement]) => statement);
expect(sql).toHaveLength(16);
expect(
sql.every((statement) =>
/^CREATE (TABLE|INDEX) IF NOT EXISTS /.test(statement),
),
).toBe(true);
expect(
sql
.filter((statement) => statement.startsWith("CREATE TABLE"))
.map((statement) => statement.match(/"([^"]+)"/)?.[1]),
).toEqual(["tickets", "ticket_messages", "sms_logs", "product_reviews"]);
expect(sql[0]).toContain('REFERENCES "users"("id") ON DELETE CASCADE');
expect(sql[5]).toContain('REFERENCES "tickets"("id") ON DELETE CASCADE');
expect(sql[12]).toContain('REFERENCES "products"("id") ON DELETE CASCADE');
expect(service.$disconnect).not.toHaveBeenCalled();
});
it("propagates connection failure without attempting any schema writes", async () => {
const error = new Error("database unavailable");
jest.spyOn(service, "$connect").mockRejectedValue(error);
await expect(service.onModuleInit()).rejects.toBe(error);
expect(service.$executeRawUnsafe).not.toHaveBeenCalled();
});
it.each([new Error("permission denied"), "raw driver failure", null])(
"logs DDL failure and still attempts the remaining statements (%p)",
async (error) => {
const warn = jest
.spyOn(console, "warn")
.mockImplementation(() => undefined);
const execute = jest
.spyOn(service, "$executeRawUnsafe")
.mockRejectedValueOnce(error)
.mockResolvedValue(0);
await expect(service.onModuleInit()).resolves.toBeUndefined();
expect(execute).toHaveBeenCalledTimes(16);
expect(warn).toHaveBeenCalledTimes(1);
expect(warn).toHaveBeenCalledWith(
expect.stringContaining(
'[PrismaService] DDL execution note for (CREATE TABLE IF NOT EXISTS "tickets"',
),
error instanceof Error ? error.message : error,
);
},
);
it("disconnects once during destruction without schema operations", async () => {
await expect(service.onModuleDestroy()).resolves.toBeUndefined();
expect(service.$disconnect).toHaveBeenCalledTimes(1);
expect(service.$connect).not.toHaveBeenCalled();
expect(service.$executeRawUnsafe).not.toHaveBeenCalled();
});
it("propagates disconnect failures so shutdown cannot silently succeed", async () => {
const error = new Error("disconnect failed");
jest.spyOn(service, "$disconnect").mockRejectedValue(error);
await expect(service.onModuleDestroy()).rejects.toBe(error);
});
});
+2 -2
View File
@@ -1,5 +1,5 @@
import { Injectable, OnModuleInit, OnModuleDestroy } from '@nestjs/common';
import { PrismaClient } from '@prisma/client';
import { Injectable, OnModuleInit, OnModuleDestroy } from "@nestjs/common";
import { PrismaClient } from "@prisma/client";
@Injectable()
export class PrismaService