Add salesforce query validation in integration tests (#20209)

This commit is contained in:
Hariom Balhara authored and GitHub committed 2025-03-21 23:06:41 +00:00
1 parent 8ee6d2befa
commit 56ab4e8415
5 files changed
+33 -5

No files matched your search

@@ -948,7 +948,7 @@ export default class SalesforceCRMService implements CRM {
log.info("Querying first account matching email domain", safeStringify({ emailDomain }));
// First check if an account has the same website as the email domain of the attendee
const accountQuery = await conn.query(
`SELECT Id, OwnerId, Owner.Email FROM Account WHERE Website IN (${this.getAllPossibleAccountWebsiteFromEmailDomain(
`SELECT Id, OwnerId, Owner.Email, Owner.Website FROM Account WHERE Website IN (${this.getAllPossibleAccountWebsiteFromEmailDomain(
emailDomain
)}) LIMIT 1`
);
@@ -963,7 +963,13 @@ export default class SalesforceCRMService implements CRM {
log.info(
"Found account matching email domain",
safeStringify({ emailDomain, accountWebsite: account.Website, accountId: account.Id })
safeStringify({
emailDomain,
accountWebsite: account.Website,
accountOwnerEmail: account.Owner?.Email,
accountOwnerId: account.OwnerId,
accountId: account.Id,
})
);
return {
@@ -1,3 +1,4 @@
import { parseQuery, composeQuery } from "@jetstreamapp/soql-parser-js";
import { vi } from "vitest";
import logger from "@calcom/lib/logger";
@@ -43,7 +44,11 @@ export const createSalesforceMock = () => {
};
// Query parser and responder
const handleQuery = (query: string) => {
const handleQuery = (rawQuery: string) => {
const parsedQuery = parseQuery(rawQuery);
// Validated Query
const query = composeQuery(parsedQuery);
// Simple SOQL parser
console.log({ query });
const fromMatch = query.match(/FROM\s+(\w+)/i);
@@ -7,6 +7,7 @@
"dependencies": {
"@calcom/lib": "*",
"@calcom/prisma": "*",
"@jetstreamapp/soql-parser-js": "^6.1.0",
"@jsforce/jsforce-node": "^3.6.3"
},
"devDependencies": {