'use strict'; const test=require('node:test'),assert=require('node:assert/strict'); const {orderDrivenUI}=require('../fixtures/order-driven-ui.cjs'); test('scope comboboxes search actual BPM choices, cascade nodes and preserve the internal Excel identity',{timeout:60000},async t=>{ const {page,runtime}=await orderDrivenUI(t,'#order-rules'),s=runtime.orderRules,catalog=require('../../src/modules/order-rules/scope-catalog.cjs'); catalog.observe(s,[{source:'todo',processName:'海外运营订单评审',nodeName:'海外通知节点'},{source:'todo',processName:'海外IPC订单评审',nodeName:'IPC通知节点'}]); await page.getByRole('button',{name:'刷新规则与字段',exact:true}).click();await page.locator('[data-rule-id="bs-change"]').click();const original=s.get('rules','bs-change').draft; assert.equal(await page.locator('#rule-scope-search,#rule-categoryId').count(),0); await page.getByRole('button',{name:'添加流程节点',exact:true}).click();const process=page.locator('#scope-process-1-ts-control');await process.fill('海外'); await page.waitForFunction(()=>document.querySelectorAll('#scope-process-1-ts-dropdown [data-selectable]').length===2);const options=page.locator('#scope-process-1-ts-dropdown [data-selectable]');assert.equal(await options.count(),2);assert.doesNotMatch((await options.allTextContents()).join(' '),/备损/); await process.press('ArrowDown');await process.press('Enter');const node=page.locator('#scope-node-1-ts-control');await node.fill('通知'); const nodeOptions=page.locator('#scope-node-1-ts-dropdown [data-selectable]');await nodeOptions.first().waitFor();assert.equal(await nodeOptions.count(),1);await node.press('Enter'); const selected=await page.locator('[data-scope-row]').nth(1).locator('[data-scope-process]').inputValue();assert.match(selected,/海外/); await page.getByRole('button',{name:'保存草稿',exact:true}).click();await page.getByText('规则草稿已保存。',{exact:true}).waitFor();const saved=s.get('rules','bs-change').draft;assert.equal(saved.categoryId,original.categoryId);assert.equal(saved.scopes.length,2);assert(saved.scopes.some(r=>r.processName===selected&&/通知/.test(r.nodeName))); await page.setViewportSize({width:390,height:844});assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),true); }); test('unselected search text never becomes a rule value and removed rows dispose their comboboxes',{timeout:60000},async t=>{ const {page,runtime}=await orderDrivenUI(t,'#order-rules');await page.locator('[data-rule-id="bs-change"]').click();const before=runtime.orderRules.get('rules','bs-change').draft; const input=page.locator('#scope-process-0-ts-control');await input.fill('并不存在的流程');await page.locator('#scope-process-0-ts-dropdown .no-results').waitFor();assert.equal(await page.locator('#scope-process-0-ts-dropdown [data-selectable]').count(),0);assert.equal(await page.evaluate(()=>PageLifecycle.dirty()),false);await input.press('Escape');await page.getByLabel('规则名称',{exact:true}).click(); assert.equal(await page.locator('[data-scope-process]').inputValue(),before.processNames[0]);assert.deepEqual(runtime.orderRules.get('rules','bs-change').draft,before); await page.getByRole('button',{name:'添加流程节点',exact:true}).click();await page.getByRole('button',{name:'删除第2行',exact:true}).click();assert.equal(await page.locator('[data-scope-row]').count(),1);assert.equal(await page.locator('.ts-wrapper').count(),2); });