@@ -115,3 +115,49 @@ describe('RelatedList list_toolbar button — a faulting `visible` hides (object
115115 }
116116 } ) ;
117117} ) ;
118+
119+ /**
120+ * objectui#11244 — whether a `visible` gate is DECLARED is asked with
121+ * `hasDeclaredVisibilityGate`, as the rest of the action family asks it
122+ * (objectui#3812), never by truthiness. A literal `visible: false` — the most
123+ * explicit way an author can say "never show this" — is falsy, so a truthiness
124+ * test read it as "no gate" and the button rendered for everyone. A blank
125+ * predicate is still no gate (the action shows), and a CEL string is evaluated.
126+ * The fail-closed leg on a FAULT is the objectui#11212 block above, unchanged.
127+ */
128+ describe ( 'RelatedList list_toolbar button — a declared `visible` is asked by declaredness, not truthiness (objectui#11244)' , ( ) => {
129+ it ( 'hides a toolbar action authored `visible: false` (DETECTOR)' , ( ) => {
130+ renderButton ( { name : 'archive_11244' , label : 'Archive' , visible : false } ) ;
131+ renderButton ( { name : 'export' , label : 'Export' } ) ;
132+ expect ( screen . getByTestId ( 'related-toolbar-action-export' ) ) . toBeInTheDocument ( ) ;
133+ expect ( screen . queryByTestId ( 'related-toolbar-action-archive_11244' ) ) . toBeNull ( ) ;
134+ } ) ;
135+
136+ it ( 'shows a toolbar action authored `visible: true`' , ( ) => {
137+ renderButton ( { name : 'archive_11244' , label : 'Archive' , visible : true } ) ;
138+ expect ( screen . getByTestId ( 'related-toolbar-action-archive_11244' ) ) . toBeInTheDocument ( ) ;
139+ } ) ;
140+
141+ it . each ( [
142+ [ 'an empty string' , '' ] ,
143+ [ 'a whitespace-only string' , ' ' ] ,
144+ ] ) ( 'reads a blank `visible` (%s) as no gate, so the action shows' , ( _label , blank ) => {
145+ const warn = vi . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
146+ try {
147+ renderButton ( { name : 'archive_11244' , label : 'Archive' , visible : blank } ) ;
148+ expect ( screen . getByTestId ( 'related-toolbar-action-archive_11244' ) ) . toBeInTheDocument ( ) ;
149+ } finally {
150+ warn . mockRestore ( ) ;
151+ }
152+ } ) ;
153+
154+ it ( 'evaluates a CEL string `visible` that answers true: the action shows' , ( ) => {
155+ renderButton ( { name : 'archive_11244' , label : 'Archive' , visible : '1 == 1' } ) ;
156+ expect ( screen . getByTestId ( 'related-toolbar-action-archive_11244' ) ) . toBeInTheDocument ( ) ;
157+ } ) ;
158+
159+ it ( 'evaluates a CEL string `visible` that answers false: the action hides' , ( ) => {
160+ renderButton ( { name : 'archive_11244' , label : 'Archive' , visible : '1 == 2' } ) ;
161+ expect ( screen . queryByTestId ( 'related-toolbar-action-archive_11244' ) ) . toBeNull ( ) ;
162+ } ) ;
163+ } ) ;
0 commit comments