feat(pl): 展示各装送段用证配置与独立占用明细并保留历史计量口径。
This commit is contained in:
1 parent
706260ff7a
commit
b764eb02a7
10 files changed
+497
-40
No files matched your search
@@ -29,3 +29,42 @@ for (const arrange of [false, true]) test(`stale ${arrange ? 'preview' : 'save'}
|
||||
assert.equal(h.state.visible.value, true)
|
||||
assert.equal(h.state.busy.value, true)
|
||||
})
|
||||
|
||||
for (const methodName of ['preview', 'loadContext'])
|
||||
test(`${methodName} ignores a result when configuration changes in flight`, async () => {
|
||||
const script = parse(
|
||||
readFileSync(
|
||||
new URL('../src/components/business/pl-plan-quota-dialog/index.vue', import.meta.url),
|
||||
'utf8'
|
||||
)
|
||||
).descriptor.scriptSetup!.content
|
||||
const ast = ts.createSourceFile('quota.ts', script, ts.ScriptTarget.Latest, true)
|
||||
const method = ast.statements
|
||||
.find((n) => ts.isFunctionDeclaration(n) && n.name?.text === methodName)!
|
||||
.getText(ast)
|
||||
let finish!: (value: any) => void
|
||||
const pending = new Promise<any>((r) => {
|
||||
finish = r
|
||||
})
|
||||
const state: any = {
|
||||
plan: { value: { planId: 'a' } },
|
||||
busy: { value: false },
|
||||
result: { value: undefined },
|
||||
context: { value: undefined },
|
||||
payload: () => ({}),
|
||||
previewVehicle: {},
|
||||
planQuotaApi: { preview: () => pending, context: () => pending }
|
||||
}
|
||||
const js = ts.transpileModule(
|
||||
`let epoch=0,revision=0;${method};return {run:${methodName},change:()=>revision++}`,
|
||||
{ compilerOptions: { target: ts.ScriptTarget.ES2022 } }
|
||||
).outputText
|
||||
const actions = new Function(...Object.keys(state), js)(...Object.values(state))
|
||||
const task = actions.run()
|
||||
actions.change()
|
||||
finish({ status: 'available', sourceFingerprint: 'old' })
|
||||
await task
|
||||
assert.equal(state.result.value, undefined)
|
||||
assert.equal(state.context.value, undefined)
|
||||
assert.equal(state.busy.value, false)
|
||||
})
|
||||
Reference in new issue
Block a user