mirror of
https://github.com/primedigitaltech/azon_seeker.git
synced 2026-10-05 07:13:06 +08:00
* feat: add Amazon collection metadata and reliable sync * fix: route extension sync through configured server * chore: release extension v0.7.13 * fix: handle extension ports across BFCache navigation * fix: classify bottom Sponsored Brands video placements * fix: exclude hidden Amazon ad cards * fix: derive Amazon result page from URL * fix: ignore hidden Amazon sponsored products * fix: preserve base Amazon product collection * fix: bind Amazon results to visible page * fix: classify visible Amazon ad formats * fix: wait for lazy Amazon ad modules * perf: reduce Amazon lazy-load scroll stops * fix: classify Amazon sponsored brand and video search ads Co-authored-by: Cursor <cursoragent@cursor.com> * fix: collect Shop by type thematic SP ads via redirect chains without data-asin Co-authored-by: Cursor <cursoragent@cursor.com> * fix: classify sponsored ads across new Amazon templates --------- Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: PetrichorFun <127877748+PetrichorFun@users.noreply.github.com>
82 lines
2.6 KiB
TypeScript
82 lines
2.6 KiB
TypeScript
import {
|
|
extractAmazonDetailAsin,
|
|
hasReachedAmazonDetailPage,
|
|
hasReachedAmazonNavigationTarget,
|
|
} from '../src/page-worker/page-navigation';
|
|
|
|
const assert = (condition: boolean, message: string) => {
|
|
if (!condition) throw new Error(message);
|
|
};
|
|
|
|
assert(
|
|
!hasReachedAmazonNavigationTarget(
|
|
'https://www.amazon.com/product-reviews/B08XM6S6ZL?reviewerType=all_reviews',
|
|
'https://www.amazon.com/product-reviews/B08XM6S6ZL?reviewerType=all_reviews&filterByStar=one_star',
|
|
),
|
|
'An unfiltered completed page must not satisfy a star-filter navigation.',
|
|
);
|
|
|
|
assert(
|
|
hasReachedAmazonNavigationTarget(
|
|
'https://www.amazon.com/product-reviews/B08XM6S6ZL/ref=cm_cr_arp_d_viewopt_sr?filterByStar=one_star&pageNumber=2',
|
|
'https://www.amazon.com/product-reviews/B08XM6S6ZL/ref=cm_cr_arp_d_paging_btm_next_2?filterByStar=one_star&pageNumber=2',
|
|
),
|
|
'Tracking ref rewrites must not prevent matching the requested review page.',
|
|
);
|
|
|
|
assert(
|
|
!hasReachedAmazonNavigationTarget(
|
|
'https://www.amazon.com/product-reviews/B08XM6S6ZL?filterByStar=one_star&pageNumber=1',
|
|
'https://www.amazon.com/product-reviews/B08XM6S6ZL?filterByStar=one_star&pageNumber=2',
|
|
),
|
|
'A previous review page must not satisfy the next-page navigation.',
|
|
);
|
|
|
|
assert(
|
|
hasReachedAmazonNavigationTarget(
|
|
'https://www.amazon.com/s?k=security+camera&page=17&ref=sr_pg_17',
|
|
'https://www.amazon.com/s?ref=sr_pg_17&page=17&k=security+camera',
|
|
),
|
|
'Search navigation should tolerate query ordering differences.',
|
|
);
|
|
|
|
assert(
|
|
hasReachedAmazonNavigationTarget(
|
|
'https://www.amazon.com/Product-Name/dp/B0DMNDL5NH/ref=sr_1_1',
|
|
'https://www.amazon.com/dp/B0DMNDL5NH',
|
|
),
|
|
'A canonical product slug must still match the requested detail ASIN.',
|
|
);
|
|
|
|
assert(
|
|
!hasReachedAmazonNavigationTarget(
|
|
'https://www.amazon.com/Product-Name/dp/B0DMNDL5NH',
|
|
'https://www.amazon.com/dp/B0BKPNRLC8',
|
|
),
|
|
'The previous detail ASIN must not satisfy the next-ASIN navigation.',
|
|
);
|
|
|
|
assert(
|
|
hasReachedAmazonDetailPage(
|
|
'https://www.amazon.com/Product-Name/dp/B0CCXB29LF?th=1',
|
|
'https://www.amazon.com/dp/B0D2MC2865',
|
|
),
|
|
'A canonical Amazon detail redirect must be accepted as a loaded detail page.',
|
|
);
|
|
|
|
assert(
|
|
!hasReachedAmazonDetailPage(
|
|
'https://www.amazon.com/',
|
|
'https://www.amazon.com/dp/B0D2MC2865',
|
|
),
|
|
'The Amazon home page must not be accepted as a detail redirect.',
|
|
);
|
|
|
|
assert(
|
|
extractAmazonDetailAsin('https://www.amazon.com/Product-Name/dp/B0CCXB29LF?th=1') ===
|
|
'B0CCXB29LF',
|
|
'The resolved ASIN must be extracted from canonical detail URLs.',
|
|
);
|
|
|
|
console.log('Amazon page navigation tests passed.');
|