fix: make property-assessor safer for whatsapp runs
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import { normalizeImageCandidates } from "./real-estate-photo-common.js";
|
||||
import { normalizeImageCandidates, runWithOperationTimeout } from "./real-estate-photo-common.js";
|
||||
|
||||
test("normalizeImageCandidates keeps distinct Zillow photo URLs and strips query strings", () => {
|
||||
const result = normalizeImageCandidates(
|
||||
@@ -64,3 +64,24 @@ test("normalizeImageCandidates filters tiny HAR page assets and keeps large phot
|
||||
"https://photos.har.com/123/main.jpg",
|
||||
]);
|
||||
});
|
||||
|
||||
test("runWithOperationTimeout rejects stalled work and runs timeout cleanup", async () => {
|
||||
let cleanedUp = false;
|
||||
|
||||
await assert.rejects(
|
||||
async () =>
|
||||
runWithOperationTimeout(
|
||||
"HAR photo extraction",
|
||||
async () => await new Promise(() => {}),
|
||||
{
|
||||
timeoutMs: 20,
|
||||
onTimeout: async () => {
|
||||
cleanedUp = true;
|
||||
},
|
||||
}
|
||||
),
|
||||
/timed out/i
|
||||
);
|
||||
|
||||
assert.equal(cleanedUp, true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user