Skip to content

Commit

Permalink
fix: unable to disallow csv upload on header menu (apache#30271)
Browse files Browse the repository at this point in the history
  • Loading branch information
justinpark committed Sep 17, 2024
1 parent 2f0c994 commit cd8b567
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions superset-frontend/src/features/home/RightMenu.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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 () => {
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/features/home/RightMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ const RightMenu = ({

const buildMenuItem = (item: MenuObjectChildProps) =>
item.disable ? (
<Menu.Item key={item.name} css={styledDisabled}>
<Menu.Item key={item.name} css={styledDisabled} disabled>
<Tooltip placement="top" title={tooltipText}>
{item.label}
</Tooltip>
Expand Down

0 comments on commit cd8b567

Please sign in to comment.