You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-26 22:41:17 +02:00
Chore: Refactor WebViewController (#13133)
This commit is contained in:
@@ -45,6 +45,41 @@ test.describe('pluginApi', () => {
|
||||
}));
|
||||
});
|
||||
|
||||
test('should report the correct visibility state for dialogs', async ({ startAppWithPlugins }) => {
|
||||
const { app, mainWindow } = await startAppWithPlugins(['resources/test-plugins/dialogs.js']);
|
||||
const mainScreen = await new MainScreen(mainWindow).setup();
|
||||
await mainScreen.createNewNote('Dialog test note');
|
||||
|
||||
const editor = mainScreen.noteEditor;
|
||||
const expectVisible = async (visible: boolean) => {
|
||||
// Check UI visibility
|
||||
if (visible) {
|
||||
await expect(mainScreen.dialog).toBeVisible();
|
||||
} else {
|
||||
await expect(mainScreen.dialog).not.toBeVisible();
|
||||
}
|
||||
|
||||
// Check visibility reported through the plugin API
|
||||
await expect.poll(async () => {
|
||||
await mainScreen.goToAnything.runCommand(app, 'getTestDialogVisibility');
|
||||
|
||||
const editorContent = await editor.contentLocator();
|
||||
return editorContent.textContent();
|
||||
}).toBe(JSON.stringify({
|
||||
visible: visible,
|
||||
active: visible,
|
||||
}));
|
||||
};
|
||||
await expectVisible(false);
|
||||
|
||||
await mainScreen.goToAnything.runCommand(app, 'showTestDialog');
|
||||
await expectVisible(true);
|
||||
|
||||
// Submitting the dialog should include form data in the output
|
||||
await mainScreen.dialog.getByRole('button', { name: 'Okay' }).click();
|
||||
await expectVisible(false);
|
||||
});
|
||||
|
||||
test('should be possible to create multiple toasts with the same text from a plugin', async ({ startAppWithPlugins }) => {
|
||||
const { app, mainWindow } = await startAppWithPlugins(['resources/test-plugins/showToast.js']);
|
||||
const mainScreen = await new MainScreen(mainWindow).setup();
|
||||
@@ -122,5 +157,30 @@ test.describe('pluginApi', () => {
|
||||
await msleep(Second);
|
||||
await expect(noteEditor.codeMirrorEditor).toHaveText(expectedUpdatedText);
|
||||
});
|
||||
|
||||
test('should support hiding and showing panels', async ({ startAppWithPlugins }) => {
|
||||
const { mainWindow, app } = await startAppWithPlugins(['resources/test-plugins/panels.js']);
|
||||
const mainScreen = await new MainScreen(mainWindow).setup();
|
||||
await mainScreen.createNewNote('Test note (panels)');
|
||||
|
||||
const panelLocator = await mainScreen.pluginPanelLocator('org.joplinapp.plugins.example.panels');
|
||||
|
||||
const noteEditor = mainScreen.noteEditor;
|
||||
await mainScreen.goToAnything.runCommand(app, 'testShowPanel');
|
||||
await expect(noteEditor.codeMirrorEditor).toHaveText('visible');
|
||||
|
||||
// Panel should be visible
|
||||
await expect(panelLocator).toBeVisible();
|
||||
// The panel should have the expected content
|
||||
const panelContent = panelLocator.contentFrame();
|
||||
await expect(
|
||||
panelContent.getByRole('heading', { name: 'Panel content' }),
|
||||
).toBeAttached();
|
||||
|
||||
await mainScreen.goToAnything.runCommand(app, 'testHidePanel');
|
||||
await expect(noteEditor.codeMirrorEditor).toHaveText('hidden');
|
||||
|
||||
await expect(panelLocator).not.toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user