Repository navigation
Commit d4427ae
test(components): pin a declared danger action on action:bar to the app-todo shape (#27300)
<!-- claude-projects-attribution: {"github_login":"os-warren"} -->
_Requested by **Warren** · [project
thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ8UhZd4buJ9P8RHCa2Rnbx4C)_
Fixes #26781
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:只新增一个测试文件,用 app-todo 的 `delete_completed`(危险操作)原样形状驱动
`action:bar`,钉住按钮画成红色(destructive)、确认框按钮也是红色。
- 为什么改:代码修复已随 #26966 合入,但没有任何测试经过 `action:bar` 走这条路径,卡要求「在 app-todo
形状上钉住」。
- 风险与回滚:零运行时风险,只加测试;回滚即删这一个文件。
-
先看:`ui/packages/components/src/renderers/action/__tests__/action-bar-danger-variant-26781.test.tsx`(三个用例:危险按钮样式、对照按钮、确认框选项)。
- 两分钟验证:`pnpm --dir ui exec vitest run
packages/components/src/renderers/action/__tests__/action-bar-danger-variant-26781.test.tsx`,预期
3 passed。
- 需要你做的:无,席位落地。
## What changes
One new test file, `action-bar-danger-variant-26781.test.tsx`, under
`ui/packages/components/src/renderers/action/__tests__/`. No source
change.
It renders an `action:bar` shaped like the list page's toolbar
(`objectViewHeaderToolbar.ts`: `location: 'list_toolbar'`, `size: 'sm'`,
`variant: 'outline'`) carrying two actions copied key for key from
`examples/app-todo` (`DeleteCompletedAction` and `ExportToCsvAction`,
`ai` block included), and asserts:
1. the `delete_completed` member (`variant: 'danger'`) draws with the
Button primitive's destructive style (`bg-destructive`, not the bar's
outline);
2. CONTROL: `export_csv` in the same bar declares no variant and draws
the bar's `outline`;
3. clicking `delete_completed` asks its `confirmText` through the
confirm handler with `{ title, confirmText: label, destructive: true }`,
and the script handler is not run on a cancel.
## Why
The code path landed with #26966 (`toButtonVariant` maps `danger` to the
primitive's `destructive`; `toRunnerVariant` forwards `danger` to the
runner, whose confirm paints destructive). The existing `danger` pins
(`action-variant-confirm-26665.test.tsx`) drive `action:button` / icon /
group / menu directly; nothing drove a declared `danger` action through
`action:bar`, which is where a list toolbar action reaches the screen.
The card's Wanted asks for that pin on the app-todo shape.
## Tests
- New file: 3 passed (vitest, `dom` project), run from the `ui/` root.
- Ablation A (one-shot, restored): `toButtonVariant` `case 'danger'`
returns `default` ⇒ test 1 red (`expected '…' to contain
'bg-destructive'`), 2 passed; restore verified (blob equal to HEAD, `git
diff HEAD` empty).
- Ablation B (one-shot, restored): `toRunnerVariant` drops its `danger`
case ⇒ test 3 red (options lose `destructive`), 2 passed; restore
verified the same way.
- `pnpm --filter @object-ui/components run type-check` exit 0 (its
`tsconfig.test.json` includes `src/**/*.test.tsx`).
## Acceptance notes
- The confirm is read from the confirm handler's call, the input the
host's `ActionConfirmDialog` (`@object-ui/app-shell`) draws from.
`@object-ui/components` cannot import app-shell, so the dialog's own
button class is not rendered here; this is the same layer the 26665 pins
read.
## Verification
<details><summary>Derived gates — 24 derived, 24 run, all exit 0, on
head 0d2d769</summary>
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 24 commands; each was run with its
exit captured before any pipe; `--ran` reconciliation: "24 derived
famil(ies) accounted for — 24 run, 0 NOT-MEASURED". `--tier`: no
path-derived mandate; changed lines 143, under the 3000 threshold.
Extra: eslint on the file exit 0; `pnpm --dir ui run
check:new-line-citations` reports 0 new citations.
</details>
Tests only, nothing a released package ships: `skip-changeset`.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01JQwxbXi3XdpqE7y1mW7EZt)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent a0aa8a1 commit d4427ae
1 file changed
Lines changed: 143 additions & 0 deletions
File tree
- ui/packages/components/src/renderers/action/__tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
0 commit comments