feat: ebay splashui challenge solver
argon2id pow → /challengesvc/answer → chlgref cookie warm homepage for akamai cookies, detect 307 redirect, solve + retry transparently in fetchEbayItems flow
This commit is contained in:
@@ -47,17 +47,22 @@ describe("eBay Scraper Cookie Handling", () => {
|
||||
test("should ignore request cookie overrides and rely on EBAY_COOKIE", async () => {
|
||||
await fetchEbayItems("laptop", 1000);
|
||||
|
||||
expect(global.fetch).toHaveBeenCalledTimes(1);
|
||||
// First call is homepage warm-up, second is search
|
||||
expect(global.fetch).toHaveBeenCalledTimes(2);
|
||||
|
||||
const firstFetchCall = (global.fetch as unknown as ReturnType<typeof mock>)
|
||||
.mock.calls[0];
|
||||
if (!firstFetchCall) {
|
||||
throw new Error("Expected fetch to be called");
|
||||
// The search request is the second call
|
||||
const secondFetchCall = (global.fetch as unknown as ReturnType<typeof mock>)
|
||||
.mock.calls[1];
|
||||
if (!secondFetchCall) {
|
||||
throw new Error("Expected search fetch to be called");
|
||||
}
|
||||
|
||||
const [, init] = firstFetchCall;
|
||||
const [searchUrl, init] = secondFetchCall;
|
||||
const headers = (init as RequestInit).headers as Record<string, string>;
|
||||
|
||||
expect(searchUrl).toBe(
|
||||
"https://www.ebay.ca/sch/i.html?_nkw=laptop&_sacat=0&_from=R40&LH_BIN=1&LH_PrefLoc=1",
|
||||
);
|
||||
expect(headers.Cookie).toBeUndefined();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user