Skip to content

Commit 11f3c2a

Browse files
authored
Merge pull request #1631 from layer5io/marblom007/fix-hide-root-title-test
[RJSFFormWrapper] Fix hideRootObjectTitle baseline assertion
2 parents cc53b09 + 57bf1ba commit 11f3c2a

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

src/__testing__/hideRootObjectTitle.test.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,20 @@ describe('hideRootObjectTitle', () => {
7777
*/
7878
describe('hideRootObjectTitle — RJSF root title/description derivation', () => {
7979
type Recorded = { title: unknown; description: unknown; properties: string[] };
80+
const rootTitleVisibleUiSchema = (() => {
81+
const existingOptions = importDesignUiSchema['ui:options'];
82+
83+
if (typeof existingOptions !== 'object' || existingOptions === null || Array.isArray(existingOptions)) {
84+
return importDesignUiSchema;
85+
}
86+
87+
const { label: _label, ...otherOptions } = existingOptions;
88+
return {
89+
...importDesignUiSchema,
90+
'ui:options': otherOptions
91+
};
92+
})();
93+
8094
const recordRootRender = (uiSchema: Record<string, unknown>): Recorded => {
8195
const recorded: Recorded = { title: undefined, description: undefined, properties: [] };
8296
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -104,8 +118,8 @@ describe('hideRootObjectTitle — RJSF root title/description derivation', () =>
104118
return recorded;
105119
};
106120

107-
it('renders the canonical root title by default (the duplicative heading)', () => {
108-
const recorded = recordRootRender(importDesignUiSchema);
121+
it('renders the canonical root title when root-label suppression is not applied', () => {
122+
const recorded = recordRootRender(rootTitleVisibleUiSchema);
109123
expect(recorded.title).toBe('Import Design');
110124
});
111125

0 commit comments

Comments
 (0)