@dxos/react-ui-form 0.8.4-main.84f28bd → 0.8.4-main.ae835ea

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/dist/lib/browser/index.mjs +826 -621
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node-esm/index.mjs +826 -621
  5. package/dist/lib/node-esm/index.mjs.map +4 -4
  6. package/dist/lib/node-esm/meta.json +1 -1
  7. package/dist/types/src/components/ControlSection/ControlSection.d.ts +2 -2
  8. package/dist/types/src/components/ControlSection/ControlSection.d.ts.map +1 -1
  9. package/dist/types/src/components/ControlSection/ControlSection.stories.d.ts +81 -5
  10. package/dist/types/src/components/ControlSection/ControlSection.stories.d.ts.map +1 -1
  11. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts +4 -5
  12. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
  13. package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts +78 -7
  14. package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts.map +1 -1
  15. package/dist/types/src/components/Form/ArrayField.d.ts +2 -2
  16. package/dist/types/src/components/Form/ArrayField.d.ts.map +1 -1
  17. package/dist/types/src/components/Form/Defaults.d.ts +5 -5
  18. package/dist/types/src/components/Form/Defaults.d.ts.map +1 -1
  19. package/dist/types/src/components/Form/Form.d.ts +7 -6
  20. package/dist/types/src/components/Form/Form.d.ts.map +1 -1
  21. package/dist/types/src/components/Form/Form.stories.d.ts +129 -32
  22. package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
  23. package/dist/types/src/components/Form/FormActions.d.ts.map +1 -1
  24. package/dist/types/src/components/Form/FormContent.d.ts +17 -11
  25. package/dist/types/src/components/Form/FormContent.d.ts.map +1 -1
  26. package/dist/types/src/components/Form/FormContext.d.ts +3 -3
  27. package/dist/types/src/components/Form/FormContext.d.ts.map +1 -1
  28. package/dist/types/src/components/Form/Input.d.ts +5 -2
  29. package/dist/types/src/components/Form/Input.d.ts.map +1 -1
  30. package/dist/types/src/components/Form/RefField.d.ts +15 -5
  31. package/dist/types/src/components/Form/RefField.d.ts.map +1 -1
  32. package/dist/types/src/components/Form/custom/GeoPointInput.d.ts +1 -1
  33. package/dist/types/src/components/Form/custom/GeoPointInput.d.ts.map +1 -1
  34. package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts +1 -1
  35. package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts.map +1 -1
  36. package/dist/types/src/components/Form/custom/SelectOptionsInput.stories.d.ts +76 -4
  37. package/dist/types/src/components/Form/custom/SelectOptionsInput.stories.d.ts.map +1 -1
  38. package/dist/types/src/components/Form/custom/TupleInput.d.ts +1 -1
  39. package/dist/types/src/components/Form/factory.d.ts +1 -1
  40. package/dist/types/src/components/Form/factory.d.ts.map +1 -1
  41. package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts +41 -0
  42. package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts.map +1 -0
  43. package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts +82 -0
  44. package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts.map +1 -0
  45. package/dist/types/src/components/ObjectPicker/index.d.ts +2 -0
  46. package/dist/types/src/components/ObjectPicker/index.d.ts.map +1 -0
  47. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +20 -6
  48. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
  49. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +81 -9
  50. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
  51. package/dist/types/src/components/index.d.ts +1 -1
  52. package/dist/types/src/components/index.d.ts.map +1 -1
  53. package/dist/types/src/components/testing.d.ts +6 -3
  54. package/dist/types/src/components/testing.d.ts.map +1 -1
  55. package/dist/types/src/hooks/useForm.d.ts +3 -3
  56. package/dist/types/src/hooks/useForm.d.ts.map +1 -1
  57. package/dist/types/src/hooks/useQueryRefOptions.d.ts +9 -3
  58. package/dist/types/src/hooks/useQueryRefOptions.d.ts.map +1 -1
  59. package/dist/types/src/hooks/useRefQueryLookupHandler.d.ts.map +1 -1
  60. package/dist/types/src/translations.d.ts +11 -5
  61. package/dist/types/src/translations.d.ts.map +1 -1
  62. package/dist/types/src/util/field.d.ts +1 -1
  63. package/dist/types/src/util/field.d.ts.map +1 -1
  64. package/dist/types/src/util/formatting.d.ts +1 -1
  65. package/dist/types/src/util/formatting.d.ts.map +1 -1
  66. package/dist/types/src/util/refs.d.ts +1 -1
  67. package/dist/types/src/util/refs.d.ts.map +1 -1
  68. package/dist/types/src/util/schema.d.ts +1 -1
  69. package/dist/types/src/util/schema.d.ts.map +1 -1
  70. package/dist/types/tsconfig.tsbuildinfo +1 -1
  71. package/package.json +41 -36
  72. package/src/components/ControlSection/ControlSection.stories.tsx +11 -14
  73. package/src/components/ControlSection/ControlSection.tsx +26 -12
  74. package/src/components/FieldEditor/FieldEditor.stories.tsx +26 -24
  75. package/src/components/FieldEditor/FieldEditor.test.tsx +14 -13
  76. package/src/components/FieldEditor/FieldEditor.tsx +21 -23
  77. package/src/components/Form/ArrayField.tsx +13 -12
  78. package/src/components/Form/Defaults.tsx +22 -20
  79. package/src/components/Form/Form.stories.tsx +135 -99
  80. package/src/components/Form/Form.tsx +27 -15
  81. package/src/components/Form/FormActions.tsx +2 -1
  82. package/src/components/Form/FormContent.tsx +121 -39
  83. package/src/components/Form/FormContext.tsx +8 -8
  84. package/src/components/Form/Input.tsx +5 -2
  85. package/src/components/Form/RefField.tsx +111 -41
  86. package/src/components/Form/custom/GeoPointInput.tsx +29 -21
  87. package/src/components/Form/custom/SelectOptionsInput.stories.tsx +11 -11
  88. package/src/components/Form/custom/SelectOptionsInput.tsx +30 -31
  89. package/src/components/Form/custom/TupleInput.tsx +2 -2
  90. package/src/components/Form/factory.tsx +2 -2
  91. package/src/components/ObjectPicker/ObjectPicker.stories.tsx +207 -0
  92. package/src/components/ObjectPicker/ObjectPicker.tsx +161 -0
  93. package/src/components/ObjectPicker/index.ts +5 -0
  94. package/src/components/ViewEditor/ViewEditor.stories.tsx +129 -49
  95. package/src/components/ViewEditor/ViewEditor.test.tsx +19 -19
  96. package/src/components/ViewEditor/ViewEditor.tsx +278 -233
  97. package/src/components/index.ts +1 -2
  98. package/src/components/testing.tsx +15 -9
  99. package/src/hooks/useForm.ts +11 -6
  100. package/src/hooks/useQueryRefOptions.ts +15 -6
  101. package/src/hooks/useRefQueryLookupHandler.ts +3 -3
  102. package/src/translations.ts +13 -6
  103. package/src/util/field.ts +9 -19
  104. package/src/util/formatting.ts +1 -1
  105. package/src/util/refs.ts +2 -2
  106. package/src/util/schema.ts +2 -4
  107. package/dist/types/src/components/deprecated/Form.d.ts +0 -15
  108. package/dist/types/src/components/deprecated/Form.d.ts.map +0 -1
  109. package/dist/types/src/components/deprecated/Form.stories.d.ts +0 -13
  110. package/dist/types/src/components/deprecated/Form.stories.d.ts.map +0 -1
  111. package/dist/types/src/components/deprecated/FormInput.d.ts +0 -16
  112. package/dist/types/src/components/deprecated/FormInput.d.ts.map +0 -1
  113. package/dist/types/src/components/deprecated/index.d.ts +0 -2
  114. package/dist/types/src/components/deprecated/index.d.ts.map +0 -1
  115. package/src/components/deprecated/Form.stories.tsx +0 -62
  116. package/src/components/deprecated/Form.tsx +0 -119
  117. package/src/components/deprecated/FormInput.tsx +0 -71
  118. package/src/components/deprecated/index.ts +0 -5
