@@ -28,8 +28,12 @@ import React from 'react';
2828import { render , screen , fireEvent , cleanup , within } from '@testing-library/react' ;
2929import '@testing-library/jest-dom' ;
3030import { SchemaRendererProvider } from '@object-ui/react' ;
31+ import { ComponentRegistry } from '@object-ui/core' ;
3132import { NotificationTopicField , NotificationChannelField } from '../RegistryRefField' ;
3233import { PREFERENCE_OPTIONS_URL } from '../preferenceOptions' ;
34+ // Module scope: the package entry registers every `field:<widget>` key the
35+ // record form resolves a field's `widget:` hint through.
36+ import { registerAllFields } from '../../index' ;
3337
3438const ANSWER = {
3539 success : true ,
@@ -84,6 +88,28 @@ function optionTexts(): string[] {
8488
8589afterEach ( ( ) => cleanup ( ) ) ;
8690
91+ describe ( 'the record form reaches the arm through `field:<widget>` (#30208 row 6)' , ( ) => {
92+ it . each ( [
93+ [ 'notification-topic' , 'preference-option-topics' , 'All topics (*)' ] ,
94+ [ 'notification-channel' , 'preference-option-channels' , 'All channels (*)' ] ,
95+ ] ) ( '`%s` is registered and lists the door' , async ( widget , testId , wildcard ) => {
96+ registerAllFields ( ) ;
97+ const Widget = ComponentRegistry . get ( `field:${ widget } ` ) ;
98+ expect ( Widget ) . toBeDefined ( ) ;
99+
100+ const apiFetch = door ( ok ( ANSWER ) ) ;
101+ render (
102+ < SchemaRendererProvider dataSource = { null } apiFetch = { apiFetch } >
103+ < React . Suspense fallback = { null } >
104+ { React . createElement ( Widget ! , { value : '' , onChange : vi . fn ( ) , field : { name : 'x' , type : 'text' } } ) }
105+ </ React . Suspense >
106+ </ SchemaRendererProvider > ,
107+ ) ;
108+ fireEvent . click ( await screen . findByTestId ( testId ) ) ;
109+ expect ( optionTexts ( ) [ 0 ] ) . toBe ( wildcard ) ;
110+ } ) ;
111+ } ) ;
112+
87113describe ( 'notification-topic — the list renders from the door (#30208 row 6)' , ( ) => {
88114 it ( 'reads the preference options door through the host fetch and lists its topics, `*` first' , async ( ) => {
89115 const apiFetch = door ( ok ( ANSWER ) ) ;
0 commit comments