1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-12-05 22:57:29 +02:00

Desktop: Resolves #11687: Plugins: Allow editor plugins to support multiple windows (#12041)

This commit is contained in:
Henry Heino
2025-06-06 02:00:47 -07:00
committed by GitHub
parent 291ba88224
commit 608dbab453
46 changed files with 1022 additions and 195 deletions

View File

@@ -1,16 +1,20 @@
import { setupDatabaseAndSynchronizer, switchClient } from '@joplin/lib/testing/test-utils';
import { renderHook } from '@testing-library/react-hooks';
import usePluginEditorView from './usePluginEditorView';
import { PluginStates, PluginViewState } from '@joplin/lib/services/plugins/reducer';
import { PluginEditorViewState, PluginStates } from '@joplin/lib/services/plugins/reducer';
import { ContainerType } from '@joplin/lib/services/plugins/WebviewController';
import { defaultWindowId } from '@joplin/lib/reducer';
const sampleView = (): PluginViewState => {
const sampleView = (): PluginEditorViewState => {
return {
buttons: [],
containerType: ContainerType.Editor,
id: 'view-1',
opened: true,
editorTypeId: 'view-1',
type: 'webview',
opened: true,
active: true,
parentWindowId: defaultWindowId,
};
};
@@ -24,7 +28,7 @@ describe('usePluginEditorView', () => {
const pluginStates: PluginStates = {
'0': {
contentScripts: {},
id: '1',
id: '0',
views: {
'view-0': {
...sampleView(),
@@ -43,7 +47,7 @@ describe('usePluginEditorView', () => {
};
{
const test = renderHook(() => usePluginEditorView(pluginStates, ['view-1']));
const test = renderHook(() => usePluginEditorView(pluginStates));
expect(test.result.current.editorPlugin.id).toBe('1');
expect(test.result.current.editorView.id).toBe('view-1');
test.unmount();
@@ -51,7 +55,7 @@ describe('usePluginEditorView', () => {
{
pluginStates['1'].views['view-1'].opened = false;
const test = renderHook(() => usePluginEditorView(pluginStates, ['view-1']));
const test = renderHook(() => usePluginEditorView(pluginStates));
expect(test.result.current.editorPlugin).toBeFalsy();
test.unmount();
}
@@ -79,7 +83,7 @@ describe('usePluginEditorView', () => {
};
{
const test = renderHook(() => usePluginEditorView(pluginStates, ['view-1']));
const test = renderHook(() => usePluginEditorView(pluginStates));
expect(test.result.current.editorPlugin.id).toBe('1');
expect(test.result.current.editorView.id).toBe('view-1');
test.unmount();