fix: correct ebay title filtering and type contracts

This commit is contained in:
2026-04-27 02:04:48 -04:00
parent b73faa35da
commit 224e83ac4c
5 changed files with 69 additions and 8 deletions

View File

@@ -419,6 +419,33 @@ describe("eBay Scraper Cookie Handling", () => {
]);
});
test("keeps short titles that were not shortened by UI cleaning", async () => {
global.fetch = mock(() =>
Promise.resolve({
ok: true,
text: () =>
Promise.resolve(`
<html><body>
<li class="s-item">
<a href="/itm/123"></a>
<h3>Free Bike</h3>
<span class="s-item__price">CA $0.00</span>
</li>
</body></html>
`),
}),
) as typeof fetch;
const results = await fetchEbayItems("bike", 1000);
expect(results).toEqual([
expect.objectContaining({
title: "Free Bike",
listingPrice: expect.objectContaining({ cents: 0, currency: "CAD" }),
}),
]);
});
test("accepts higher fallback prices without price classes", async () => {
global.fetch = mock(() =>
Promise.resolve({

View File

@@ -1804,6 +1804,36 @@ describe("Facebook Marketplace Scraper Core Tests", () => {
}),
]);
});
test("keeps free search listings when amount is missing but formatted_amount is FREE", () => {
const ads = [
{
node: {
listing: {
id: "free-no-amount",
marketplace_listing_title: "Free Sofa",
listing_price: {
formatted_amount: "FREE",
currency: "CAD",
},
is_live: true,
},
},
},
];
const results = parseFacebookAds(ads);
expect(results).toEqual([
expect.objectContaining({
title: "Free Sofa",
listingPrice: expect.objectContaining({
cents: 0,
amountFormatted: "FREE",
}),
}),
]);
});
});
});