Harden assessor fallback after Zillow photo failure

This commit is contained in:
2026-03-28 03:17:51 -05:00
parent 3335e96d35
commit 54854edfc6
5 changed files with 115 additions and 74 deletions

View File

@@ -1,7 +1,11 @@
import test from "node:test";
import assert from "node:assert/strict";
import { normalizeImageCandidates, runWithOperationTimeout } from "./real-estate-photo-common.js";
import {
isPageClosedError,
normalizeImageCandidates,
runWithOperationTimeout,
} from "./real-estate-photo-common.js";
test("normalizeImageCandidates keeps distinct Zillow photo URLs and strips query strings", () => {
const result = normalizeImageCandidates(
@@ -85,3 +89,15 @@ test("runWithOperationTimeout rejects stalled work and runs timeout cleanup", as
assert.equal(cleanedUp, true);
});
test("isPageClosedError detects transient browser-session closure errors", () => {
assert.equal(
isPageClosedError(new Error("page.evaluate: Target page, context or browser has been closed")),
true
);
assert.equal(
isPageClosedError(new Error("Execution context was destroyed, most likely because of a navigation")),
true
);
assert.equal(isPageClosedError(new Error("No Zillow image URLs were found")), false);
});