2024-09-26 03:35:32 -07:00
|
|
|
|
2025-02-07 10:59:54 -08:00
|
|
|
import { test, expect } from './util/test';
|
2024-09-26 03:35:32 -07:00
|
|
|
import MainScreen from './models/MainScreen';
|
|
|
|
|
|
|
|
test.describe('pluginApi', () => {
|
2024-11-05 01:04:44 -08:00
|
|
|
test('the editor.setText command should update the current note (use RTE: false)', async ({ startAppWithPlugins }) => {
|
|
|
|
const { app, mainWindow } = await startAppWithPlugins(['resources/test-plugins/execCommand.js']);
|
2024-11-20 03:35:22 -08:00
|
|
|
const mainScreen = await new MainScreen(mainWindow).setup();
|
2024-11-05 01:04:44 -08:00
|
|
|
await mainScreen.createNewNote('First note');
|
|
|
|
const editor = mainScreen.noteEditor;
|
2024-09-26 03:35:32 -07:00
|
|
|
|
2024-11-05 01:04:44 -08:00
|
|
|
await editor.focusCodeMirrorEditor();
|
|
|
|
await mainWindow.keyboard.type('This content should be overwritten.');
|
2024-09-26 03:35:32 -07:00
|
|
|
|
2024-11-05 01:04:44 -08:00
|
|
|
await editor.expectToHaveText('This content should be overwritten.');
|
|
|
|
await mainScreen.goToAnything.runCommand(app, 'testUpdateEditorText');
|
|
|
|
await editor.expectToHaveText('PASS');
|
2024-09-26 03:35:32 -07:00
|
|
|
|
2024-11-05 01:04:44 -08:00
|
|
|
// Should still have the same text after switching notes:
|
|
|
|
await mainScreen.createNewNote('Second note');
|
|
|
|
await editor.goBack();
|
2024-09-26 03:35:32 -07:00
|
|
|
|
2024-11-05 01:04:44 -08:00
|
|
|
await editor.expectToHaveText('PASS');
|
|
|
|
});
|
2025-02-07 10:59:54 -08:00
|
|
|
|
2025-04-13 11:28:56 -07:00
|
|
|
test('should return form data from the dialog API', async ({ startAppWithPlugins }) => {
|
|
|
|
const { app, mainWindow } = await startAppWithPlugins(['resources/test-plugins/dialogs.js']);
|
|
|
|
const mainScreen = await new MainScreen(mainWindow).setup();
|
|
|
|
await mainScreen.createNewNote('First note');
|
|
|
|
|
|
|
|
const editor = mainScreen.noteEditor;
|
|
|
|
await editor.expectToHaveText('');
|
|
|
|
|
|
|
|
await mainScreen.goToAnything.runCommand(app, 'showTestDialog');
|
|
|
|
// Wait for the iframe to load
|
|
|
|
const dialogContent = mainScreen.dialog.locator('iframe').contentFrame();
|
|
|
|
await dialogContent.locator('form').waitFor();
|
|
|
|
|
|
|
|
// Submitting the dialog should include form data in the output
|
|
|
|
await mainScreen.dialog.getByRole('button', { name: 'Okay' }).click();
|
|
|
|
await editor.expectToHaveText(JSON.stringify({
|
|
|
|
id: 'ok',
|
|
|
|
hasFormData: true,
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
|
2025-02-07 10:59:54 -08:00
|
|
|
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();
|
|
|
|
|
|
|
|
await mainScreen.goToAnything.runCommand(app, 'testShowToastNotification');
|
|
|
|
const notificationLocator = mainWindow.getByText('Toast: This is a test info message.');
|
|
|
|
await expect(notificationLocator).toBeVisible();
|
|
|
|
|
|
|
|
// Running the command again, there should be two notifications with the same text.
|
|
|
|
await mainScreen.goToAnything.runCommand(app, 'testShowToastNotification');
|
|
|
|
await expect(notificationLocator.nth(1)).toBeVisible();
|
|
|
|
await expect(notificationLocator.nth(0)).toBeVisible();
|
|
|
|
|
|
|
|
await mainScreen.goToAnything.runCommand(app, 'testShowToastNotification');
|
|
|
|
await expect(notificationLocator).toHaveCount(3);
|
|
|
|
});
|
2024-09-26 03:35:32 -07:00
|
|
|
});
|
|
|
|
|