feat(19.6.1-05): persist picked relation labels across FormView tab remount

- FORM_REMEMBER_LABEL inject so hosts keep picked option names
- RelationField choose() writes the label before emit
- Vitest backstops remount and tab-switch labeling

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jakub Zych
2026-10-22 14:40:35 +02:00
parent ba0501c274
commit 14baafb27c
6 changed files with 122 additions and 4 deletions

View File

@@ -13,6 +13,7 @@ import {
langFixture,
listFixture,
listSchemaFixture,
optionsFixture,
recordFixture,
rosterFormSchemaFixture,
rosterRecordFixture,
@@ -931,3 +932,31 @@ describe('field triggers on the form (D-21, UI-SPEC C6 backstops)', () => {
expect(banner.text()).toContain('Overrides are refused.')
})
})
describe('picked relation labels across tab remount', () => {
type Mounted = Awaited<ReturnType<typeof mountApp>>['wrapper']
async function tab(wrapper: Mounted, key: string): Promise<void> {
await wrapper.find(`[role="tab"][data-tab="${key}"]`).trigger('click')
await flushPromises()
}
it('keeps a picked relation label after switching tabs', async () => {
const { wrapper } = await mountApp(
'/acme/demo/widgets/1',
routes({ [`GET ${BASE}/fields/maker/options`]: { body: optionsFixture.makerField } }),
)
const maker = () => wrapper.find('[data-field="maker"] [role="combobox"]')
expect((maker().element as HTMLInputElement).value).toBe('Bolt & Co')
await maker().trigger('click')
await flushPromises()
await wrapper.find('[data-field="maker"] [role="option"][data-value="1"]').trigger('mousedown')
await flushPromises()
await tab(wrapper, 'tab:Details')
await tab(wrapper, 'default')
expect((maker().element as HTMLInputElement).value).toBe('Acme Works')
expect((maker().element as HTMLInputElement).value).not.toBe('1')
})
})