@@ -2,87 +2,141 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import '@dxos-theme';
6
-
7
5
  import { type Meta, type StoryObj } from '@storybook/react-vite';
8
- import { Schema } from 'effect';
9
- import React, { useCallback, useMemo, useState, useEffect } from 'react';
6
+ import * as Schema from 'effect/Schema';
7
+ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
10
8
 
11
- import { Format, type EchoSchema, toJsonSchema, TypedObject } from '@dxos/echo-schema';
12
- import { Filter, useQuery, useSpace } from '@dxos/react-client/echo';
13
- import { withClientProvider } from '@dxos/react-client/testing';
9
+ import { DXN, Filter, Obj, Query, type QueryAST, Tag, Type } from '@dxos/echo';
10
+ import { type EchoSchema, Format } from '@dxos/echo/internal';
11
+ import { useQuery } from '@dxos/react-client/echo';
12
+ import { useClientProvider, withClientProvider } from '@dxos/react-client/testing';
14
13
  import { useAsyncEffect } from '@dxos/react-ui';
15
- import { ViewProjection, ViewType, createView } from '@dxos/schema';
16
- import { withTheme, withLayout } from '@dxos/storybook-utils';
14
+ import { withTheme } from '@dxos/react-ui/testing';
15
+ import { DataType, type ProjectionModel, createView, getTypenameFromQuery } from '@dxos/schema';
17
16
 
