From ca09aed6120ceb59badfc483eadb0c5104c57dd3 Mon Sep 17 00:00:00 2001 From: ThearchyHelios Date: Mon, 5 Oct 2026 04:16:01 +0800 Subject: [PATCH] =?UTF-8?q?check-whatif=20=E8=A1=A5=E7=A9=BA=E6=80=81?= =?UTF-8?q?=EF=BC=9A=E5=8E=9F=E5=BC=8F=E6=B2=A1=E6=9C=89=E5=BC=95=E7=94=A8?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=97=B6=E8=AF=B4=E6=B8=85=E6=97=A0=E5=8F=AF?= =?UTF-8?q?=E6=8E=A8=E6=BC=94=EF=BC=8C=E4=B8=8D=E7=94=BB=E7=A9=BA=E5=88=97?= =?UTF-8?q?=E8=A1=A8=EF=BC=8C=E4=B9=9F=E4=B8=8D=E7=94=BB=E3=80=8C=E6=8A=A5?= =?UTF-8?q?=E5=91=8A=E4=B8=AD=E4=BC=9A=E5=8F=98=E7=9A=84=E5=9C=B0=E6=96=B9?= =?UTF-8?q?=E3=80=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/check-whatif.mjs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scripts/check-whatif.mjs b/scripts/check-whatif.mjs index 8f57c164..4933764e 100644 --- a/scripts/check-whatif.mjs +++ b/scripts/check-whatif.mjs @@ -83,6 +83,12 @@ function whatifReply(body) { segments: [{ report: 'write', unit: 'u4', sid: 's22', metric: 'adj', rendered_old: '44,000.0元', rendered_new: '44,000.0元', changed: false }], unsupported: [{ metric: 'adj', input: 'vars.adjust.items', reason: '无法推演:当时没有保存这个输入的完整值' }] } } + if (body?.metric === 'fx') { + // 空态:原式里没有引用任何输入(写死的常数) + return { ...base, metrics: [{ id: 'fx', name: '汇率', unit: '', old: 7.12, new: 7.12, delta: 0, rendered_old: '7.12', + rendered_new: '7.12', rendered_delta: null, changed: false, status: 'unchanged', reason: null, substituted: '7.12', inputs: [] }], + segments: [], unsupported: [] } + } const def = METRICS[body?.metric] const step = chainOf(def.sid)[0] const views = inputsOf(def.sid).map((inp) => { @@ -301,6 +307,16 @@ await section('不支持的输入', async () => { await ctx.close() }) +await section('空态', async () => { + const { ctx, page } = await open('whatif') + await openMetric(page, 's24') + await openWhatIf(page) + check('原式没有引用输入:说清无可推演,不画空列表', (await text(page, '[data-whatif-empty]')).includes('无可推演') + && await page.locator('[data-whatif-input]').count() === 0) + check('没有报告引用时不画「报告中会变的地方」', await page.locator('[data-whatif-segments]').count() === 0) + await ctx.close() +}) + await section('加载、失败、未封存', async () => { let release const gate = new Promise((r) => { release = r })