@@ -210,10 +210,11 @@ describe('view-declared bulk actions (objectui#3002)', () => {
210210 await waitFor ( ( ) => expect ( screen . getAllByTestId ( 'bulk-action-push_down' ) ) . toHaveLength ( 1 ) ) ;
211211 } ) ;
212212
213- it ( 'keeps an unresolvable name alongside the promoted defs' , async ( ) => {
214- // A name the object never declared may still have a runner handler
215- // registered under it; hiding it because some OTHER def exists dropped
216- // half the bar's buttons.
213+ it ( 'draws no button for a name the object does not declare, even with a runner handler under it (objectstack#30169)' , async ( ) => {
214+ // Trigger objectstack#30169. The spec says a bare `bulkActions` name "names
215+ // an action the object declares", and lint `action-name-undefined` refuses
216+ // any other. A runner handler registered under the name is client code,
217+ // not a declaration, so it does not bring the button back.
217218 const handler = vi . fn ( async ( ) => ( { success : true } ) ) ;
218219 await renderAndSelectAll ( {
219220 objectActions : [ PUSH_DOWN ] ,
@@ -222,9 +223,63 @@ describe('view-declared bulk actions (objectui#3002)', () => {
222223 } ) ;
223224
224225 expect ( await screen . findByTestId ( 'bulk-action-push_down' ) ) . toBeInTheDocument ( ) ;
225- const legacy = await screen . findByTestId ( 'bulk-action-crm_only_handler' ) ;
226- fireEvent . click ( legacy ) ;
227- await waitFor ( ( ) => expect ( handler ) . toHaveBeenCalledTimes ( 1 ) ) ;
226+ expect ( screen . queryByTestId ( 'bulk-action-crm_only_handler' ) ) . not . toBeInTheDocument ( ) ;
227+ expect ( handler ) . not . toHaveBeenCalled ( ) ;
228+ } ) ;
229+ } ) ;
230+
231+ /**
232+ * objectstack#30169 — the selection bar and a disabled package. With the
233+ * package disabled the server withholds its actions: they leave the served
234+ * object's `actions`, exactly as if never declared. The view still names one
235+ * in `bulkActions` as a bare string (the spec accepts it). Before the fix the
236+ * bar drew it anyway, under its humanized name ("Create Campaign"), and the
237+ * click toasted "not executable". Now the bar draws only what the object
238+ * declares: withheld, no button and one development warning naming it;
239+ * served, the button under the action's own label.
240+ */
241+ describe ( 'a bulk action a disabled package withholds (objectstack#30169)' , ( ) => {
242+ /** The package's action. Its label is NOT the humanized name, on purpose. */
243+ const CREATE_CAMPAIGN = {
244+ name : 'create_campaign' ,
245+ label : 'Add to Campaign' ,
246+ type : 'api' ,
247+ target : '/api/v1/campaigns/add' ,
248+ } ;
249+ const VIEW = { bulkActions : [ 'push_down' , 'create_campaign' ] } ;
250+
251+ const bulkActionWarnings = ( warn : { mock : { calls : unknown [ ] [ ] } } ) =>
252+ warn . mock . calls
253+ . map ( ( args ) => String ( args [ 0 ] ) )
254+ . filter ( ( line ) => line . includes ( 'ObjectGrid bulkActions' ) ) ;
255+
256+ it ( 'withheld: the served object lacks it, so the bar draws no button and warns once naming it' , async ( ) => {
257+ const warn = vi . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
258+ try {
259+ await renderAndSelectAll ( { objectActions : [ PUSH_DOWN ] , schema : VIEW } ) ;
260+
261+ // The declared sibling is drawn, so the bar is up and populated.
262+ expect ( await screen . findByTestId ( 'bulk-action-push_down' ) ) . toBeInTheDocument ( ) ;
263+ expect ( screen . queryByTestId ( 'bulk-action-create_campaign' ) ) . not . toBeInTheDocument ( ) ;
264+ expect ( screen . queryByText ( 'Create Campaign' ) ) . not . toBeInTheDocument ( ) ;
265+ await waitFor ( ( ) => expect ( bulkActionWarnings ( warn ) ) . toHaveLength ( 1 ) ) ;
266+ expect ( bulkActionWarnings ( warn ) [ 0 ] ) . toContain ( "'create_campaign'" ) ;
267+ expect ( bulkActionWarnings ( warn ) [ 0 ] ) . not . toContain ( "'push_down'" ) ;
268+ } finally {
269+ warn . mockRestore ( ) ;
270+ }
271+ } ) ;
272+
273+ it ( 'served: the same view draws it under the action label, and stays quiet' , async ( ) => {
274+ const warn = vi . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
275+ try {
276+ await renderAndSelectAll ( { objectActions : [ PUSH_DOWN , CREATE_CAMPAIGN ] , schema : VIEW } ) ;
277+
278+ expect ( await screen . findByTestId ( 'bulk-action-create_campaign' ) ) . toHaveTextContent ( 'Add to Campaign' ) ;
279+ expect ( bulkActionWarnings ( warn ) ) . toEqual ( [ ] ) ;
280+ } finally {
281+ warn . mockRestore ( ) ;
282+ }
228283 } ) ;
229284} ) ;
230285
0 commit comments