debug_rule_categories.js 1.3 KB

12
  1. const {chromium}=require('playwright');
  2. (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=rule-category-test',{waitUntil:'load'});await p.evaluate(()=>{switchView('rules');renderRules();});await p.waitForTimeout(200);const wardrobe=await p.locator('#rule-table-wardrobe tr').count();await p.locator('#view-rules .tab[onclick*="kitchen"]').click();const kitchen=await p.locator('#rule-table-kitchen tr').count();await p.locator('#view-rules .tab[onclick*="wardrobe"]').click();await p.evaluate(()=>startRuleEdit('wardrobe',0));const input=p.locator('#rule-table-wardrobe tr').first().locator('td').nth(2).locator('input');await input.fill('1900');await p.evaluate(()=>saveRuleEdit('wardrobe',0));const result=await p.evaluate(()=>({wardrobeNames:DEFAULT_RULES.wardrobe.map(r=>r.name),kitchenNames:DEFAULT_RULES.kitchen.map(r=>r.name),saved:JSON.parse(localStorage.getItem(STORAGE_KEY)).priceRules.wardrobe[0].value}));console.log(JSON.stringify({wardrobe,kitchen,...result,errors}));await b.close();})().catch(e=>{console.error(e);process.exit(1)});