|
|
@@ -74,7 +74,8 @@ try:
|
|
|
assert action('return Array.from(v.renderRoot.querySelectorAll(".tree-link")).map(a=>new URL(a.href).searchParams.get("type"));')==['products','social','documents','reports']
|
|
|
assert action('return Array.from(v.renderRoot.querySelectorAll(".stat")).map(a=>new URL(a.href).searchParams.get("type"));')==['products','social','documents','reports']
|
|
|
reader_surface()
|
|
|
- assert action('return v.renderRoot.getElementById("advanced-filters").hidden;')
|
|
|
+ assert not action('return !!v.renderRoot.querySelector(".advanced-toggle,#advanced-filters");')
|
|
|
+ assert action('return !!v.renderRoot.querySelector("select[aria-label=评论数量]") && !!v.renderRoot.querySelector("select[aria-label=价格]");')
|
|
|
assert action('return v.renderRoot.getElementById("coverage-insights").hidden;')
|
|
|
assert action('return v.renderRoot.querySelector("a[data-record-id]").getBoundingClientRect().top;')<350
|
|
|
assert action('return getComputedStyle(v.renderRoot.querySelector(".stats")).display;')=='none'
|
|
|
@@ -89,20 +90,52 @@ try:
|
|
|
wait('!'+V+'.renderRoot.getElementById("coverage-insights").hidden')
|
|
|
assert action('return v.renderRoot.querySelectorAll(".bar").length;')>0
|
|
|
assert evaluate('performance.getEntriesByType("resource").length')==resources
|
|
|
- action('v.renderRoot.querySelector(".insights-toggle").click();v.renderRoot.querySelector(".advanced-toggle").click();')
|
|
|
- wait('!'+V+'.renderRoot.getElementById("advanced-filters").hidden')
|
|
|
- action('const i=v.renderRoot.querySelector("input[aria-label=日期起]");i.value="2026-11-01";i.dispatchEvent(new Event("change",{bubbles:true}));')
|
|
|
- wait(V+'.routeQuery.from==="2026-11-01" && !'+V+'._loading')
|
|
|
- action('v.renderRoot.querySelector(".advanced-toggle").click();')
|
|
|
- wait(V+'.renderRoot.getElementById("advanced-filters").hidden')
|
|
|
- assert action('return !!v.renderRoot.querySelector("button[aria-label^=移除日期起]");')
|
|
|
- action('v.renderRoot.querySelector("button[aria-label^=移除日期起]").click();')
|
|
|
- wait('!'+V+'.routeQuery.from && !'+V+'._loading')
|
|
|
+ action('v.renderRoot.querySelector(".insights-toggle").click();')
|
|
|
def select(label,value):
|
|
|
selector=json.dumps('select[aria-label="'+label+'"]',ensure_ascii=False)
|
|
|
action('const s=v.renderRoot.querySelector('+selector+');s.value='+json.dumps(value)+';s.dispatchEvent(new Event("change",{bubbles:true}));')
|
|
|
- wait(V+'._loading===true || '+V+'._data?.effectiveQuery.filters['+json.dumps({'平台':'platform','品牌':'brand','品类':'category'}.get(label,label))+']')
|
|
|
+ key={'平台':'platform','品牌':'brand','品类':'category','评论数量':'sort','价格':'sort'}.get(label,label)
|
|
|
+ wait('('+V+'.routeQuery['+json.dumps(key)+'] || "")==='+json.dumps(value)+' && !'+V+'._loading && '+V+'._data')
|
|
|
ready()
|
|
|
+ select('评论数量','reviews_desc')
|
|
|
+ assert action('return v._data.totalMatched;')==4639
|
|
|
+ assert action('return v._data.records[0].relatedCounts.reviews;')==1000
|
|
|
+ assert action('return !v._data.effectiveQuery.filters.reviewCount && !v._data.effectiveQuery.filters.observedPriceMinor;')
|
|
|
+ first_counts=action('return v._data.records.map(r=>r.relatedCounts.reviews || 0);')
|
|
|
+ first_ids=action('return v._data.records.map(r=>r.record_id);')
|
|
|
+ action('Array.from(v.renderRoot.querySelectorAll(".pagination button")).find(b=>b.textContent.includes("下一页")).click();')
|
|
|
+ wait(V+'.routeQuery.cursor && !'+V+'._loading')
|
|
|
+ second_counts=action('return v._data.records.map(r=>r.relatedCounts.reviews || 0);')
|
|
|
+ assert first_counts+second_counts==sorted(first_counts+second_counts,reverse=True)
|
|
|
+ assert not set(first_ids)&set(action('return v._data.records.map(r=>r.record_id);'))
|
|
|
+ select('价格','price_asc')
|
|
|
+ assert not action('return !!v.routeQuery.cursor;')
|
|
|
+ assert action('return v._data.totalMatched;')==4639
|
|
|
+ assert action('return v.renderRoot.querySelector("select[aria-label=评论数量]").value;')==''
|
|
|
+ amounts=action('return v._data.records.map(r=>r.priceRange.minMinor);')
|
|
|
+ assert amounts==sorted(amounts)
|
|
|
+ select('价格','price_desc')
|
|
|
+ amounts=action('return v._data.records.map(r=>r.priceRange.minMinor);')
|
|
|
+ assert amounts==sorted(amounts,reverse=True)
|
|
|
+ assert action('return Array.from(v.renderRoot.querySelectorAll(".product-price")).every(el=>el.textContent.includes("¥") && el.textContent.includes("历史观察价"));')
|
|
|
+ sorted_url=evaluate('location.href');call('Page.reload');ready()
|
|
|
+ assert evaluate('location.href')==sorted_url
|
|
|
+ assert action('return v.routeQuery.sort;')=='price_desc'
|
|
|
+ action('v.renderRoot.querySelector("a[data-record-id]").click();');ready();product_ready()
|
|
|
+ product_tab('reviews')
|
|
|
+ assert product_action('return Object.keys(p._data.effectiveQuery.filters).join(",");')=='productId'
|
|
|
+ assert product_action('return p._data.effectiveQuery.sort;') is None
|
|
|
+ action('v.renderRoot.querySelector(".breadcrumb a").click();');ready()
|
|
|
+ assert action('return v.routeQuery.sort;')=='price_desc'
|
|
|
+ select('评论数量','reviews_asc')
|
|
|
+ assert action('return v._data.totalMatched;')==4639
|
|
|
+ assert action('return v.renderRoot.querySelector("select[aria-label=价格]").value;')==''
|
|
|
+ assert action('return v._data.records.every(r=>!r.relatedCounts.reviews);')
|
|
|
+ action('v.renderRoot.querySelector("a[data-record-id]").click();');ready();product_ready();product_tab('reviews')
|
|
|
+ assert product_action('return p.renderRoot.querySelector(".empty").textContent.includes("不代表平台上没有评论");')
|
|
|
+ call('Page.navigate',dict(url=args.url+'?type=products&brand=ksf&reviewCount=has&price=10-20&cursor=retired-range-cursor'));ready()
|
|
|
+ assert action('return v.routeQuery.brand==="ksf" && !v.routeQuery.reviewCount && !v.routeQuery.price && !v.routeQuery.cursor && !v._error;')
|
|
|
+ call('Page.navigate',dict(url=args.url));ready()
|
|
|
select('平台','jd')
|
|
|
wait(V+'.routeQuery.platform==="jd" && !'+V+'._loading')
|
|
|
select('品牌','ksf')
|
|
|
@@ -125,6 +158,7 @@ try:
|
|
|
product_ready()
|
|
|
assert product_action('return p.product.id;')==action('return v._detail.record.id;')
|
|
|
assert product_action('return p.renderRoot.querySelectorAll(".product-resources button").length;')==4
|
|
|
+ assert action('return v.renderRoot.querySelector("#source").getBoundingClientRect().bottom;')<700
|
|
|
product_tab('prices')
|
|
|
assert product_action('return p._data.records.every(row=>row.product_id===p.product.id);')
|
|
|
assert action('return v.routeQuery.brand;')=='ksf'
|
|
|
@@ -157,6 +191,9 @@ try:
|
|
|
assert product_action('return p._data.totalMatched;')==1000
|
|
|
assert product_action('return p._data.records.every(row=>row.product_id===p.product.id);')
|
|
|
assert product_action('return p.renderRoot.querySelectorAll(".review").length;')==20
|
|
|
+ density=product_action('const rows=Array.from(p.renderRoot.querySelectorAll(".review"));return {firstTop:rows[0].getBoundingClientRect().top,firstHeight:rows[0].getBoundingClientRect().height,visible:rows.filter(r=>r.getBoundingClientRect().bottom<innerHeight).length};')
|
|
|
+ assert density['firstTop']<320 and density['firstHeight']<110 and density['visible']>=7,density
|
|
|
+ assert product_action('return p.renderRoot.querySelector(".review .full-review").textContent===p._data.records[0].content;')
|
|
|
assert product_action('return !/SHA256|分类依据|rule_title_|source_attribute/.test(p.renderRoot.textContent);')
|
|
|
shot('library-product-reviews')
|
|
|
review_first=product_action('return p._data.records[0].record_id;')
|
|
|
@@ -172,14 +209,25 @@ try:
|
|
|
wait('!'+P+'.query.relatedCursor && !'+P+'._loading && '+P+'._data')
|
|
|
assert product_action('return p._data.records[0].record_id;')==review_first
|
|
|
assert product_action('return !p.renderRoot.querySelector("input:not([type=date]),form");')
|
|
|
- product_action('const i=p.renderRoot.querySelector("input[aria-label=商品资料日期起]");i.value="2099-01-01";i.dispatchEvent(new Event("change",{bubbles:true}));')
|
|
|
- wait(P+'.query.relatedFrom==="2099-01-01" && !'+P+'._loading && '+P+'._data?.totalMatched===0')
|
|
|
- assert product_action('return p.product.id;')==product_id
|
|
|
- product_action('Array.from(p.renderRoot.querySelectorAll("button")).find(b=>b.textContent.includes("清空当前筛选")).click();')
|
|
|
- wait('!'+P+'.query.relatedFrom && !'+P+'._loading && '+P+'._data')
|
|
|
+ assert product_action('return !p.renderRoot.querySelector("input[type=date],.date-filters");')
|
|
|
+ call('Page.navigate',dict(url=args.url+'/products/'+product_id+'?type=products&brand=ksf&sort=reviews_desc&panel=reviews&relatedQuality=audit&relatedFrom=2099-01-01&relatedTo=2099-12-31&relatedCursor=old-date-cursor'))
|
|
|
+ ready();product_ready()
|
|
|
+ assert product_action('return !p.query.relatedFrom && !p.query.relatedTo && !p.query.relatedCursor && p._data.totalMatched===1000;')
|
|
|
+ assert action('return v.routeQuery.brand=== "ksf" && v.routeQuery.sort=== "reviews_desc";')
|
|
|
+ assert product_action('return !!p.renderRoot.querySelector(".review-meta") && !p.renderRoot.querySelector("input[type=date]");')
|
|
|
+ shot('library-product-reviews')
|
|
|
product_tab('prices')
|
|
|
assert product_action('return p._data.records.every(row=>row.product_id===p.product.id);')
|
|
|
assert product_action('return !!p.renderRoot.querySelector(".price-heading strong");')
|
|
|
+ assert product_action('return !p.renderRoot.querySelector("input[type=date],.date-filters");')
|
|
|
+ price_total=product_action('return p._data.totalMatched;')
|
|
|
+ call('Page.navigate',dict(url=args.url+'/products/'+product_id+'?type=products&brand=ksf&sort=price_asc&panel=prices&relatedQuality=audit&relatedFrom=2099-01-01&relatedTo=2099-12-31&relatedCursor=old-price-date-cursor'))
|
|
|
+ ready();product_ready()
|
|
|
+ assert product_action('return !p.query.relatedFrom && !p.query.relatedTo && !p.query.relatedCursor;')
|
|
|
+ assert product_action('return p._data.totalMatched;')==price_total
|
|
|
+ assert product_action('return p._data.records.every(row=>row.product_id===p.product.id) && !p._data.effectiveQuery.filters.sourceDate;')
|
|
|
+ assert product_action('return p.renderRoot.querySelector(".price").textContent.includes("观察时间") && !p.renderRoot.querySelector("input[type=date],.date-filters");')
|
|
|
+ assert action('return v.routeQuery.brand=== "ksf" && v.routeQuery.sort=== "price_asc";')
|
|
|
shot('library-product-prices')
|
|
|
product_tab('specs')
|
|
|
assert product_action('return p._data.records.every(row=>row.product_id===p.product.id);')
|
|
|
@@ -275,10 +323,7 @@ try:
|
|
|
action('v.renderRoot.querySelector(".breadcrumb a").click();')
|
|
|
wait(V+'._data && !'+V+'._loading && !'+V+'.recordId')
|
|
|
go_type('products')
|
|
|
- action('v.renderRoot.querySelector(".advanced-toggle").click();')
|
|
|
- wait('!'+V+'.renderRoot.getElementById("advanced-filters").hidden')
|
|
|
- action('const i=v.renderRoot.querySelector("input[aria-label=日期起]");i.value="2099-01-01";i.dispatchEvent(new Event("change",{bubbles:true}));')
|
|
|
- wait(V+'.routeQuery.from==="2099-01-01" && !'+V+'._loading')
|
|
|
+ call('Page.navigate',dict(url=args.url+'?type=products&from=2099-01-01'));ready()
|
|
|
assert action('return v._data.totalMatched;')==0
|
|
|
action('v.renderRoot.querySelector(".empty button").click();')
|
|
|
wait('!'+V+'.routeQuery.from && !'+V+'._loading && '+V+'._data?.totalMatched===4639')
|
|
|
@@ -334,7 +379,7 @@ try:
|
|
|
shot('library-mobile-detail')
|
|
|
failures=[x for x in events if x.get('method')=='Runtime.exceptionThrown']
|
|
|
assert not failures,failures
|
|
|
- result=dict(ok=True,scope=scope,layouts=layouts,tests=['product-catalog-navigation','real-data-counts','exact-filters','active-filter-removal','advanced-filters','display-mode-no-refetch','coverage-toggle','product-inline-panels','product-review-date-filter','no-search-controls','legacy-search-link-normalization','report-stage-filter','compact-layout','product-review-pagination-refresh','product-isolation','product-panel-error-recovery','legacy-product-link','deep-refresh','back-preserves-filters','review-quality','policy-prose-first','reader-source-without-internal-fields','reader-citation','clause-original-source','previous-next-pagination','zero-result-reset','connection-error-recovery','typed-price-spec-coverage-cards','legacy-category-details','mobile-overview','mobile-product-tabs','mobile-navigation','mobile-facts'],productionWrites=0,consoleExceptions=0)
|
|
|
+ result=dict(ok=True,scope=scope,layouts=layouts,productReviewDensity=density,tests=['product-catalog-navigation','real-data-counts','exact-filters','active-filter-removal','review-count-sorting','historical-price-sorting','sort-keeps-all-results','uncaptured-reviews','sorted-pagination-refresh','retired-range-link-normalization','display-mode-no-refetch','coverage-toggle','product-inline-panels','compact-product-overview','compact-review-density','review-original-text-preserved','review-date-filter-removed','legacy-review-date-link-normalization','no-search-controls','legacy-search-link-normalization','report-stage-filter','compact-layout','product-review-pagination-refresh','product-isolation','product-panel-error-recovery','legacy-product-link','deep-refresh','back-preserves-filters','review-quality','policy-prose-first','reader-source-without-internal-fields','reader-citation','clause-original-source','previous-next-pagination','zero-result-reset','connection-error-recovery','typed-price-spec-coverage-cards','legacy-category-details','mobile-overview','mobile-product-tabs','mobile-navigation','mobile-facts'],productionWrites=0,consoleExceptions=0)
|
|
|
(WORK/'browser-validation.json').write_text(json.dumps(result,ensure_ascii=False,indent=2)+'\n',encoding='utf-8')
|
|
|
print(json.dumps(result,ensure_ascii=False,indent=2))
|
|
|
finally:
|