18
- import { ViewEditor, type ViewEditorProps } from './ViewEditor';
19
17
  import { translations } from '../../translations';
20
18
  import { TestLayout, TestPanel, VIEW_EDITOR_DEBUG_SYMBOL } from '../testing';
21
19
 
20
+ import { ViewEditor, type ViewEditorProps } from './ViewEditor';
21
+
22
+ const types = [
23
+ // TODO(burdon): Get label from annotation.
24
+ { value: Type.getTypename(DataType.Organization), label: 'Organization' },
25
+ { value: Type.getTypename(DataType.Person), label: 'Person' },
26
+ { value: Type.getTypename(DataType.Project), label: 'Project' },
27
+ { value: Type.getTypename(DataType.Employer), label: 'Employer' },
28
+ ];
29
+
22
30
  // Type definition for debug objects exposed to tests.
23
31
  export type ViewEditorDebugObjects = {
24
32
  schema: EchoSchema;
25
- view: ViewType;
26
- projection: ViewProjection;
33
+ view: DataType.View;
34
+ projection: ProjectionModel;
27
35
  };
28
36
 
29
- type StoryProps = Pick<ViewEditorProps, 'readonly'>;
37
+ type StoryProps = Pick<ViewEditorProps, 'readonly' | 'mode'>;
30
38
 
