michael-s-molina commented on a change in pull request #14184:
URL: https://github.com/apache/superset/pull/14184#discussion_r623365892



##########
File path: superset-frontend/src/components/Menu/Menu.test.tsx
##########
@@ -157,43 +159,63 @@ test('should render all the top navbar menu items', () => 
{
   } = mockedProps;
   render(<Menu {...mockedProps} />);
   menu.forEach(item => {
-    const menuItem = screen.getByText(item.label);
-    expect(menuItem).toHaveAttribute('href', item.url);
+    expect(screen.getByText(item.label)).toBeInTheDocument();
   });
 });
 
-test('should render the top navbar child menu items', () => {
+test('should render the top navbar child menu items', async () => {
   const {
     data: { menu },
   } = mockedProps;
   render(<Menu {...mockedProps} />);
-  const datasets = screen.getByText('Datasets');
-  const databases = screen.getByText('Databases');
-  const dataset = menu[1].childs![0] as { url: string };
-  const database = menu[1].childs![2] as { url: string };
+  const sources = screen.getByText('Sources');
+  userEvent.hover(sources);
+  setTimeout(() => {
+    const datasets = screen.getByText('Datasets');
+    const databases = screen.getByText('Databases');
+    const dataset = menu[1].childs![0] as { url: string };
+    const database = menu[1].childs![2] as { url: string };
 
-  expect(datasets).toHaveAttribute('href', dataset.url);
-  expect(databases).toHaveAttribute('href', database.url);
+    expect(datasets).toHaveAttribute('href', dataset.url);
+    expect(databases).toHaveAttribute('href', database.url);
+  }, 1000);
+});
+
+test('should render the dropdown items', async () => {
+  render(<Menu {...mockedProps} />);
+  dropdownItems.forEach(item => {
+    setTimeout(() => {
+      expect(screen.getByText(item.label)).toHaveAttribute('href', item.url);
+      
expect(screen.getByTestId(`menu-item-${item.label}`)).toBeInTheDocument();
+    }, 10);
+  });
 });
 
 test('should render the Settings', () => {

Review comment:
       Instead of the `setTimeout` we can use `findBy` like:
   
   ```
   test('should render the Settings', async () => {
     render(<Menu {...mockedProps} />);
     const settings = await screen.findByText('Settings');
     expect(settings).toBeInTheDocument();
   });
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to