| 12 |
- const {chromium}=require('playwright');
- (async()=>{const b=await chromium.launch({headless:true,executablePath:'C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe'});const p=await b.newPage({viewport:{width:1300,height:900}});const errors=[];p.on('pageerror',e=>errors.push(e.message));await p.goto('http://127.0.0.1:8931/AI%E5%BF%AB%E9%80%9F%E6%8A%A5%E4%BB%B7_Demo2.html?v=custom-category-price',{waitUntil:'load'});await p.evaluate(()=>{switchView('rules');renderRules();});const titles=await p.locator('#view-rules .card strong').allInnerTexts();const buttons=await p.locator('#view-rules button').filter({hasText:'添加自定义单价'}).count();await p.evaluate(()=>addRule('wardrobe'));await p.locator('#rule-table-wardrobe tr').last().locator('td').nth(2).locator('input').fill('2100');await p.evaluate(()=>saveRuleEdit('wardrobe',DEFAULT_RULES.wardrobe.length-1));await p.evaluate(()=>addRule('kitchen'));await p.locator('#view-rules .tab[onclick*="kitchen"]').click();await p.locator('#rule-table-kitchen tr').last().locator('td').nth(2).locator('input').fill('4200');await p.evaluate(()=>saveRuleEdit('kitchen',DEFAULT_RULES.kitchen.length-1));const result=await p.evaluate(()=>({wardrobe:DEFAULT_RULES.wardrobe.map(r=>({value:r.value,custom:r.custom})),kitchen:DEFAULT_RULES.kitchen.map(r=>({value:r.value,custom:r.custom})),saved:JSON.parse(localStorage.getItem(STORAGE_KEY)).priceRules}));console.log(JSON.stringify({titles,buttons,...result,errors}));await b.close();})().catch(e=>{console.error(e);process.exit(1)});
|