Skip to content

Commit 740e353

Browse files
committed
test(fields): pin the field:<widget> registration of the notification faces
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibzyvUbUU6pC3x3Amrx
1 parent 8bd6d95 commit 740e353

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

‎ui/packages/fields/src/widgets/__tests__/RegistryRefField.preferenceOptions-31062.test.tsx‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@ import React from 'react';
2828
import { render, screen, fireEvent, cleanup, within } from '@testing-library/react';
2929
import '@testing-library/jest-dom';
3030
import { SchemaRendererProvider } from '@object-ui/react';
31+
import { ComponentRegistry } from '@object-ui/core';
3132
import { NotificationTopicField, NotificationChannelField } from '../RegistryRefField';
3233
import { 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

3438
const ANSWER = {
3539
success: true,
@@ -84,6 +88,28 @@ function optionTexts(): string[] {
8488

8589
afterEach(() => 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+
87113
describe('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

Comments
 (0)