From cd8b56706bce667d768456a29cdc85a3fa27ab7c Mon Sep 17 00:00:00 2001 From: "JUST.in DO IT" Date: Tue, 17 Sep 2024 14:27:47 -0700 Subject: [PATCH] fix: unable to disallow csv upload on header menu (#30271) --- .../src/features/home/RightMenu.test.tsx | 14 +++++++++----- superset-frontend/src/features/home/RightMenu.tsx | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/superset-frontend/src/features/home/RightMenu.test.tsx b/superset-frontend/src/features/home/RightMenu.test.tsx index 50c0ca325..ba50a5256 100644 --- a/superset-frontend/src/features/home/RightMenu.test.tsx +++ b/superset-frontend/src/features/home/RightMenu.test.tsx @@ -308,10 +308,13 @@ test('If there is a DB with allow_file_upload set as True the option should be e userEvent.hover(dropdown); const dataMenu = await screen.findByText(dropdownItems[0].label); userEvent.hover(dataMenu); - expect(await screen.findByText('Upload CSV to database')).toBeInTheDocument(); + const csvMenu = await screen.findByText('Upload CSV to database'); + expect(csvMenu).toBeInTheDocument(); expect( await screen.findByText('Upload Excel to database'), ).toBeInTheDocument(); + + expect(csvMenu).not.toHaveAttribute('aria-disabled', 'true'); }); test('If there is NOT a DB with allow_file_upload set as True the option should be disabled', async () => { @@ -341,10 +344,11 @@ test('If there is NOT a DB with allow_file_upload set as True the option should userEvent.hover(dropdown); const dataMenu = await screen.findByText(dropdownItems[0].label); userEvent.hover(dataMenu); - expect(await screen.findByText('Upload CSV to database')).toBeInTheDocument(); - expect( - (await screen.findByText('Upload CSV to database')).closest('a'), - ).not.toBeInTheDocument(); + const csvMenu = await screen.findByRole('menuitem', { + name: 'Upload CSV to database', + }); + expect(csvMenu).toBeInTheDocument(); + expect(csvMenu).toHaveAttribute('aria-disabled', 'true'); }); test('Logs out and clears local storage item redux', async () => { diff --git a/superset-frontend/src/features/home/RightMenu.tsx b/superset-frontend/src/features/home/RightMenu.tsx index c07b6b33a..e5c34fdd9 100644 --- a/superset-frontend/src/features/home/RightMenu.tsx +++ b/superset-frontend/src/features/home/RightMenu.tsx @@ -313,7 +313,7 @@ const RightMenu = ({ const buildMenuItem = (item: MenuObjectChildProps) => item.disable ? ( - + {item.label}