|
27 | 27 | * its own `locations`, with the bridge's rule: `list_toolbar` → header |
28 | 28 | * button, `list_item` → row menu. Running it stays the host's (the |
29 | 29 | * bridge's `onToolbarAction` / `onRowAction`). |
30 | | - * - `actions: []` → the author's choice of NO actions. The built-in |
31 | | - * New / Edit / Delete / View affordances are not action ids (the runtime |
32 | | - * ships no built-in action names) and are untouched by this key. |
| 30 | + * - `actions: []` → the author's choice of NO actions, the built-in New |
| 31 | + * included (#26182): the list offers no generic create form, whatever the |
| 32 | + * child object's `userActions.create` says. A NON-empty list leaves New |
| 33 | + * the host's, and Edit / Delete / View are row affordances this key never |
| 34 | + * touches (the runtime ships no built-in action names). |
33 | 35 | * - An id the registry cannot resolve, or one whose action declares no |
34 | 36 | * location this list renders, is REFUSED where the lookup answers: an |
35 | 37 | * inline `role="status"` notice on the list names it and says why. Never a |
@@ -251,18 +253,55 @@ describe('record:related_list.actions — AUTHORED: the authored list is what re |
251 | 253 | expect(onToolbarAction.mock.calls[0][0]).toMatchObject({ name: 'invite', label: 'Invite', type: 'api' }); |
252 | 254 | }); |
253 | 255 |
|
254 | | - it('`actions: []` is the author’s choice of NO actions — while New stays, because it is not an action id', async () => { |
| 256 | + it('`actions: []` is the author’s choice of NO actions — New included, though the host offers it (#26182)', async () => { |
255 | 257 | mount([]); |
256 | 258 | await waitForRow(); |
257 | | - // Positive first, so the empty reads below are taken on a list that |
258 | | - // really drew its header: the host's create affordance is still there. |
259 | | - expect(await screen.findByTestId('related-list-new')).toBeInTheDocument(); |
| 259 | + expect(screen.queryByTestId('related-list-new')).toBeNull(); |
260 | 260 | expect(toolbarNames()).toEqual([]); |
261 | 261 | expect(rowTriggers()).toHaveLength(0); |
262 | 262 | expect(refusal()).toBeNull(); |
263 | 263 | }); |
264 | 264 | }); |
265 | 265 |
|
| 266 | +describe('record:related_list.actions — the built-in New: only `[]` withholds it (#26182)', () => { |
| 267 | + // Each case reads the SAME host, which offers create for `contact`: what |
| 268 | + // differs is only the authored key, so the verdict is this list's own. |
| 269 | + it('CONTROL: with no `actions` the host’s New is drawn and runs the host’s create', async () => { |
| 270 | + mount(undefined); |
| 271 | + await waitForRow(); |
| 272 | + const button = await screen.findByTestId('related-list-new'); |
| 273 | + fireEvent.click(button); |
| 274 | + expect(onCreate).toHaveBeenCalledTimes(1); |
| 275 | + }); |
| 276 | + |
| 277 | + it('a NON-empty authored list leaves New the host’s: naming actions is not withholding create', async () => { |
| 278 | + mount(['invite']); |
| 279 | + await waitForRow(); |
| 280 | + await waitFor(() => expect(toolbarNames()).toEqual(['invite'])); |
| 281 | + expect(screen.getByTestId('related-list-new')).toBeInTheDocument(); |
| 282 | + }); |
| 283 | + |
| 284 | + it('`actions: []` withholds New on THIS list only — a sibling list of the same object keeps it', async () => { |
| 285 | + render( |
| 286 | + <MetadataCtx.Provider value={METADATA}> |
| 287 | + <RecordContextProvider objectName="account" recordId="ACC-1" dataSource={makeDataSource() as never}> |
| 288 | + <RelatedRecordActionsProvider value={HOST}> |
| 289 | + <div data-testid="list-empty"> |
| 290 | + <SchemaRenderer schema={doc([]) as never} /> |
| 291 | + </div> |
| 292 | + <div data-testid="list-default"> |
| 293 | + <SchemaRenderer schema={doc(undefined) as never} /> |
| 294 | + </div> |
| 295 | + </RelatedRecordActionsProvider> |
| 296 | + </RecordContextProvider> |
| 297 | + </MetadataCtx.Provider>, |
| 298 | + ); |
| 299 | + await waitFor(() => expect(screen.getAllByText('Alice')).toHaveLength(2)); |
| 300 | + expect(await within(screen.getByTestId('list-default')).findByTestId('related-list-new')).toBeInTheDocument(); |
| 301 | + expect(within(screen.getByTestId('list-empty')).queryByTestId('related-list-new')).toBeNull(); |
| 302 | + }); |
| 303 | +}); |
| 304 | + |
266 | 305 | describe('record:related_list.actions — an id that cannot be placed is REFUSED where it resolves (objectui#11163)', () => { |
267 | 306 | it('an id the registry cannot resolve is named in a `role="status"` notice; the resolvable ones still render', async () => { |
268 | 307 | mount(['invite', 'no_such_action']); |
|
0 commit comments