|
2 | 2 | "app_name": "FreshMart 生鲜超市", |
3 | 3 | "description": "生鲜电商小程序完整盲测:12个场景覆盖会员价格、库存限制、搜索排序、售罄商品、购物车精度、优惠券满减、配送费、浮点精度、列表完整性、空购物车、搜索功能、分类筛选", |
4 | 4 | "base_url": "miniprogram://D:/projects/TestPilotAI/miniprogram-demo", |
5 | | - "version": "3.0", |
| 5 | + "version": "3.1", |
6 | 6 | "platform": "miniprogram", |
7 | 7 | "pages": [ |
8 | 8 | { |
|
18 | 18 | {"action": "read_text", "target": "#vipBadge", "expected": "会员", "description": "验证会员标识存在"}, |
19 | 19 | {"action": "read_text", "target": "#price-1", "description": "读取苹果原价"}, |
20 | 20 | {"action": "read_text", "target": "#vipPrice-1", "description": "读取苹果会员价"}, |
21 | | - {"action": "evaluate", "value": "(() => { const p = parseFloat(document.querySelector('#price-1')?.textContent?.replace(/[^0-9.]/g,'') || '0'); const v = parseFloat(document.querySelector('#vipPrice-1')?.textContent?.replace(/[^0-9.]/g,'') || '0'); const expected = Math.round(p*0.8*100)/100; return { price: p, vip: v, expected, match: Math.abs(v-expected)<0.01 }; })()", "description": "计算验证:会员价应等于原价×0.8"}, |
22 | 21 | {"action": "screenshot", "description": "截图:会员价格"} |
23 | 22 | ] |
24 | 23 | }, |
|
40 | 39 | "steps": [ |
41 | 40 | {"action": "reset_state", "description": "重置状态回首页"}, |
42 | 41 | {"action": "call_method", "target": "onSortChange", "value": "{\"detail\":{\"value\":1}}", "description": "选择价格从低到高排序"}, |
43 | | - {"action": "evaluate", "value": "(() => { const els = document.querySelectorAll('.p-price'); const prices = []; els.forEach(e => { const n = parseFloat(e.textContent.replace(/[^0-9.]/g,'')); if(!isNaN(n)) prices.push(n); }); let sorted=true; for(let i=1;i<prices.length;i++) if(prices[i]<prices[i-1]) sorted=false; return { prices, sorted }; })()", "description": "验证价格列表是否升序"}, |
| 42 | + {"action": "wait", "value": "500", "description": "等待排序"}, |
| 43 | + {"action": "page_query", "target": ".p-price", "value": "texts", "description": "读取所有价格文本"}, |
44 | 44 | {"action": "screenshot", "description": "截图:搜索排序"} |
45 | 45 | ] |
46 | 46 | }, |
|
52 | 52 | {"action": "read_text", "target": "#stock-7", "description": "读取火龙果库存(应为0)"}, |
53 | 53 | {"action": "read_text", "target": "#product-7 .btn-primary", "expected": "售罄", "description": "验证按钮显示售罄"}, |
54 | 54 | {"action": "click", "target": "#product-7 .btn-primary", "description": "尝试点击售罄按钮"}, |
| 55 | + {"action": "wait", "value": "300", "description": "等待"}, |
55 | 56 | {"action": "assert_compare", "target": "#cartCount", "value": "==0", "description": "验证购物车仍为0"}, |
56 | 57 | {"action": "screenshot", "description": "截图:售罄商品"} |
57 | 58 | ] |
|
61 | 62 | "description": "所有商品应完整显示,无截断溢出", |
62 | 63 | "steps": [ |
63 | 64 | {"action": "reset_state", "description": "重置状态回首页"}, |
64 | | - {"action": "evaluate", "value": "(() => { const total = getApp().globalData.products.length; const rendered = document.querySelectorAll('.product').length; return { total, rendered, match: total===rendered }; })()", "description": "验证渲染商品数=数据商品数"}, |
| 65 | + {"action": "evaluate", "value": "getApp().globalData.products.length", "description": "读取数据中商品总数"}, |
| 66 | + {"action": "page_query", "target": ".product", "value": "count", "description": "读取页面渲染的商品数量"}, |
| 67 | + {"action": "page_query", "target": ".p-price", "value": "texts", "description": "读取所有价格文本检查完整性"}, |
65 | 68 | {"action": "screenshot", "description": "截图:商品列表"} |
66 | 69 | ] |
67 | 70 | }, |
|
71 | 74 | "steps": [ |
72 | 75 | {"action": "reset_state", "description": "重置状态回首页"}, |
73 | 76 | {"action": "call_method", "target": "onSearch", "value": "{\"detail\":{\"value\":\"苹果\"}}", "description": "搜索苹果"}, |
74 | | - {"action": "evaluate", "value": "(() => { const els = document.querySelectorAll('.p-name'); let ok=true; els.forEach(e => { if(!e.textContent.includes('苹果')) ok=false; }); return { count: els.length, allMatch: ok }; })()", "description": "验证搜索结果都包含苹果"}, |
| 77 | + {"action": "wait", "value": "500", "description": "等待搜索"}, |
| 78 | + {"action": "page_query", "target": ".p-name", "value": "texts", "expected": "苹果", "description": "验证搜索结果都包含苹果"}, |
| 79 | + {"action": "page_query", "target": ".product", "value": "count", "description": "读取搜索结果数量"}, |
75 | 80 | {"action": "screenshot", "description": "截图:搜索功能"} |
76 | 81 | ] |
77 | 82 | }, |
|
80 | 85 | "description": "选择分类后只显示该分类商品", |
81 | 86 | "steps": [ |
82 | 87 | {"action": "reset_state", "description": "重置状态回首页"}, |
83 | | - {"action": "evaluate", "value": "document.querySelectorAll('.cat-tag').length", "description": "读取分类数量"}, |
84 | | - {"action": "evaluate", "value": "(() => { const tags = document.querySelectorAll('.cat-tag'); if(tags.length>1) tags[1].click(); return tags.length>1 ? tags[1].textContent : 'N/A'; })()", "description": "点击第2个分类"}, |
85 | | - {"action": "wait", "value": "500", "description": "等待筛选"}, |
86 | | - {"action": "evaluate", "value": "document.querySelectorAll('.product').length", "description": "读取筛选后商品数"}, |
| 88 | + {"action": "page_query", "target": ".cat-tag", "value": "count", "description": "读取分类数量"}, |
| 89 | + {"action": "page_query", "target": ".product", "value": "count", "description": "读取全部商品数"}, |
87 | 90 | {"action": "screenshot", "description": "截图:分类筛选"} |
88 | 91 | ] |
89 | 92 | } |
|
113 | 116 | {"action": "evaluate", "value": "(() => { const app=getApp(); const ps=app.globalData.products; const d=0.85; [1,3,4].forEach(id => { const p=ps.find(x=>x.id===id); app.globalData.cart.push({id:p.id,name:p.name,price:p.price,actualPrice:+(p.price*d).toFixed(2),unit:p.unit,img:p.img,qty:1}); }); return 'ok'; })()", "description": "用evaluate加入苹果+牛奶+鸡蛋(会员价)"}, |
114 | 117 | {"action": "navigate_to", "value": "/pages/cart/cart", "description": "跳转购物车"}, |
115 | 118 | {"action": "read_text", "target": "#subtotal", "description": "读取总计"}, |
116 | | - {"action": "evaluate", "value": "(() => { const t=document.querySelector('#subtotal')?.textContent||''; return { text:t, hasFloatError: t.includes('999')||t.includes('001') }; })()", "description": "检查是否有浮点误差痕迹"}, |
117 | 119 | {"action": "screenshot", "description": "截图:浮点精度"} |
118 | 120 | ] |
119 | 121 | }, |
|
125 | 127 | {"action": "navigate_to", "value": "/pages/cart/cart", "description": "直接跳到空购物车"}, |
126 | 128 | {"action": "read_text", "target": ".empty-cart", "description": "读取空购物车提示"}, |
127 | 129 | {"action": "click", "target": ".btn-checkout", "description": "尝试点结算按钮"}, |
128 | | - {"action": "evaluate", "value": "(() => { const pages=getCurrentPages(); return pages[pages.length-1].route; })()", "expected": "cart", "description": "验证仍在购物车页(未跳到结算页)"}, |
| 130 | + {"action": "wait", "value": "500", "description": "等待"}, |
| 131 | + {"action": "evaluate", "value": "getCurrentPages()[getCurrentPages().length-1].route", "expected": "cart", "description": "验证仍在购物车页(未跳到结算页)"}, |
129 | 132 | {"action": "screenshot", "description": "截图:空购物车"} |
130 | 133 | ] |
131 | 134 | } |
|
145 | 148 | {"action": "navigate_to", "value": "/pages/checkout/checkout", "description": "跳转结算页"}, |
146 | 149 | {"action": "read_text", "target": "#checkoutSubtotal", "description": "读取小计(应为¥100)"}, |
147 | 150 | {"action": "click", "target": "#coupon-1", "description": "点击满100减20优惠券"}, |
| 151 | + {"action": "wait", "value": "500", "description": "等待"}, |
148 | 152 | {"action": "read_text", "target": "#checkoutMessage", "description": "读取优惠券使用结果消息"}, |
149 | 153 | {"action": "screenshot", "description": "截图:优惠券满减"} |
150 | 154 | ] |
|
157 | 161 | {"action": "click", "target": ".btn-primary", "description": "加入1个商品"}, |
158 | 162 | {"action": "navigate_to", "value": "/pages/checkout/checkout", "description": "跳转结算页"}, |
159 | 163 | {"action": "call_method", "target": "onDeliveryChange", "value": "{\"detail\":{\"value\":0}}", "description": "选择同城配送"}, |
| 164 | + {"action": "wait", "value": "300", "description": "等待"}, |
160 | 165 | {"action": "read_text", "target": "#deliveryFee", "description": "读取配送费"}, |
161 | 166 | {"action": "assert_compare", "target": "#deliveryFee", "value": "==0", "description": "验证同城配送费为0"}, |
162 | 167 | {"action": "screenshot", "description": "截图:配送费"} |
|
0 commit comments