diff --git a/superset-frontend/src/dashboard/components/Header/Header.test.tsx b/superset-frontend/src/dashboard/components/Header/Header.test.tsx index 9e285f1c66af1..b8034bf92457d 100644 --- a/superset-frontend/src/dashboard/components/Header/Header.test.tsx +++ b/superset-frontend/src/dashboard/components/Header/Header.test.tsx @@ -465,4 +465,31 @@ describe('Email Report Modal', () => { // BLOCKER: I cannot get report to populate, as its data is handled through redux expect.anything(); }); + + it('Should render report header', async () => { + const mockedProps = createProps(); + render(setup(mockedProps)); + expect( + screen.getByRole('button', { name: 'Schedule email report' }), + ).toBeInTheDocument(); + }); + + it('Should not render report header even with menu access for anonymous user', async () => { + const mockedProps = createProps(); + const anonymousUserProps = { + ...mockedProps, + user: { + roles: { + Public: [['menu_access', 'Manage']], + }, + permissions: { + datasource_access: ['[examples].[birth_names](id:2)'], + }, + }, + }; + render(setup(anonymousUserProps)); + expect( + screen.queryByRole('button', { name: 'Schedule email report' }), + ).not.toBeInTheDocument(); + }); }); diff --git a/superset-frontend/src/dashboard/components/Header/index.jsx b/superset-frontend/src/dashboard/components/Header/index.jsx index f8ca74b8e9713..1fb26eb0cc914 100644 --- a/superset-frontend/src/dashboard/components/Header/index.jsx +++ b/superset-frontend/src/dashboard/components/Header/index.jsx @@ -435,7 +435,7 @@ class Header extends React.PureComponent { return false; } const { user } = this.props; - if (!user) { + if (!user?.userId) { // this is in the case that there is an anonymous user. return false; } diff --git a/superset-frontend/src/explore/components/ExploreChartHeader/index.jsx b/superset-frontend/src/explore/components/ExploreChartHeader/index.jsx index 008ff0a5950cf..be713614a4178 100644 --- a/superset-frontend/src/explore/components/ExploreChartHeader/index.jsx +++ b/superset-frontend/src/explore/components/ExploreChartHeader/index.jsx @@ -227,7 +227,7 @@ export class ExploreChartHeader extends React.PureComponent { return false; } const { user } = this.props; - if (!user) { + if (!user?.userId) { // this is in the case that there is an anonymous user. return false; }