fix: correct ebay title filtering and type contracts
This commit is contained in:
@@ -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({
|
||||
|
||||
@@ -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",
|
||||
}),
|
||||
}),
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user