refactor: extract server-side CRM contact update

This commit is contained in:
2026-11-06 09:58:02 +00:00
parent ea5e90943d
commit 71de8a2d14
7 changed files with 190 additions and 147 deletions
@@ -835,9 +835,7 @@ test("updateaccount returns CONTACT_ID_REQUIRED when contactId missing", async (
const mod = loadModule("pages/api/endpoint/updateaccount_api.js", {
respondError: respondErrorMock,
respondSuccess: respondSuccessMock,
getToken: async () => ({ access_token: "token" }),
hashAPIPath: () => "&hash=expected",
axios: async () => ({ data: { contactid: "c1" } }),
updateCrmContact: async () => ({ contactid: "c1" }),
consoleLogger: () => {}
});
@@ -853,9 +851,7 @@ test("updateaccount returns ACCOUNT_UPDATE_PAYLOAD_REQUIRED when body missing",
const mod = loadModule("pages/api/endpoint/updateaccount_api.js", {
respondError: respondErrorMock,
respondSuccess: respondSuccessMock,
getToken: async () => ({ access_token: "token" }),
hashAPIPath: () => "&hash=expected",
axios: async () => ({ data: { contactid: "c1" } }),
updateCrmContact: async () => ({ contactid: "c1" }),
consoleLogger: () => {}
});
@@ -874,9 +870,7 @@ test("updateaccount catch path returns ACCOUNT_UPDATE_FAILED", async () => {
const mod = loadModule("pages/api/endpoint/updateaccount_api.js", {
respondError: respondErrorMock,
respondSuccess: respondSuccessMock,
getToken: async () => ({ access_token: "token" }),
hashAPIPath: () => "&hash=expected",
axios: async () => {
updateCrmContact: async () => {
throw new Error("relay failed");
},
consoleLogger: () => {}