Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dashboard): don't show report modal for anonymous user #17106

Merged
merged 4 commits into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions superset-frontend/src/dashboard/components/Header/Header.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down