From 04a3cad2afaa75faca21b059fe0d9c2410061abe Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 8 Oct 2026 15:07:35 +0000 Subject: [PATCH] test(app-shell): the new-hook target test waits for the roster's labels before reading them ObjectHooksPanel.newHookTarget-11820 awaited only the "This package" group, then read the checkbox labels synchronously. The group is drawn by the panel's read of this package's objects; the labels, and the "Other objects" group, are drawn by the hook editor's own read of the object roster. Until the roster answers, the selected object is drawn by its bare name on purpose, so the group could be on screen while its checkbox was still named `invoice`, and the read failed on timing alone. Every read whose answer the roster draws now waits for it with findByRole at the default timeout. The component is unchanged. Claude-Session: https://claude.ai/code/session_01DBZ9bntPZ7VKyQNtJeNsgw Co-authored-by: Claude --- .changeset/11978-hooks-target-label-wait.md | 4 ++++ ...bjectHooksPanel.newHookTarget-11820.test.tsx | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 .changeset/11978-hooks-target-label-wait.md diff --git a/.changeset/11978-hooks-target-label-wait.md b/.changeset/11978-hooks-target-label-wait.md new file mode 100644 index 0000000000..0f02bdacd0 --- /dev/null +++ b/.changeset/11978-hooks-target-label-wait.md @@ -0,0 +1,4 @@ +--- +--- + +No release: a test change only. `@object-ui/app-shell`'s `ObjectHooksPanel.newHookTarget-11820` test now waits for the object roster's labels before it reads them. The panel's read of this package's objects and the hook editor's own roster read answer at their own pace, and until the roster answers the selected object is drawn by its bare name (objectui#10585). The test used to read the labels synchronously once the "This package" group appeared, so whether it passed depended on which read answered first (objectui#11978). diff --git a/packages/app-shell/src/views/studio-design/ObjectHooksPanel.newHookTarget-11820.test.tsx b/packages/app-shell/src/views/studio-design/ObjectHooksPanel.newHookTarget-11820.test.tsx index e9bf443625..cf74f91210 100644 --- a/packages/app-shell/src/views/studio-design/ObjectHooksPanel.newHookTarget-11820.test.tsx +++ b/packages/app-shell/src/views/studio-design/ObjectHooksPanel.newHookTarget-11820.test.tsx @@ -83,14 +83,21 @@ describe('ObjectHooksPanel — a new hook (objectui#11820)', () => { fireEvent.click(screen.getByRole('button', { name: /New/ })); await waitFor(() => expect(mockClient.save).toHaveBeenCalledTimes(1)); + // Two reads answer at their own pace (objectui#11978): the panel's read of + // this package's objects draws the "This package" group, and the editor's + // own read of the object roster draws the labels and the "Other objects" + // group. Until the roster answers, the selected object is drawn by its + // bare name — deliberately, it asserts nothing (objectui#10585) — so the + // group can be on screen while its checkbox is still named `invoice`. + // Every read below whose answer the roster draws waits for it. const own = await screen.findByRole('group', { name: 'This package' }); - expect(within(own).getByRole('checkbox', { name: 'Invoice (invoice)' })).toBeChecked(); - expect(within(own).getByRole('checkbox', { name: 'Invoice line (invoice_line)' })).toBeInTheDocument(); + expect(await within(own).findByRole('checkbox', { name: 'Invoice (invoice)' })).toBeChecked(); + expect(await within(own).findByRole('checkbox', { name: 'Invoice line (invoice_line)' })).toBeInTheDocument(); - const outside = screen.getByRole('group', { name: 'Other objects' }); + const outside = await screen.findByRole('group', { name: 'Other objects' }); expect(within(outside).getByTestId('hook-object-outside-reach')).toBeInTheDocument(); - expect(within(outside).getByRole('checkbox', { name: 'User (sys_user)' })).not.toBeChecked(); - expect(within(outside).getByRole('checkbox', { name: 'Employee (hr_employee)' })).toBeInTheDocument(); + expect(await within(outside).findByRole('checkbox', { name: 'User (sys_user)' })).not.toBeChecked(); + expect(await within(outside).findByRole('checkbox', { name: 'Employee (hr_employee)' })).toBeInTheDocument(); // The package's list was read for THIS package, published and draft. expect(mockClient.list).toHaveBeenCalledWith('object', { packageId: PACKAGE });