Skip to content
Snippets Groups Projects

Resolve "Allow plugin to add entries to context menu"

Merged Piotr Gawron requested to merge 307-allow-plugin-to-add-entries-to-context-menu into development
6 files
+ 210
7
Compare changes
  • Side-by-side
  • Inline
Files
6
@@ -7,6 +7,7 @@ import {
import { act, render, screen } from '@testing-library/react';
import { CONTEXT_MENU_INITIAL_STATE } from '@/redux/contextMenu/contextMenu.constants';
import { bioEntityContentFixture } from '@/models/fixtures/bioEntityContentsFixture';
import { PluginsContextMenu } from '@/services/pluginsManager/pluginContextMenu/pluginsContextMenu';
import { ContextMenu } from './ContextMenu.component';
const renderComponent = (initialStore?: InitialStoreState): { store: StoreType } => {
@@ -24,6 +25,13 @@ const renderComponent = (initialStore?: InitialStoreState): { store: StoreType }
};
describe('ContextMenu - Component', () => {
beforeEach(() => {
PluginsContextMenu.menuItems = [];
});
afterEach(() => {
PluginsContextMenu.menuItems = [];
});
describe('when context menu is hidden', () => {
beforeEach(() => {
renderComponent({
@@ -183,4 +191,23 @@ describe('ContextMenu - Component', () => {
expect(modal.modalName).toBe('mol-art');
});
});
it('should render context menu', () => {
const callback = jest.fn();
PluginsContextMenu.addMenu('1324235432', 'Click me', '', true, callback);
renderComponent({
contextMenu: {
...CONTEXT_MENU_INITIAL_STATE,
isOpen: true,
coordinates: [0, 0],
uniprot: '',
},
});
expect(screen.getByTestId('context-modal')).toBeInTheDocument();
expect(screen.getByTestId('context-modal')).not.toHaveClass('hidden');
expect(screen.getByText('Click me')).toBeInTheDocument();
});
});
Loading