feat: enhance Stalker functionality with additional product details and analysis capabilities
This commit is contained in:
@@ -75,6 +75,30 @@ test("sellability checks matched seller inventory, not the source ASIN", async (
|
||||
const url = new URL(rawUrl);
|
||||
|
||||
if (url.pathname === "/product") {
|
||||
if (url.searchParams.get("asin") === "B111111111") {
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
products: [
|
||||
{
|
||||
asin: "B111111111",
|
||||
title: "Sellable Storefront Product",
|
||||
brand: "Good Brand",
|
||||
categoryTree: [{ name: "Kitchen" }, { name: "Storage" }],
|
||||
monthlySold: 42,
|
||||
stats: {
|
||||
current: [null, null, null, 12345, null, null, null, null, null, null, null, 7],
|
||||
avg: [2500],
|
||||
},
|
||||
csv: [[0, 1999]],
|
||||
},
|
||||
],
|
||||
tokensLeft: 10,
|
||||
refillRate: 10,
|
||||
}),
|
||||
{ status: 200 },
|
||||
);
|
||||
}
|
||||
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
products: [
|
||||
@@ -126,6 +150,7 @@ test("sellability checks matched seller inventory, not the source ASIN", async (
|
||||
resume: true,
|
||||
maxSellerRequests: null,
|
||||
sellability: true,
|
||||
analyzeSellable: false,
|
||||
});
|
||||
|
||||
expect(fetchSellabilityBatchMock.mock.calls.length).toBe(1);
|
||||
@@ -146,18 +171,37 @@ test("sellability checks matched seller inventory, not the source ASIN", async (
|
||||
|
||||
const inventory = db
|
||||
.query(
|
||||
"SELECT asin, can_sell, sellability_status FROM stalker_seller_inventory ORDER BY asin",
|
||||
`SELECT asin, can_sell, sellability_status, product_title, brand,
|
||||
category_tree, current_price, avg_price_90d, sales_rank, monthly_sold,
|
||||
seller_count
|
||||
FROM stalker_seller_inventory ORDER BY asin`,
|
||||
)
|
||||
.all() as Array<{
|
||||
asin: string;
|
||||
can_sell: number | null;
|
||||
sellability_status: string | null;
|
||||
product_title: string | null;
|
||||
brand: string | null;
|
||||
category_tree: string | null;
|
||||
current_price: number | null;
|
||||
avg_price_90d: number | null;
|
||||
sales_rank: number | null;
|
||||
monthly_sold: number | null;
|
||||
seller_count: number | null;
|
||||
}>;
|
||||
expect(inventory).toEqual([
|
||||
{
|
||||
asin: "B111111111",
|
||||
can_sell: 1,
|
||||
sellability_status: "available",
|
||||
product_title: "Sellable Storefront Product",
|
||||
brand: "Good Brand",
|
||||
category_tree: JSON.stringify(["Kitchen", "Storage"]),
|
||||
current_price: 19.99,
|
||||
avg_price_90d: 25,
|
||||
sales_rank: 12345,
|
||||
monthly_sold: 42,
|
||||
seller_count: 7,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user