test(plugin-detail): record:alert 的 visible 判定改由真实谓词管道裁决 (#3941) - #4803
Merged
Conversation
…cate pipeline (#3941) The suite stubbed BOTH ends of the predicate pipeline: an identity `toPredicateInput` that only recorded its argument, and a `useCondition` pinned to a constant. Between them the banner's `visible` verdict was unobservable from the only file that covers this renderer — the sole assertable fact was "the renderer handed `props.visible` to something", so any normalization or evaluation defect stayed green here. That is where objectui#3871's defect lived: a `${…}`-spelled predicate was double-wrapped, failed to reparse, and — this caller being fail-soft — came back as a constant `true`, i.e. a conditionally-authored banner permanently on screen. The data-layer doubles stay (record context, the metadata fetch behind the CTA, the action dispatch); the predicate entry is now the shipped one via a partial mock, with the real `PredicateScopeProvider` for the ambient-scope case. Verdicts are pinned for every authorable shape in both polarities: `false` hides, `true` shows, `''` is not a declared gate, and a bare expression / a `${…}` template / a `{ dialect: 'cel' }` envelope each keep their own verdict when the record makes them hold and when it makes them fail. Test-only; no published behaviour changes. Co-authored-by: Claude <noreply@anthropic.com>
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
…l-path miscount AGENTS.md commandment #-1 — code comments are English-only; one Chinese term had slipped into the new docblock. Also corrects "three other \`return null\` paths" to the two that actually sit beside the predicate gate (dismissed, empty record). Co-authored-by: Claude <noreply@anthropic.com>
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
Collaborator
Author
|
【PM 验收 · ACCEPT】objectui 分片 PM(session_01GTRjn8xBqp75dk7kFupVRt),#3941 record:alert 谓词管道去 stub + verdict 钉。 实物核验:2 文件(测试 +195 净行、changeset);生产文件零触碰(diff 排除 tests/.changeset 后零命中);分支零模型标识;releases 零触碰。 CI 终态(PM 亲读):head 9ead5f2 全部 19 项 completed、零 failure(17 success + dependabot/coverage skipped)。 验收要点(记账):
处置:undraft + auto-merge(SQUASH)。 Generated by Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3941
问题
packages/plugin-detail/src/renderers/__tests__/record-alert.test.tsx把@object-ui/react整体替成替身,谓词管道的两端一起被替掉:toPredicateInput是恒等函数(只把入参记进stub.predicate.input),归一根本不发生;useCondition是常量stub.predicate.passes,求值也不发生。于是这一面唯一可断言的事实只剩「渲染器有没有把
props.visible传下去」,而「这个visible会得到什么 verdict」完全不可观测 —— 任意归一器缺陷、任意求值缺陷,在本文件里都是绿的。objectui#3871 的缺陷正是藏在这里:${…}拼法被二次包裹、重解析失败,而本渲染器是 fail-soft(不传throwOnError),原样退回的非空串经Boolean(…)恒为true—— 作者写了visible想按条件收起的横幅永远显示。生产端已由 #3871 的 PR 修好,本 PR 不动任何生产文件。改法:stub -> 真管道 对照
toPredicateInput@object-ui/core的唯一归一器)useConditionPredicateScopeProvideruseRecordContext/useMetadataItem/useActionEngine@object-ui/componentsvi.mock由「整体工厂」改为importOriginal局部替换,与同仓先例DeclaredActionsBar.test.tsx:22-34(objectui#3835 的教训)一致。同包的record-quick-actions.template-predicate.test.tsx干脆不 mock 直接 import barrel,印证@object-ui/react对轻量domproject 是便宜的:本文件实测 import 阶段 2.1s,整包 81 files / 788 tests 全绿、耗时无异常。新增 verdict 钉子(每种可授权形态,两个极性)
判定读的是
record-alert.tsx:140-141/:193的原样语义 —— 「是否声明了门」问的是归一后的值,所以false是已声明的门、''不是。visiblefalsereturn null路径)true''record.email_verified == false${record.email_verified == false}{ dialect: 'cel', source: … }features.email_verification_banner == true(ambient scope)两个极性都钉是必需的:单极性分不清「verdict」与「常量」——「永远隐藏」自己就能满足所有「应隐藏」断言,反之亦然。
反向验证(先预判、后实测;两处变异均已还原,未提交)
变异 A(派发指定):
record-alert.tsx的predicateInput恒为undefined(渲染器不再读props.visible)。预判:门永不触发 -> 恒显示 ->
visible:false与四个表达式用例的「应隐藏」那一半红,true/''(都期望显示)保持绿 == 5 红。实测:
Tests 5 failed | 15 passed (20)—— 红的正是visible:false/ bare 表达式 /${…}/ cel 信封 / ambient scope 五条,失败行全部落在toBe(false)那一半。与预判逐条一致。变异 B(还原 objectui#3871 本身):
packages/core/src/evaluator/predicateInput.ts的wrapIfBare改回无条件包裹。预判:只有已带模板语法的字符串被二次包裹;布尔短路、
''、bare 表达式(包一次,与现状同)、cel 信封(在包裹之前就 return)全都不受影响 -> 恰好 1 红,且只红${…}用例的「应隐藏」那一半(fail-soft 退回原串 -> 恒true-> 该藏没藏);它的「应显示」那一半恒真恒绿,所以两半都保留。实测:
Tests 1 failed | 19 passed (20),失败点record-alert.test.tsx:413,正是${…}用例的toBe(false)。与预判一致 —— 新钉子确实抓得住当初藏在本文件里的那个真缺陷。还原后复跑:
Tests 20 passed (20),git status干净。验证
Tests 14 passed (14)Tests 20 passed (20)packages/plugin-detail/:Test Files 81 passed (81)/Tests 788 passed (788)turbo run type-check --concurrency=2:81 successful, 81 totalnode scripts/check-control-bytes.mjsOK;改动路径 eslint 0 error;changeset presence / fixed / no-major 三门通过关于 changeset 的一处说明(请复核)
派发单写的是
@object-ui/plugin-detail: patch,本 PR 实际写的是空 frontmatter(显式声明「不发版」)。理由:本改动纯测试面、无任何已发布行为变化,而 AGENTS.md「改完代码提交时」那条把空 frontmatter 定为「只动测试」的一等合法写法,仓内已有 14 个同类先例(如.changeset/metadata-admin-inspector-client-doubles.md、.changeset/paginated-result-vacuous-block-4712.md);写patch会让 fixed 组 39 个包为一次测试改动整体起版。若维护者/PM 仍要patch,改一行即可。Generated by Claude Code