feat: add website enrichment crawler

This commit is contained in:
2026-06-04 20:29:23 +02:00
parent ca42c8d5a6
commit 1f6e31c01c
25 changed files with 3539 additions and 56 deletions

View File

@@ -8,6 +8,7 @@ import {
isStalePendingAgentRun,
getLeadDiscoveryContactStatus,
getLeadDiscoveryPriority,
shouldScheduleWebsiteEnrichment,
} from "../lib/lead-discovery-run";
test("agent run guard ignores stale pending runs but blocks active runs", () => {
@@ -180,6 +181,69 @@ test("lead discovery lead record stores valid email and sets contactStatus to ne
assert.equal(record.contactPerson, undefined);
});
test("scheduling helper triggers website enrichment for missing contact leads with website data", () => {
assert.equal(
shouldScheduleWebsiteEnrichment({
websiteUrl: "https://www.example.de",
websiteDomain: "example.de",
contactStatus: "missing_contact",
}),
true,
);
});
test("scheduling helper does not trigger without website data", () => {
assert.equal(
shouldScheduleWebsiteEnrichment({
websiteUrl: null,
websiteDomain: "",
contactStatus: "missing_contact",
}),
false,
);
});
test("scheduling helper does not trigger when contact status is already usable", () => {
assert.equal(
shouldScheduleWebsiteEnrichment({
websiteUrl: "https://www.example.de",
websiteDomain: "example.de",
contactStatus: "new",
}),
false,
);
});
test("scheduling helper does not trigger for audit-ready leads", () => {
assert.equal(
shouldScheduleWebsiteEnrichment({
websiteUrl: "https://www.example.de",
websiteDomain: "example.de",
contactStatus: "audit_ready",
}),
false,
);
});
test("scheduling helper preserves existing contact-status behavior beyond TASK-7", () => {
assert.equal(
shouldScheduleWebsiteEnrichment({
websiteUrl: "https://www.example.de",
websiteDomain: "example.de",
contactStatus: "outreach_ready",
}),
false,
);
assert.equal(
shouldScheduleWebsiteEnrichment({
websiteUrl: "https://www.example.de",
websiteDomain: "example.de",
contactStatus: "do_not_contact",
}),
false,
);
});
test("lead discovery lead record stores normalized matching fields", () => {
const record = buildLeadDiscoveryLeadRecord({
campaignId: "campaign-1",