diff --git a/superset-frontend/src/dashboard/components/Header/Header.test.tsx b/superset-frontend/src/dashboard/components/Header/Header.test.tsx index fe8dd56a53dd6..d5393b2275597 100644 --- a/superset-frontend/src/dashboard/components/Header/Header.test.tsx +++ b/superset-frontend/src/dashboard/components/Header/Header.test.tsx @@ -31,6 +31,7 @@ const createProps = () => ({ id: 1, dash_edit_perm: false, dash_save_perm: false, + dash_share_perm: false, userId: 1, metadata: {}, common: { diff --git a/superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/HeaderActionsDropdown.test.tsx b/superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/HeaderActionsDropdown.test.tsx index ac87d6d358d31..039c1ef97c6d1 100644 --- a/superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/HeaderActionsDropdown.test.tsx +++ b/superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/HeaderActionsDropdown.test.tsx @@ -55,6 +55,7 @@ const createProps = () => ({ updateCss: jest.fn(), userCanEdit: false, userCanSave: false, + userCanShare: false, lastModifiedTime: 0, }); const editModeOnProps = { @@ -107,9 +108,7 @@ test('should render the menu items', async () => { const mockedProps = createProps(); render(setup(mockedProps)); await openDropdown(); - expect(screen.getAllByRole('menuitem')).toHaveLength(6); - expect(screen.getByText('Copy dashboard URL')).toBeInTheDocument(); - expect(screen.getByText('Share dashboard by email')).toBeInTheDocument(); + expect(screen.getAllByRole('menuitem')).toHaveLength(4); expect(screen.getByText('Refresh dashboard')).toBeInTheDocument(); expect(screen.getByText('Set auto-refresh interval')).toBeInTheDocument(); expect(screen.getByText('Download as image')).toBeInTheDocument(); @@ -119,9 +118,7 @@ test('should render the menu items', async () => { test('should render the menu items in edit mode', async () => { render(setup(editModeOnProps)); await openDropdown(); - expect(screen.getAllByRole('menuitem')).toHaveLength(7); - expect(screen.getByText('Copy dashboard URL')).toBeInTheDocument(); - expect(screen.getByText('Share dashboard by email')).toBeInTheDocument(); + expect(screen.getAllByRole('menuitem')).toHaveLength(5); expect(screen.getByText('Refresh dashboard')).toBeInTheDocument(); expect(screen.getByText('Set auto-refresh interval')).toBeInTheDocument(); expect(screen.getByText('Set filter mapping')).toBeInTheDocument(); @@ -129,6 +126,18 @@ test('should render the menu items in edit mode', async () => { expect(screen.getByText('Edit CSS')).toBeInTheDocument(); }); +test('should show the share actions', async () => { + const mockedProps = createProps(); + const canShareProps = { + ...mockedProps, + userCanShare: true, + }; + render(setup(canShareProps)); + await openDropdown(); + expect(screen.getByText('Copy dashboard URL')).toBeInTheDocument(); + expect(screen.getByText('Share dashboard by email')).toBeInTheDocument(); +}); + test('should render the "Save Modal" when user can save', async () => { const mockedProps = createProps(); const canSaveProps = {