Skip to content

Commit 04a3cad

Browse files
committed
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 <noreply@anthropic.com>
1 parent 989b190 commit 04a3cad

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
---
3+
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).

‎packages/app-shell/src/views/studio-design/ObjectHooksPanel.newHookTarget-11820.test.tsx‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,21 @@ describe('ObjectHooksPanel — a new hook (objectui#11820)', () => {
8383
fireEvent.click(screen.getByRole('button', { name: /New/ }));
8484
await waitFor(() => expect(mockClient.save).toHaveBeenCalledTimes(1));
8585

86+
// Two reads answer at their own pace (objectui#11978): the panel's read of
87+
// this package's objects draws the "This package" group, and the editor's
88+
// own read of the object roster draws the labels and the "Other objects"
89+
// group. Until the roster answers, the selected object is drawn by its
90+
// bare name — deliberately, it asserts nothing (objectui#10585) — so the
91+
// group can be on screen while its checkbox is still named `invoice`.
92+
// Every read below whose answer the roster draws waits for it.
8693
const own = await screen.findByRole('group', { name: 'This package' });
87-
expect(within(own).getByRole('checkbox', { name: 'Invoice (invoice)' })).toBeChecked();
88-
expect(within(own).getByRole('checkbox', { name: 'Invoice line (invoice_line)' })).toBeInTheDocument();
94+
expect(await within(own).findByRole('checkbox', { name: 'Invoice (invoice)' })).toBeChecked();
95+
expect(await within(own).findByRole('checkbox', { name: 'Invoice line (invoice_line)' })).toBeInTheDocument();
8996

90-
const outside = screen.getByRole('group', { name: 'Other objects' });
97+
const outside = await screen.findByRole('group', { name: 'Other objects' });
9198
expect(within(outside).getByTestId('hook-object-outside-reach')).toBeInTheDocument();
92-
expect(within(outside).getByRole('checkbox', { name: 'User (sys_user)' })).not.toBeChecked();
93-
expect(within(outside).getByRole('checkbox', { name: 'Employee (hr_employee)' })).toBeInTheDocument();
99+
expect(await within(outside).findByRole('checkbox', { name: 'User (sys_user)' })).not.toBeChecked();
100+
expect(await within(outside).findByRole('checkbox', { name: 'Employee (hr_employee)' })).toBeInTheDocument();
94101

95102
// The package's list was read for THIS package, published and draft.
96103
expect(mockClient.list).toHaveBeenCalledWith('object', { packageId: PACKAGE });

0 commit comments

Comments
 (0)