From 782fa8a1c71c0de51611750eaea789356c9c1fc6 Mon Sep 17 00:00:00 2001 From: Dave Date: Tue, 17 Mar 2026 11:09:26 -0400 Subject: [PATCH] feature/IO-3587-Commision-Cut - restore test fixes --- .../lib/handleCommentBasedPayment.js | 2 +- .../lib/handleInvoiceBasedPayment.js | 2 +- .../lib/tests/intelliPayGeneralLibs.test.js | 28 +++++++++---------- server/job/test/job-totals.test.js | 5 ++++ 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/server/intellipay/lib/handleCommentBasedPayment.js b/server/intellipay/lib/handleCommentBasedPayment.js index fd2ff3ef8..5cd279a59 100644 --- a/server/intellipay/lib/handleCommentBasedPayment.js +++ b/server/intellipay/lib/handleCommentBasedPayment.js @@ -1,7 +1,7 @@ const sendPaymentNotificationEmail = require("./sendPaymentNotificationEmail"); const { INSERT_NEW_PAYMENT, GET_BODYSHOP_BY_ID, GET_JOBS_BY_PKS } = require("../../graphql-client/queries"); const getPaymentType = require("./getPaymentType"); -const moment = require("moment"); +const moment = require("moment-timezone"); const gqlClient = require("../../graphql-client/graphql-client").client; diff --git a/server/intellipay/lib/handleInvoiceBasedPayment.js b/server/intellipay/lib/handleInvoiceBasedPayment.js index 34a1a5e8d..7f404547e 100644 --- a/server/intellipay/lib/handleInvoiceBasedPayment.js +++ b/server/intellipay/lib/handleInvoiceBasedPayment.js @@ -8,7 +8,7 @@ const { const { sendTaskEmail } = require("../../email/sendemail"); const getPaymentType = require("./getPaymentType"); -const moment = require("moment"); +const moment = require("moment-timezone"); const gqlClient = require("../../graphql-client/graphql-client").client; diff --git a/server/intellipay/lib/tests/intelliPayGeneralLibs.test.js b/server/intellipay/lib/tests/intelliPayGeneralLibs.test.js index 9c9bec789..a6de12638 100644 --- a/server/intellipay/lib/tests/intelliPayGeneralLibs.test.js +++ b/server/intellipay/lib/tests/intelliPayGeneralLibs.test.js @@ -1,5 +1,18 @@ import { describe, it, expect, vi, beforeEach, afterEach } from "vitest"; +const { mockSend } = vi.hoisted(() => ({ + mockSend: vi.fn() +})); + +vi.mock("@aws-sdk/client-secrets-manager", () => { + return { + SecretsManagerClient: vi.fn(() => ({ + send: mockSend + })), + GetSecretValueCommand: vi.fn((input) => input) + }; +}); + const getPaymentType = require("../getPaymentType"); const decodeComment = require("../decodeComment"); const getCptellerUrl = require("../getCptellerUrl"); @@ -145,28 +158,15 @@ describe("Payment Processing Functions", () => { // GetShopCredentials Tests describe("getShopCredentials", () => { const originalEnv = { ...process.env }; - let mockSend; beforeEach(() => { - mockSend = vi.fn(); - vi.mock("@aws-sdk/client-secrets-manager", () => { - return { - SecretsManagerClient: vi.fn(() => ({ - send: mockSend - })), - GetSecretValueCommand: vi.fn((input) => input) - }; - }); - + mockSend.mockReset(); process.env.INTELLIPAY_MERCHANTKEY = "test-merchant-key"; process.env.INTELLIPAY_APIKEY = "test-api-key"; - vi.resetModules(); }); afterEach(() => { process.env = { ...originalEnv }; - vi.restoreAllMocks(); - vi.unmock("@aws-sdk/client-secrets-manager"); }); it("returns environment variables in non-production environment", async () => { diff --git a/server/job/test/job-totals.test.js b/server/job/test/job-totals.test.js index 04a915b6b..07dd5e3a4 100644 --- a/server/job/test/job-totals.test.js +++ b/server/job/test/job-totals.test.js @@ -35,6 +35,11 @@ describe("TotalsServerSide fixture tests", () => { const fixtureFiles = fs.readdirSync(fixturesDir).filter((f) => f.endsWith(".json")); + if (fixtureFiles.length === 0) { + it.skip("skips when no job total fixtures are present", () => {}); + return; + } + const dummyClient = { request: async () => { return {};