Add property assessor assess command
This commit is contained in:
96
skills/property-assessor/tests/assessment.test.ts
Normal file
96
skills/property-assessor/tests/assessment.test.ts
Normal file
@@ -0,0 +1,96 @@
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import { assessProperty } from "../src/assessment.js";
|
||||
import type { PublicRecordsResolution } from "../src/public-records.js";
|
||||
|
||||
const samplePublicRecords: PublicRecordsResolution = {
|
||||
requestedAddress: "4141 Whiteley Dr, Corpus Christi, TX 78418",
|
||||
matchedAddress: "4141 WHITELEY DR, CORPUS CHRISTI, TX, 78418",
|
||||
latitude: 27.6138,
|
||||
longitude: -97.3024,
|
||||
geoid: "483550031013005",
|
||||
state: {
|
||||
name: "Texas",
|
||||
code: "TX",
|
||||
fips: "48"
|
||||
},
|
||||
county: {
|
||||
name: "Nueces County",
|
||||
fips: "355",
|
||||
geoid: "48355"
|
||||
},
|
||||
officialLinks: {
|
||||
censusGeocoder: "https://geocoding.geo.census.gov/example",
|
||||
texasCountyDirectory:
|
||||
"https://comptroller.texas.gov/taxes/property-tax/county-directory/nueces.php",
|
||||
texasPropertyTaxPortal: "https://texas.gov/PropertyTaxes"
|
||||
},
|
||||
appraisalDistrict: {
|
||||
"Chief Appraiser": "Debra Morin, Interim",
|
||||
Website: "http://www.ncadistrict.com/",
|
||||
directoryPage:
|
||||
"https://comptroller.texas.gov/taxes/property-tax/county-directory/nueces.php"
|
||||
},
|
||||
taxAssessorCollector: {
|
||||
"Tax Assessor-Collector": "Kevin Kieschnick",
|
||||
Website: "http://www.nuecesco.com"
|
||||
},
|
||||
lookupRecommendations: [
|
||||
"Start from the official public-record jurisdiction instead of a listing-site geo ID."
|
||||
],
|
||||
sourceIdentifierHints: {
|
||||
parcelId: "14069438"
|
||||
}
|
||||
};
|
||||
|
||||
test("assessProperty auto-enriches public-record data from address and asks for recipient email", async () => {
|
||||
const result = await assessProperty(
|
||||
{
|
||||
address: "4141 Whiteley Dr, Corpus Christi, TX 78418",
|
||||
listingSourceUrl: "https://www.zillow.com/homedetails/example",
|
||||
listingGeoId: "233290",
|
||||
parcelId: "14069438"
|
||||
},
|
||||
{
|
||||
resolvePublicRecordsFn: async () => samplePublicRecords
|
||||
}
|
||||
);
|
||||
|
||||
assert.equal(result.ok, true);
|
||||
assert.equal(result.needsRecipientEmails, true);
|
||||
assert.equal(result.outputPath, null);
|
||||
assert.match(result.message, /target email/i);
|
||||
assert.equal(result.reportPayload.subjectProperty?.address, samplePublicRecords.matchedAddress);
|
||||
assert.equal(result.reportPayload.publicRecords?.jurisdiction, "Nueces County Appraisal District");
|
||||
assert.equal(result.reportPayload.publicRecords?.accountNumber, "14069438");
|
||||
assert.equal(result.reportPayload.photoReview?.status, "not completed");
|
||||
assert.match(
|
||||
String(result.reportPayload.verdict?.offerGuidance),
|
||||
/listing, photo, comp, and carry analysis still required/i
|
||||
);
|
||||
assert.deepEqual(result.reportPayload.recipientEmails, []);
|
||||
});
|
||||
|
||||
test("assessProperty renders a PDF when recipient email is present", async () => {
|
||||
const outputPath = path.join(os.tmpdir(), `property-assess-command-${Date.now()}.pdf`);
|
||||
const result = await assessProperty(
|
||||
{
|
||||
address: "4141 Whiteley Dr, Corpus Christi, TX 78418",
|
||||
recipientEmails: ["buyer@example.com"],
|
||||
output: outputPath
|
||||
},
|
||||
{
|
||||
resolvePublicRecordsFn: async () => samplePublicRecords
|
||||
}
|
||||
);
|
||||
|
||||
assert.equal(result.ok, true);
|
||||
assert.equal(result.needsRecipientEmails, false);
|
||||
assert.equal(result.outputPath, outputPath);
|
||||
const stat = await fs.promises.stat(outputPath);
|
||||
assert.ok(stat.size > 1000);
|
||||
});
|
||||
Reference in New Issue
Block a user