fix: make property-assessor safer for whatsapp runs
This commit is contained in:
32
skills/property-assessor/tests/timeout-guards.test.ts
Normal file
32
skills/property-assessor/tests/timeout-guards.test.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import { discoverListingSources } from "../src/listing-discovery.js";
|
||||
import { extractPhotoData } from "../src/photo-review.js";
|
||||
|
||||
test("discoverListingSources times out stalled Zillow and HAR discovery calls", async () => {
|
||||
const result = await discoverListingSources(
|
||||
"1011 Ennis Joslin Rd APT 235, Corpus Christi, TX 78412",
|
||||
{
|
||||
timeoutMs: 20,
|
||||
discoverZillowListingFn: async () => await new Promise(() => {}),
|
||||
discoverHarListingFn: async () => await new Promise(() => {})
|
||||
}
|
||||
);
|
||||
|
||||
assert.equal(result.zillowUrl, null);
|
||||
assert.equal(result.harUrl, null);
|
||||
assert.match(result.attempts.join(" "), /zillow discovery timed out/i);
|
||||
assert.match(result.attempts.join(" "), /har discovery timed out/i);
|
||||
});
|
||||
|
||||
test("extractPhotoData times out a stalled photo extraction instead of hanging forever", async () => {
|
||||
await assert.rejects(
|
||||
async () =>
|
||||
extractPhotoData("zillow", "https://www.zillow.com/example", {
|
||||
timeoutMs: 20,
|
||||
extractZillowPhotosFn: async () => await new Promise(() => {})
|
||||
}),
|
||||
/timed out/i
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user