Skip to content

Commit cda78ec

Browse files
committed
fix(metadata): add await for loading indicator in taxonomy stories
1 parent 579eb07 commit cda78ec

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,19 @@ const mockLogger = {
4848
},
4949
};
5050

51+
// I'm not exactly sure why, but the metadata sidebar shows a loading indicator for several seconds with taxonomies
52+
// This await is needed in order for taxonomy tests to pass.
53+
const waitForLoadingToComplete = async (canvas: ReturnType<typeof within>) => {
54+
const loadingIndicator = await canvas.findByRole('status', { name: 'Loading' });
55+
expect(loadingIndicator).toBeInTheDocument();
56+
await waitFor(
57+
async () => {
58+
expect(loadingIndicator).not.toBeInTheDocument();
59+
},
60+
{ timeout: 10000 },
61+
);
62+
};
63+
5164
export const AddTemplateDropdownMenuOn = {
5265
play: async ({ canvasElement }) => {
5366
const canvas = within(canvasElement);
@@ -76,6 +89,7 @@ export const AddTemplateDropdownMenuOnEmpty = {
7689
},
7790
play: async ({ canvasElement }) => {
7891
const canvas = within(canvasElement);
92+
7993
const addTemplateButton = await canvas.findByRole('button', { name: 'Add template' }, { timeout: 2000 });
8094

8195
expect(addTemplateButton).toBeInTheDocument();
@@ -616,6 +630,8 @@ export const ViewMultilevelTaxonomy: StoryObj<typeof MetadataSidebarRedesign> =
616630
play: async ({ canvasElement }) => {
617631
const canvas = within(canvasElement);
618632

633+
await waitForLoadingToComplete(canvas);
634+
619635
await waitFor(async () => {
620636
const multilevelOptionButton = canvas.getByRole('button', { name: 'London' });
621637

@@ -644,6 +660,8 @@ export const ViewSinglelevelTaxonomy: StoryObj<typeof MetadataSidebarRedesign> =
644660
play: async ({ canvasElement }) => {
645661
const canvas = within(canvasElement);
646662

663+
await waitForLoadingToComplete(canvas);
664+
647665
await waitFor(async () => {
648666
const singlelevelOptionButton = canvas.getByRole('button', { name: 'Blue' });
649667

@@ -663,6 +681,8 @@ export const EditMultilevelTaxonomy: StoryObj<typeof MetadataSidebarRedesign> =
663681
play: async ({ canvasElement }) => {
664682
const canvas = within(canvasElement);
665683

684+
await waitForLoadingToComplete(canvas);
685+
666686
const editButton = await waitFor(() => canvas.getByRole('button', { name: 'Edit My Taxonomy' }));
667687

668688
await userEvent.click(editButton);
@@ -709,6 +729,8 @@ export const EditSinglelevelTaxonomy: StoryObj<typeof MetadataSidebarRedesign> =
709729
play: async ({ canvasElement }) => {
710730
const canvas = within(canvasElement);
711731

732+
await waitForLoadingToComplete(canvas);
733+
712734
const editButton = await waitFor(() => canvas.getByRole('button', { name: 'Edit My Taxonomy' }));
713735

714736
await userEvent.click(editButton);

0 commit comments

Comments
 (0)