fix(amazon-shopping): verify prime and delivery filters
This commit is contained in:
@@ -74,4 +74,45 @@ describe("extractDetailPage", () => {
|
||||
assert.equal(details.availability, "In Stock");
|
||||
assert.deepEqual(details.specs, [{ name: "Wattage", value: "15 watts" }]);
|
||||
});
|
||||
|
||||
it("preserves a search-card Prime signal when detail delivery text omits Prime", () => {
|
||||
const details = extractDetailPage(`
|
||||
<h1 id="productTitle">Prime Sofa Bed</h1>
|
||||
<div id="mir-layout-DELIVERY_BLOCK-slot-PRIMARY_DELIVERY_MESSAGE_LARGE">FREE delivery Tomorrow. Details</div>
|
||||
<table>
|
||||
<tr><td>Product Dimensions</td><td>35"D x 83"W x 31"H</td></tr>
|
||||
</table>
|
||||
`, {
|
||||
asin: "B0PRIME123",
|
||||
title: "Prime Sofa Bed",
|
||||
url: "https://www.amazon.com/dp/B0PRIME123",
|
||||
delivery: { display: "FREE delivery Tomorrow", free: true, prime: true },
|
||||
specs: [],
|
||||
bullets: [],
|
||||
matchedFilters: [],
|
||||
missingFields: [],
|
||||
extractionNotes: []
|
||||
});
|
||||
|
||||
assert.equal(details.delivery?.prime, true);
|
||||
assert.equal(details.delivery?.free, true);
|
||||
});
|
||||
|
||||
it("does not treat Prime in a detail title as Prime delivery", () => {
|
||||
const details = extractDetailPage(`
|
||||
<h1 id="productTitle">Prime Sofa Bed</h1>
|
||||
<div id="mir-layout-DELIVERY_BLOCK-slot-PRIMARY_DELIVERY_MESSAGE_LARGE">FREE delivery Tomorrow. Details</div>
|
||||
`, {
|
||||
asin: "B0TITLE123",
|
||||
title: "Prime Sofa Bed",
|
||||
url: "https://www.amazon.com/dp/B0TITLE123",
|
||||
specs: [],
|
||||
bullets: [],
|
||||
matchedFilters: [],
|
||||
missingFields: [],
|
||||
extractionNotes: []
|
||||
});
|
||||
|
||||
assert.equal(details.delivery?.prime, false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user