Skip to content

Commit

Permalink
Include latest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
geido committed Apr 14, 2021
1 parent 6c56e4f commit a64fa0d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const createProps = () => ({
id: 1,
dash_edit_perm: false,
dash_save_perm: false,
dash_share_perm: false,
userId: 1,
metadata: {},
common: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const createProps = () => ({
updateCss: jest.fn(),
userCanEdit: false,
userCanSave: false,
userCanShare: false,
lastModifiedTime: 0,
});
const editModeOnProps = {
Expand Down Expand Up @@ -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();
Expand All @@ -119,16 +118,26 @@ 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();
expect(screen.getByText('Edit dashboard properties')).toBeInTheDocument();
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 = {
Expand Down

0 comments on commit a64fa0d

Please sign in to comment.