Skip to content

Commit 651df6f

Browse files
committed
feat(metadata): Update multilevel taxonomy test after rebase
1 parent 9b27f2f commit 651df6f

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

src/elements/content-sidebar/stories/tests/MetadataSidebarRedesign-visual.stories.tsx

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -686,40 +686,40 @@ export const EditMultilevelTaxonomy: StoryObj<typeof MetadataSidebarRedesign> =
686686
const editButton = await canvas.findByRole('button', { name: 'Edit My Taxonomy' });
687687
await userEvent.click(editButton);
688688

689-
const multilevelInput = await canvas.findByRole('combobox');
690-
await userEvent.click(multilevelInput);
691-
692-
const listbox = await canvas.findByRole('listbox');
693-
const listboxCanvas = within(listbox);
694-
695-
const japanLabel = await listboxCanvas.findByText('Japan');
696-
const japanTreeitem = japanLabel.closest('[role="treeitem"]') as HTMLElement | null;
697-
expect(japanTreeitem).not.toBeNull();
698-
const expander = within(japanTreeitem as HTMLElement).getByRole('button', { name: 'Expand branch' });
699-
await userEvent.click(expander);
700-
701-
const hokkaidoLabel = await listboxCanvas.findByText('Hokkaido');
702-
const hokkaidoTreeitem = hokkaidoLabel.closest('[role="treeitem"]') as HTMLElement | null;
703-
expect(hokkaidoTreeitem).not.toBeNull();
704-
const hokkaidoExpander = within(hokkaidoTreeitem as HTMLElement).getByRole('button', { name: 'Expand branch' });
705-
await userEvent.click(hokkaidoExpander);
706-
707-
const sapporoTreeitem = await listboxCanvas.findByRole('treeitem', { name: 'Sapporo' });
708-
await userEvent.click(sapporoTreeitem);
709-
710-
const nestedExpandButtons = await waitFor(() => screen.getAllByRole('button', { name: 'Expand branch' }));
711-
712-
await userEvent.click(nestedExpandButtons[2]);
713-
714-
const sapporoOption = await waitFor(() => canvas.getByRole('treeitem', { name: 'Sapporo' }));
715-
716-
expect(sapporoOption).toBeInTheDocument();
717-
expect(sapporoOption).toHaveAttribute('aria-selected', 'false');
718-
719-
await userEvent.click(sapporoOption);
689+
const navigateToSapporoTreeItem = async () => {
690+
const multilevelInput = await canvas.findByRole('combobox');
691+
await userEvent.click(multilevelInput);
692+
693+
const listbox = await canvas.findByRole('listbox');
694+
const listboxCanvas = within(listbox);
695+
696+
const japanLabel = await listboxCanvas.findByText('Japan');
697+
const japanTreeitem = japanLabel.closest('[role="treeitem"]') as HTMLElement | null;
698+
expect(japanTreeitem).not.toBeNull();
699+
const expander = within(japanTreeitem as HTMLElement).getByRole('button', { name: 'Expand branch' });
700+
await userEvent.click(expander);
701+
702+
const hokkaidoLabel = await listboxCanvas.findByText('Hokkaido');
703+
const hokkaidoTreeitem = hokkaidoLabel.closest('[role="treeitem"]') as HTMLElement | null;
704+
expect(hokkaidoTreeitem).not.toBeNull();
705+
const hokkaidoExpander = within(hokkaidoTreeitem as HTMLElement).getByRole('button', {
706+
name: 'Expand branch',
707+
});
708+
await userEvent.click(hokkaidoExpander);
709+
710+
const sapporoTreeitem = await listboxCanvas.findByRole('treeitem', { name: 'Sapporo' });
711+
return sapporoTreeitem;
712+
};
713+
714+
const unselectedSapporoTreeitem = await navigateToSapporoTreeItem();
715+
expect(unselectedSapporoTreeitem).toHaveAttribute('aria-selected', 'false');
716+
await userEvent.click(unselectedSapporoTreeitem);
720717

721718
const sapporoSelection = await waitFor(() => canvas.getByRole('gridcell', { name: 'Sapporo' }));
722719
expect(sapporoSelection).toBeInTheDocument();
720+
721+
const seelectedSapporoTreeitem = await navigateToSapporoTreeItem();
722+
expect(seelectedSapporoTreeitem).toHaveAttribute('aria-selected', 'true');
723723
},
724724
};
725725

0 commit comments

Comments
 (0)