31
39
  const DefaultStory = (props: StoryProps) => {
32
- const space = useSpace();
40
+ const { space } = useClientProvider();
33
41
  const [schema, setSchema] = useState<EchoSchema>();
34
- const [view, setView] = useState<ViewType>();
35
- const [projection, setProjection] = useState<ViewProjection>();
42
+ const [view, setView] = useState<DataType.View>();
43
+ const projectionRef = useRef<ProjectionModel>(null);
44
+
45
+ const tags = useQuery(space, Filter.type(Tag.Tag));
46
+
36
47
  useAsyncEffect(async () => {
37
48
  if (space) {
38
- class TestSchema extends TypedObject({ typename: 'example.com/type/Test', version: '0.1.0' })({
49
+ const TestSchema = Schema.Struct({
39
50
  name: Schema.String,
40
51
  email: Format.Email,
41
52
  salary: Format.Currency(),
42
- }) {}
43
-
44
- const [schema] = await space.db.schemaRegistry.register([TestSchema]);
45
- const view = createView({ name: 'Test', typename: schema.typename, jsonSchema: toJsonSchema(TestSchema) });
46
- const projection = new ViewProjection(schema.jsonSchema, view);
47
-
48
- setSchema(schema);
53
+ }).pipe(
54
+ Type.Obj({
55
+ typename: 'example.com/type/Test',
56
+ version: '0.1.0',
57
+ }),
58
+ );
59
+
60
+ const AlternateSchema = Schema.Struct({
61
+ title: Schema.String,
62
+ description: Schema.String,
63
+ completed: Schema.Boolean,
64
+ }).pipe(
65
+ Type.Obj({
66
+ typename: 'example.com/type/Alternate',
67
+ version: '0.1.0',
68
+ }),
69
+ );
70
+
71
+ const [testSchema] = await space.db.schemaRegistry.register([TestSchema, AlternateSchema]);
72
+ const view = createView({
73
+ name: 'Test',
74
+ query: Query.select(Filter.typename(TestSchema.typename)),
75
+ jsonSchema: Type.toJsonSchema(TestSchema),
76
+ presentation: Obj.make(Type.Expando, {}),
77
+ });
78
+
79
+ setSchema(testSchema);
49
80
  setView(view);
50
- setProjection(projection);
51
81
  }
52
82
  }, [space]);
53
83
 
54
- const views = useQuery(space, Filter.type(ViewType));
55
- const currentTypename = useMemo(() => view?.query?.typename, [view]);
56
- const updateViewTypename = useCallback(
57
- (newTypename: string) => {
58
- if (!schema) {
84
+ const updateViewQuery = useCallback(
85
+ async (newQuery: QueryAST.Query, target?: string) => {
86
+ if (!schema || !view || !space) {
59
87
  return;
60
88
  }
61
- const matchingViews = views.filter((view) => view.query.typename === currentTypename);
62
- for (const view of matchingViews) {
63
- view.query.typename = newTypename;
89
+
90
+ if (props.mode === 'query') {
91
+ const queue = target && DXN.tryParse(target) ? target : undefined;
92
+ const query = queue ? Query.fromAst(newQuery).options({ queues: [queue] }) : Query.fromAst(newQuery);
93
+ view.query.ast = query.ast;
94
+
95
+ const typename = getTypenameFromQuery(query.ast);
96
+ const [newSchema] = await space.db.schemaRegistry.query({ typename }).run();
97
+ if (!newSchema) {
98
+ return;
99
+ }
100
+
101
+ const newView = createView({
102
+ query,
103
+ jsonSchema: newSchema.jsonSchema,
104
+ presentation: Obj.make(Type.Expando, {}),
105
+ });
106
+ view.projection = Obj.getSnapshot(newView).projection;
107
+ setSchema(() => newSchema);
108
+ } else {
109
+ console.log('updateViewQuery', { newQuery });
110
+ view.query.ast = newQuery;
111
+ schema.updateTypename(getTypenameFromQuery(newQuery));
64
112
  }
65
- schema.updateTypename(newTypename);
66
113
  },
67
- [views, schema],
114
+ [view, schema],
68
115
  );
69
116
 
70
- const handleDelete = useCallback((property: string) => projection?.deleteFieldProjection(property), [projection]);
117
+ const handleDelete = useCallback(
118
+ (property: string) => projectionRef.current?.deleteFieldProjection(property),
119
+ [projectionRef],
120
+ );
71
121
 
72
122
  // Expose objects on window for test access.
73
123
  useEffect(() => {
74
- if (typeof window !== 'undefined' && schema && view && projection) {
75
- (window as any)[VIEW_EDITOR_DEBUG_SYMBOL] = { schema, view, projection } satisfies ViewEditorDebugObjects;
124
+ if (typeof window !== 'undefined' && schema && view && projectionRef.current) {
125
+ (window as any)[VIEW_EDITOR_DEBUG_SYMBOL] = {
126
+ schema,
127
+ view,
128
+ projection: projectionRef.current,
129
+ } satisfies ViewEditorDebugObjects;
76
130
  }
77
- }, [schema, view, projection]);
131
+ }, [schema, view]);
78
132
 
79
133
  // NOTE(ZaymonFC): This looks awkward but it resolves an infinite parsing issue with sb.
80
134
  const json = useMemo(
81
- () => JSON.parse(JSON.stringify({ schema, view, projection })),
82
- [JSON.stringify(schema), JSON.stringify(view), JSON.stringify(projection)],
135
+ () => JSON.parse(JSON.stringify({ schema, view, projection: projectionRef.current })),
136
+ [JSON.stringify(schema), JSON.stringify(view)],
83
137
  );
84
138
 
85
- if (!schema || !view || !projection) {
139
+ if (!schema || !view) {
86
140
  return <div />;
87
141
  }
88
142
 
@@ -90,11 +144,15 @@ const DefaultStory = (props: StoryProps) => {
90
144
  <TestLayout json={json}>
91
145
  <TestPanel>
92
146
  <ViewEditor
147
+ ref={projectionRef}
93
148
  schema={schema}
94
149
  view={view}
95
150
  registry={space?.db.schemaRegistry}
151
+ mode={props.mode}
96
152
  readonly={props.readonly}
97
- onTypenameChanged={updateViewTypename}
153
+ types={types}
154
+ tags={tags}
155
+ onQueryChanged={updateViewQuery}
98
156
  onDelete={handleDelete}
99
157
  />
100
158
  </TestPanel>
@@ -102,19 +160,41 @@ const DefaultStory = (props: StoryProps) => {
102
160
  );
103
161
  };
104
162
 
105
- const meta: Meta<StoryProps> = {
163
+ const meta = {
106
164
  title: 'ui/react-ui-form/ViewEditor',
107
165
  render: DefaultStory,
108
- decorators: [withClientProvider({ createSpace: true }), withLayout({ fullscreen: true }), withTheme],
109
- parameters: { translations },
110
- };
166
+ decorators: [
167
+ withClientProvider({
168
+ createSpace: true,
169
+ types: [Tag.Tag],
170
+ onCreateSpace: ({ space }) => {
171
+ space.db.add(Tag.make({ label: 'Important' }));
172
+ space.db.add(Tag.make({ label: 'Investor' }));
173
+ space.db.add(Tag.make({ label: 'New' }));
174
+ },
175
+ }),
176
+ withTheme,
177
+ ],
178
+ parameters: {
179
+ layout: 'fullscreen',
180
+ translations,
181
+ },
182
+ } satisfies Meta<typeof DefaultStory>;
111
183
 
112
184
  export default meta;
113
185
 
114
- type Story = StoryObj<StoryProps>;
186
+ type Story = StoryObj<typeof meta>;
115
187
 
116
188
  export const Default: Story = {};
117
189
 
118
190
  export const Readonly: Story = {
119
- args: { readonly: true },
191
+ args: {
192
+ readonly: true,
193
+ },
194
+ };
195
+
196
+ export const QueryMode: Story = {
197
+ args: {
198
+ mode: 'query',
199
+ },
120
200
  };
@@ -3,15 +3,16 @@
3
3
  //
4
4
 
5
5
  import { composeStories } from '@storybook/react';
6
- import { screen, cleanup, fireEvent, waitFor } from '@testing-library/react';
6
+ import { cleanup, fireEvent, screen, waitFor } from '@testing-library/react';
7
7
  import { afterEach, describe, expect, test } from 'vitest';
8
8
 
9
- import { EchoSchema } from '@dxos/echo-schema';
10
- import { ViewProjection, ViewType } from '@dxos/schema';
9
+ import { EchoSchema, isInstanceOf } from '@dxos/echo/internal';
10
+ import { DataType, ProjectionModel } from '@dxos/schema';
11
+
12
+ import { VIEW_EDITOR_DEBUG_SYMBOL } from '../testing';
11
13
 
12
14
  import * as stories from './ViewEditor.stories';
13
15
  import { type ViewEditorDebugObjects } from './ViewEditor.stories';
14
- import { VIEW_EDITOR_DEBUG_SYMBOL } from '../testing';
15
16
 
16
17
  const { Default } = composeStories(stories);
17
18
 
@@ -19,8 +20,8 @@ const getViewEditorDebugObjects = (): ViewEditorDebugObjects => {
19
20
  const debugObjects = (window as any)[VIEW_EDITOR_DEBUG_SYMBOL] as ViewEditorDebugObjects;
20
21
  expect(debugObjects).toBeDefined();
21
22
  expect(debugObjects.schema).toBeInstanceOf(EchoSchema);
22
- expect(debugObjects.view).toBeInstanceOf(ViewType);
23
- expect(debugObjects.projection).toBeInstanceOf(ViewProjection);
23
+ expect(isInstanceOf(DataType.View, debugObjects.view)).toBeTruthy();
24
+ expect(debugObjects.projection).toBeInstanceOf(ProjectionModel);
24
25
  return debugObjects;
25
26
  };
26
27
 
@@ -41,7 +42,7 @@ describe('ViewEditor', () => {
41
42
  test('renders view editor', async () => {
42
43
  await Default.run();
43
44
  await waitForViewEditor();
44
- expect(screen.getByText('View')).toBeInTheDocument();
45
+ expect(screen.getByText('Record type')).toBeInTheDocument();
45
46
  });
46
47
 
47
48
  test('change property name', async () => {
@@ -73,7 +74,7 @@ describe('ViewEditor', () => {
73
74
  expect(schemaProperties!.name).toBeUndefined();
74
75
 
75
76
  // Check view contains new_property field.
76
- const newPropertyField = debugObjects.view.fields.find((field: any) => field.path === 'new_property');
77
+ const newPropertyField = debugObjects.view.projection.fields.find((field: any) => field.path === 'new_property');
77
78
  expect(newPropertyField).toBeDefined();
78
79
  expect(newPropertyField!.path).toBe('new_property');
79
80
 
@@ -120,7 +121,9 @@ describe('ViewEditor', () => {
120
121
  expect(schemaProperties!.added_property).toBeDefined();
121
122
 
122
123
  // Check view contains added_property field.
123
- const addedPropertyField = debugObjects.view.fields.find((field: any) => field.path === 'added_property');
124
+ const addedPropertyField = debugObjects.view.projection.fields.find(
125
+ (field: any) => field.path === 'added_property',
126
+ );
124
127
  expect(addedPropertyField).toBeDefined();
125
128
  expect(addedPropertyField!.path).toBe('added_property');
126
129
 
@@ -131,14 +134,15 @@ describe('ViewEditor', () => {
131
134
  expect(addedPropertyProjection!.props.property).toBe('added_property');
132
135
  });
133
136
 
134
- test('delete property', async () => {
137
+ // TODO(mykola): Fix flaky test.
138
+ test('delete property', { retry: 2 }, async () => {
135
139
  await Default.run();
136
140
  await waitForViewEditor();
137
141
 
138
142
  // Find the delete button for the 'name' property.
139
143
  const nameProperty = screen.getByText('name');
140
144
  const propertyRow = nameProperty.closest('[role="listitem"]');
141
- const deleteButton = propertyRow?.querySelector('button:last-child');
145
+ const deleteButton = propertyRow?.querySelector('[data-testid="field.delete"]');
142
146
 
143
147
  if (!deleteButton) {
144
148
  throw new Error('Delete button not found');
@@ -161,7 +165,7 @@ describe('ViewEditor', () => {
161
165
  expect(schemaProperties!.name).toBeUndefined();
162
166
 
163
167
  // Check view no longer contains the name field.
164
- const nameField = debugObjects.view.fields.find((field: any) => field.path === 'name');
168
+ const nameField = debugObjects.view.projection.fields.find((field: any) => field.path === 'name');
165
169
  expect(nameField).toBeUndefined();
166
170
 
167
171
  // Check projection no longer contains the name property.
@@ -186,19 +190,15 @@ describe('ViewEditor', () => {
186
190
  // Access the live objects directly from window using symbol.
187
191
  const debugObjects = getViewEditorDebugObjects();
188
192
 
189
- // Check that hiddenFields is non-empty.
190
- expect(debugObjects.view.hiddenFields).toBeDefined();
191
- expect(debugObjects.view.hiddenFields!.length).toBeGreaterThan(0);
192
-
193
193
  // Click the show button
194
194
  fireEvent.click(screen.getByTestId('show-field-button'));
195
195
 
196
196
  // Wait for the data to update and check that hiddenFields is empty.
197
197
  await waitFor(() => {
198
- expect(debugObjects.view.hiddenFields!.length).toBe(0);
198
+ expect(debugObjects.view.projection.fields.filter(({ visible }) => visible === false)!.length).toBe(0);
199
199
  });
200
200
 
201
201
  // Also verify that the field is back in the visible fields list.
202
- expect(debugObjects.view.fields.length).toBeGreaterThan(0);
202
+ expect(debugObjects.view.projection.fields.filter(({ visible }) => visible !== false).length).toBeGreaterThan(0);
203
203
  });
204
- });
204
+ }, 30_000);