mirror of
https://github.com/open-reception/appointment-booking-software.git
synced 2026-08-17 21:25:52 +02:00
Merge pull request #282 from open-reception/dependabot/npm_and_yarn/vitest-4.1.8
Bump vitest from 3.2.4 to 4.1.8
This commit is contained in:
Generated
+724
-316
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -81,7 +81,7 @@
|
||||
"typescript-eslint": "^8.34.1",
|
||||
"vaul-svelte": "^1.0.0-next.7",
|
||||
"vite": "^6.4.2",
|
||||
"vitest": "^3.2.4"
|
||||
"vitest": "^4.1.9"
|
||||
},
|
||||
"dependencies": {
|
||||
"@noble/hashes": "^1.8.0",
|
||||
@@ -97,7 +97,7 @@
|
||||
"drizzle-orm": "^0.45.2",
|
||||
"jose": "^6.0.11",
|
||||
"mode-watcher": "^1.0.8",
|
||||
"nodemailer": "^8.0.9",
|
||||
"nodemailer": "^9.0.1",
|
||||
"postgres": "^3.4.7",
|
||||
"secrets.js-34r7h": "^2.0.2",
|
||||
"uuidv7": "^1.0.2",
|
||||
|
||||
@@ -13,14 +13,12 @@ vi.mock("../../db", () => ({
|
||||
}));
|
||||
|
||||
vi.mock("$lib/logger", () => ({
|
||||
UniversalLogger: vi.fn(() => ({
|
||||
setContext: vi.fn(() => ({
|
||||
debug: vi.fn(),
|
||||
error: vi.fn(),
|
||||
warn: vi.fn(),
|
||||
info: vi.fn(),
|
||||
})),
|
||||
})),
|
||||
UniversalLogger: class {
|
||||
setContext = vi.fn().mockReturnThis();
|
||||
warn = vi.fn();
|
||||
error = vi.fn();
|
||||
info = vi.fn();
|
||||
},
|
||||
default: {
|
||||
setContext: vi.fn(() => ({
|
||||
debug: vi.fn(),
|
||||
@@ -174,6 +172,7 @@ describe("AgentService", () => {
|
||||
const insertChain = {
|
||||
values: vi.fn(() => ({
|
||||
returning: vi.fn().mockResolvedValue([mockAgent]),
|
||||
onConflictDoNothing: vi.fn(),
|
||||
})),
|
||||
};
|
||||
mockDb.insert.mockReturnValue(insertChain);
|
||||
@@ -209,6 +208,7 @@ describe("AgentService", () => {
|
||||
const insertChain = {
|
||||
values: vi.fn(() => ({
|
||||
returning: vi.fn().mockRejectedValue(new Error("DB error")),
|
||||
onConflictDoNothing: vi.fn(),
|
||||
})),
|
||||
};
|
||||
mockDb.insert.mockReturnValue(insertChain);
|
||||
@@ -233,6 +233,13 @@ describe("AgentService", () => {
|
||||
from: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
limit: vi.fn().mockResolvedValue([mockAgent]),
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
orderBy: vi.fn(),
|
||||
innerJoin: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
})),
|
||||
})),
|
||||
};
|
||||
@@ -249,6 +256,13 @@ describe("AgentService", () => {
|
||||
from: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
limit: vi.fn().mockResolvedValue([]),
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
orderBy: vi.fn(),
|
||||
innerJoin: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
})),
|
||||
})),
|
||||
};
|
||||
@@ -264,6 +278,13 @@ describe("AgentService", () => {
|
||||
from: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
limit: vi.fn().mockRejectedValue(new Error("DB error")),
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
orderBy: vi.fn(),
|
||||
innerJoin: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
})),
|
||||
})),
|
||||
};
|
||||
@@ -285,8 +306,15 @@ describe("AgentService", () => {
|
||||
const selectChain = {
|
||||
from: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
limit: vi.fn(),
|
||||
orderBy: vi.fn().mockResolvedValue(agents),
|
||||
})),
|
||||
orderBy: vi.fn(),
|
||||
innerJoin: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
})),
|
||||
})),
|
||||
};
|
||||
mockDb.select.mockReturnValue(selectChain);
|
||||
@@ -301,8 +329,15 @@ describe("AgentService", () => {
|
||||
const selectChain = {
|
||||
from: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
limit: vi.fn(),
|
||||
orderBy: vi.fn().mockResolvedValue([]),
|
||||
})),
|
||||
orderBy: vi.fn(),
|
||||
innerJoin: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
})),
|
||||
})),
|
||||
};
|
||||
mockDb.select.mockReturnValue(selectChain);
|
||||
@@ -317,8 +352,15 @@ describe("AgentService", () => {
|
||||
const selectChain = {
|
||||
from: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
limit: vi.fn(),
|
||||
orderBy: vi.fn().mockRejectedValue(new Error("DB error")),
|
||||
})),
|
||||
orderBy: vi.fn(),
|
||||
innerJoin: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
})),
|
||||
})),
|
||||
};
|
||||
mockDb.select.mockReturnValue(selectChain);
|
||||
@@ -490,6 +532,11 @@ describe("AgentService", () => {
|
||||
orderBy: vi.fn().mockResolvedValue(agents),
|
||||
})),
|
||||
})),
|
||||
where: vi.fn(() => ({
|
||||
limit: vi.fn(),
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
};
|
||||
mockDb.select.mockReturnValue(selectChain);
|
||||
@@ -507,6 +554,11 @@ describe("AgentService", () => {
|
||||
orderBy: vi.fn().mockResolvedValue([]),
|
||||
})),
|
||||
})),
|
||||
where: vi.fn(() => ({
|
||||
limit: vi.fn(),
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
};
|
||||
mockDb.select.mockReturnValue(selectChain);
|
||||
@@ -524,6 +576,11 @@ describe("AgentService", () => {
|
||||
orderBy: vi.fn().mockRejectedValue(new Error("DB error")),
|
||||
})),
|
||||
})),
|
||||
where: vi.fn(() => ({
|
||||
limit: vi.fn(),
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
};
|
||||
mockDb.select.mockReturnValue(selectChain);
|
||||
@@ -542,6 +599,7 @@ describe("AgentService", () => {
|
||||
it("should assign agent to channel successfully", async () => {
|
||||
const insertChain = {
|
||||
values: vi.fn(() => ({
|
||||
returning: vi.fn(),
|
||||
onConflictDoNothing: vi.fn().mockResolvedValue([]),
|
||||
})),
|
||||
};
|
||||
@@ -558,6 +616,7 @@ describe("AgentService", () => {
|
||||
it("should handle database error", async () => {
|
||||
const insertChain = {
|
||||
values: vi.fn(() => ({
|
||||
returning: vi.fn(),
|
||||
onConflictDoNothing: vi.fn().mockRejectedValue(new Error("DB error")),
|
||||
})),
|
||||
};
|
||||
@@ -629,6 +688,13 @@ describe("AgentService", () => {
|
||||
from: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
limit: vi.fn().mockResolvedValue([mockAgent]),
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
orderBy: vi.fn(),
|
||||
innerJoin: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
})),
|
||||
})),
|
||||
};
|
||||
@@ -637,6 +703,12 @@ describe("AgentService", () => {
|
||||
const selectChainForOverlap = {
|
||||
from: vi.fn(() => ({
|
||||
where: vi.fn().mockResolvedValue([]),
|
||||
orderBy: vi.fn(),
|
||||
innerJoin: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
})),
|
||||
})),
|
||||
};
|
||||
|
||||
@@ -649,6 +721,7 @@ describe("AgentService", () => {
|
||||
const insertChain = {
|
||||
values: vi.fn(() => ({
|
||||
returning: vi.fn().mockResolvedValue([mockAbsence]),
|
||||
onConflictDoNothing: vi.fn(),
|
||||
})),
|
||||
};
|
||||
mockDb.insert.mockReturnValue(insertChain);
|
||||
@@ -702,6 +775,13 @@ describe("AgentService", () => {
|
||||
from: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
limit: vi.fn().mockResolvedValue([]),
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
orderBy: vi.fn(),
|
||||
innerJoin: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
})),
|
||||
})),
|
||||
};
|
||||
@@ -724,6 +804,12 @@ describe("AgentService", () => {
|
||||
where: vi.fn(() => ({
|
||||
limit: vi.fn().mockResolvedValue([mockAgent]),
|
||||
})),
|
||||
orderBy: vi.fn(),
|
||||
innerJoin: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
})),
|
||||
})),
|
||||
};
|
||||
|
||||
@@ -731,6 +817,12 @@ describe("AgentService", () => {
|
||||
const selectChainForOverlap = {
|
||||
from: vi.fn(() => ({
|
||||
where: vi.fn().mockResolvedValue([mockAbsence]),
|
||||
orderBy: vi.fn(),
|
||||
innerJoin: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
})),
|
||||
})),
|
||||
};
|
||||
|
||||
@@ -750,6 +842,13 @@ describe("AgentService", () => {
|
||||
from: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
limit: vi.fn().mockResolvedValue([mockAbsence]),
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
orderBy: vi.fn(),
|
||||
innerJoin: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
})),
|
||||
})),
|
||||
};
|
||||
@@ -765,6 +864,13 @@ describe("AgentService", () => {
|
||||
from: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
limit: vi.fn().mockResolvedValue([]),
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
orderBy: vi.fn(),
|
||||
innerJoin: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
})),
|
||||
})),
|
||||
};
|
||||
@@ -825,6 +931,13 @@ describe("AgentService", () => {
|
||||
from: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
limit: vi.fn().mockResolvedValue([mockAbsence]),
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
orderBy: vi.fn(),
|
||||
innerJoin: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
})),
|
||||
})),
|
||||
};
|
||||
@@ -863,6 +976,13 @@ describe("AgentService", () => {
|
||||
from: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
limit: vi.fn().mockResolvedValue([]),
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
orderBy: vi.fn(),
|
||||
innerJoin: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
})),
|
||||
})),
|
||||
};
|
||||
@@ -883,6 +1003,13 @@ describe("AgentService", () => {
|
||||
from: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
limit: vi.fn().mockResolvedValue([mockAbsence]),
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
orderBy: vi.fn(),
|
||||
innerJoin: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
})),
|
||||
})),
|
||||
};
|
||||
|
||||
@@ -37,14 +37,12 @@ vi.mock("../../db", () => ({
|
||||
}));
|
||||
|
||||
vi.mock("$lib/logger", () => ({
|
||||
UniversalLogger: vi.fn(() => ({
|
||||
setContext: vi.fn(() => ({
|
||||
debug: vi.fn(),
|
||||
error: vi.fn(),
|
||||
warn: vi.fn(),
|
||||
info: vi.fn(),
|
||||
})),
|
||||
})),
|
||||
UniversalLogger: class {
|
||||
setContext = vi.fn().mockReturnThis();
|
||||
warn = vi.fn();
|
||||
error = vi.fn();
|
||||
info = vi.fn();
|
||||
},
|
||||
default: {
|
||||
setContext: vi.fn(() => ({
|
||||
debug: vi.fn(),
|
||||
|
||||
@@ -13,14 +13,12 @@ vi.mock("../../db", () => ({
|
||||
}));
|
||||
|
||||
vi.mock("$lib/logger", () => ({
|
||||
UniversalLogger: vi.fn(() => ({
|
||||
setContext: vi.fn(() => ({
|
||||
debug: vi.fn(),
|
||||
error: vi.fn(),
|
||||
warn: vi.fn(),
|
||||
info: vi.fn(),
|
||||
})),
|
||||
})),
|
||||
UniversalLogger: class {
|
||||
setContext = vi.fn().mockReturnThis();
|
||||
warn = vi.fn();
|
||||
error = vi.fn();
|
||||
info = vi.fn();
|
||||
},
|
||||
default: {
|
||||
setContext: vi.fn(() => ({
|
||||
debug: vi.fn(),
|
||||
@@ -245,6 +243,7 @@ describe("NotificationService", () => {
|
||||
const selectChain = {
|
||||
from: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
limit: vi.fn(),
|
||||
orderBy: vi.fn().mockResolvedValue(mockNotifications),
|
||||
})),
|
||||
})),
|
||||
@@ -261,6 +260,7 @@ describe("NotificationService", () => {
|
||||
const selectChain = {
|
||||
from: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
limit: vi.fn(),
|
||||
orderBy: vi.fn().mockResolvedValue([]),
|
||||
})),
|
||||
})),
|
||||
@@ -276,6 +276,7 @@ describe("NotificationService", () => {
|
||||
const selectChain = {
|
||||
from: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
limit: vi.fn(),
|
||||
orderBy: vi.fn().mockRejectedValue(new Error("DB error")),
|
||||
})),
|
||||
})),
|
||||
@@ -298,6 +299,7 @@ describe("NotificationService", () => {
|
||||
from: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
limit: vi.fn().mockResolvedValue([{ id: "notification-123" }]),
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
})),
|
||||
};
|
||||
@@ -313,6 +315,7 @@ describe("NotificationService", () => {
|
||||
from: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
limit: vi.fn().mockResolvedValue([]),
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
})),
|
||||
};
|
||||
@@ -328,6 +331,7 @@ describe("NotificationService", () => {
|
||||
from: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
limit: vi.fn().mockRejectedValue(new Error("DB error")),
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
})),
|
||||
};
|
||||
@@ -372,6 +376,7 @@ describe("NotificationService", () => {
|
||||
from: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
limit: vi.fn().mockResolvedValue([mockNotification]),
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
})),
|
||||
};
|
||||
@@ -428,6 +433,7 @@ describe("NotificationService", () => {
|
||||
from: vi.fn(() => ({
|
||||
where: vi.fn(() => ({
|
||||
limit: vi.fn().mockResolvedValue([mockNotification]),
|
||||
orderBy: vi.fn(),
|
||||
})),
|
||||
})),
|
||||
};
|
||||
|
||||
@@ -47,7 +47,6 @@ const mockStaffMember = {
|
||||
describe("StaffService", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
describe("getStaffMembers", () => {
|
||||
@@ -347,7 +346,9 @@ describe("StaffService", () => {
|
||||
const mockStaffCryptoService = {
|
||||
getStaffPublicKey: vi.fn().mockResolvedValue("mock-public-key"),
|
||||
};
|
||||
vi.mocked(StaffCryptoService).mockImplementation(() => mockStaffCryptoService as any);
|
||||
vi.mocked(StaffCryptoService).mockImplementation(function () {
|
||||
return mockStaffCryptoService as any;
|
||||
} as any);
|
||||
|
||||
const result = await StaffService.getStaffPublicKey("tenant-123", "staff-123");
|
||||
|
||||
|
||||
@@ -59,12 +59,12 @@ vi.mock("$lib/server/auth/jwt-utils", () => ({
|
||||
|
||||
// Mock universal logger
|
||||
vi.mock("$lib/logger", () => ({
|
||||
UniversalLogger: vi.fn(() => ({
|
||||
setContext: vi.fn().mockReturnThis(),
|
||||
warn: vi.fn(),
|
||||
error: vi.fn(),
|
||||
info: vi.fn(),
|
||||
})),
|
||||
UniversalLogger: class {
|
||||
setContext = vi.fn().mockReturnThis();
|
||||
warn = vi.fn();
|
||||
error = vi.fn();
|
||||
info = vi.fn();
|
||||
},
|
||||
}));
|
||||
|
||||
// Mock openapi
|
||||
|
||||
@@ -6,12 +6,13 @@ import { mockCookies } from "$lib/tests/const";
|
||||
|
||||
// Mock the logger
|
||||
vi.mock("$lib/logger", () => ({
|
||||
UniversalLogger: vi.fn(() => ({
|
||||
setContext: vi.fn(() => ({
|
||||
error: vi.fn(),
|
||||
debug: vi.fn(),
|
||||
})),
|
||||
})),
|
||||
UniversalLogger: class {
|
||||
setContext = vi.fn(() => this);
|
||||
warn = vi.fn();
|
||||
error = vi.fn();
|
||||
info = vi.fn();
|
||||
debug = vi.fn();
|
||||
},
|
||||
}));
|
||||
|
||||
// Mock OpenAPI registration
|
||||
|
||||
+5
-9
@@ -129,19 +129,15 @@ describe("GET /api/tenants/[id]/appointments/staff-public-keys-by-staff", () =>
|
||||
|
||||
vi.mocked(checkPermission).mockImplementationOnce(() => {});
|
||||
|
||||
const mockService = {
|
||||
getStaffPublicKeys: vi.fn().mockResolvedValueOnce(mockStaffPublicKeys),
|
||||
};
|
||||
|
||||
vi.mocked(StaffCryptoService).mockImplementationOnce(
|
||||
() => mockService as unknown as StaffCryptoService,
|
||||
);
|
||||
const mockGetStaffPublicKeys = vi
|
||||
.mocked(StaffCryptoService.prototype.getStaffPublicKeys)
|
||||
.mockResolvedValueOnce(mockStaffPublicKeys);
|
||||
|
||||
const event = createMockRequestEvent(mockTenantId, locals);
|
||||
await GET(event);
|
||||
|
||||
expect(mockService.getStaffPublicKeys).toHaveBeenCalledWith(mockTenantId);
|
||||
expect(mockService.getStaffPublicKeys).toHaveBeenCalledOnce();
|
||||
expect(mockGetStaffPublicKeys).toHaveBeenCalledWith(mockTenantId);
|
||||
expect(mockGetStaffPublicKeys).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it("should call checkPermission with tenant ID and false flag", async () => {
|
||||
|
||||
+8
-4
@@ -13,9 +13,11 @@ vi.mock("$lib/logger", () => ({
|
||||
}));
|
||||
|
||||
vi.mock("$lib/server/services/staff-crypto.service", () => ({
|
||||
StaffCryptoService: vi.fn(() => ({
|
||||
getStaffPublicKeys: vi.fn(),
|
||||
})),
|
||||
StaffCryptoService: vi.fn(function () {
|
||||
return {
|
||||
getStaffPublicKeys: vi.fn(),
|
||||
};
|
||||
}),
|
||||
}));
|
||||
|
||||
vi.mock("$lib/server/auth/booking-access-token", () => ({
|
||||
@@ -34,7 +36,9 @@ describe("Staff Public Keys API", () => {
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
(StaffCryptoService as any).mockImplementation(() => serviceMock);
|
||||
(StaffCryptoService as any).mockImplementation(function () {
|
||||
return serviceMock;
|
||||
});
|
||||
});
|
||||
|
||||
function createEvent(authorization?: string): RequestEvent {
|
||||
|
||||
+20
-21
@@ -7,15 +7,15 @@ import type { RequestEvent } from "@sveltejs/kit";
|
||||
vi.mock("$lib/logger", () => {
|
||||
const mockLogger = {
|
||||
setContext: vi.fn(() => ({
|
||||
info: vi.fn(),
|
||||
warn: vi.fn(),
|
||||
error: vi.fn(),
|
||||
debug: vi.fn(),
|
||||
info: vi.fn(() => undefined),
|
||||
warn: vi.fn(() => undefined),
|
||||
error: vi.fn(() => undefined),
|
||||
debug: vi.fn(() => undefined),
|
||||
})),
|
||||
info: vi.fn(),
|
||||
warn: vi.fn(),
|
||||
error: vi.fn(),
|
||||
debug: vi.fn(),
|
||||
info: vi.fn(() => undefined),
|
||||
warn: vi.fn(() => undefined),
|
||||
error: vi.fn(() => undefined),
|
||||
debug: vi.fn(() => undefined),
|
||||
};
|
||||
|
||||
return {
|
||||
@@ -24,20 +24,25 @@ vi.mock("$lib/logger", () => {
|
||||
};
|
||||
});
|
||||
|
||||
// Create a mock service object that will be returned by the StaffCryptoService constructor
|
||||
const mockStaffCryptoService = {
|
||||
getStaffCryptoForPasskey: vi.fn(),
|
||||
};
|
||||
|
||||
vi.mock("$lib/server/services/staff-crypto.service", () => ({
|
||||
StaffCryptoService: vi.fn(() => ({
|
||||
getStaffCryptoForPasskey: vi.fn(),
|
||||
})),
|
||||
StaffCryptoService: vi.fn(function () {
|
||||
return mockStaffCryptoService;
|
||||
}),
|
||||
}));
|
||||
|
||||
vi.mock("$lib/server/auth/webauthn-service", () => ({
|
||||
WebAuthnService: {
|
||||
getMostRecentPasskey: vi.fn(),
|
||||
getMostRecentPasskey: vi.fn(async () => undefined),
|
||||
},
|
||||
}));
|
||||
|
||||
vi.mock("$lib/server/utils/permissions", () => ({
|
||||
checkPermission: vi.fn(),
|
||||
checkPermission: vi.fn(() => true),
|
||||
}));
|
||||
|
||||
vi.mock("$lib/server/utils/errors", () => {
|
||||
@@ -82,9 +87,7 @@ vi.mock("$lib/server/utils/errors", () => {
|
||||
};
|
||||
});
|
||||
|
||||
import { StaffCryptoService } from "$lib/server/services/staff-crypto.service";
|
||||
import { WebAuthnService } from "$lib/server/auth/webauthn-service";
|
||||
import { checkPermission } from "$lib/server/utils/permissions";
|
||||
|
||||
describe("Staff Key Shard API Route", () => {
|
||||
const mockTenantId = "123e4567-e89b-12d3-a456-426614174000";
|
||||
@@ -92,14 +95,10 @@ describe("Staff Key Shard API Route", () => {
|
||||
const mockPasskeyId = "passkey-abc-123";
|
||||
const mockUserId = mockStaffId; // Same user accessing their own key shard
|
||||
|
||||
const mockStaffCryptoService = {
|
||||
getStaffCryptoForPasskey: vi.fn(),
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
(StaffCryptoService as any).mockImplementation(() => mockStaffCryptoService);
|
||||
(checkPermission as any).mockImplementation(() => true);
|
||||
// Reset the mock implementations to defaults
|
||||
mockStaffCryptoService.getStaffCryptoForPasskey.mockClear();
|
||||
});
|
||||
|
||||
function createMockRequestEvent(overrides: Partial<RequestEvent> = {}): RequestEvent {
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import { paraglideVitePlugin } from "@inlang/paraglide-js";
|
||||
import tailwindcss from "@tailwindcss/vite";
|
||||
import { svelteTesting } from "@testing-library/svelte/vite";
|
||||
import { sveltekit } from "@sveltejs/kit/vite";
|
||||
import { defineConfig } from "vite";
|
||||
import { defineConfig } from "vitest/config";
|
||||
import { readFileSync } from "fs";
|
||||
|
||||
const pkg = JSON.parse(readFileSync(new URL("./package.json", import.meta.url), "utf8"));
|
||||
|
||||
Reference in New Issue
Block a user