Integrate local business workflow and SaaS redesign

This commit is contained in:
2026-06-12 21:08:35 +02:00
parent f00c5a3193
commit 21c7e4c9a4
88 changed files with 2683 additions and 849 deletions

View File

@@ -61,24 +61,49 @@ test("persistDiscoveredLeads does not schedule website enrichment jobs directly"
);
});
test("processCampaignRun schedules website enrichment after lead persistence", () => {
test("persistDiscoveredLeads backfills missing emails on duplicate re-runs only", () => {
const source = extractExportSource("persistDiscoveredLeads");
assert.match(source, /getUsableContactEmail\(candidate\)/);
assert.match(source, /duplicateLeadForEmailBackfill/);
assert.match(source, /ctx\.db\.patch\(\s*duplicateLeadForEmailBackfill\._id/);
assert.match(source, /normalizedEmail:\s*usableEmail\.email/);
assert.match(source, /email:\s*usableEmail\.email/);
assert.match(source, /contactStatus\s*=\s*"new"/);
assert.match(source, /contactStatus\s*!==\s*"do_not_contact"/);
assert.match(source, /blacklistStatus\s*!==\s*"blocked"/);
assert.match(source, /duplicateByEmailRows\.length\s*===\s*0/);
assert.doesNotMatch(source, /internal\.websiteEnrichment\.queueLeadEnrichment/);
assert.doesNotMatch(source, /internal\.pageSpeed\.queueLeadPageSpeedAudit/);
});
test("processCampaignRun uses Local Business Data and does not schedule website enrichment", () => {
const source = extractExportSource("processCampaignRun");
const persistIndex = source.indexOf(
"internal.leadDiscovery.persistDiscoveredLeads",
);
const queueCall = source.indexOf("internal.websiteEnrichment.queueLeadEnrichment");
const eventMessageIndex = source.indexOf("Website-Kontaktanreicherung geplant.");
assert.notEqual(persistIndex, -1, "processCampaignRun should persist discovered leads");
assert.notEqual(queueCall, -1, "processCampaignRun should schedule website enrichment");
assert.notEqual(eventMessageIndex, -1, "processCampaignRun should append enrichment schedule events");
assert.ok(
persistIndex < queueCall,
"processCampaignRun should schedule enrichment after persistence succeeds",
assert.equal(
queueCall,
-1,
"Campaign discovery must not schedule website enrichment in the SaaS flow",
);
assert.ok(
queueCall < eventMessageIndex,
"processCampaignRun should append enrichment event after scheduling",
assert.equal(
source.includes("GOOGLE_GEOCODING_API_KEY") || source.includes("GOOGLE_PLACES_API_KEY"),
false,
"Campaign discovery should no longer require Google lead-discovery keys",
);
assert.match(
source,
/LOCAL_BUSINESS_DATA_API_KEY/,
"Campaign discovery should read the Local Business Data API key",
);
assert.match(
source,
/local_business_data/,
"Campaign discovery should record Local Business Data as the source",
);
});