Skip to content

Commit

Permalink
Regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
personalizedrefrigerator committed Jan 25, 2025
1 parent 1f5091d commit 0a621ff
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@ import { Locator, Page } from '@playwright/test';
export default class EditorCodeDialog {
private readonly dialog: Locator;
public readonly textArea: Locator;
public readonly okButton: Locator;

public constructor(page: Page) {
this.dialog = page.getByRole('dialog', { name: 'Edit' });
this.textArea = this.dialog.locator('textarea');
this.okButton = this.dialog.getByRole('button', { name: 'OK' });
}

public async waitFor() {
await this.dialog.waitFor();
await this.textArea.waitFor();
}

public async submit() {
await this.okButton.click();
}
}
19 changes: 19 additions & 0 deletions packages/app-desktop/integration-tests/richTextEditor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,25 @@ test.describe('richTextEditor', () => {
await expect(editor.richTextEditor).toBeFocused();
});

test('double-clicking a code block should edit it', async ({ mainWindow }) => {
const mainScreen = await new MainScreen(mainWindow).setup();
await mainScreen.createNewNote('Testing code blocks');

const editor = mainScreen.noteEditor;
await editor.toggleEditorsButton.click();

// Make the code block
await editor.toggleCodeBlockButton.click();
const codeEditor = editor.richTextCodeEditor;
await codeEditor.textArea.fill('This is a test code block!');
await codeEditor.submit();

// Double-clicking the code block should open it
const renderedCode = editor.getRichTextFrameLocator().locator('pre.hljs', { hasText: 'This is a test code block!' });
await renderedCode.first().dblclick();
await codeEditor.waitFor();
});

test('disabling tab indentation should also disable it in code dialogs', async ({ mainWindow, electronApp }) => {
const mainScreen = await new MainScreen(mainWindow).setup();
await mainScreen.createNewNote('Testing code blocks');
Expand Down

0 comments on commit 0a621ff

Please sign in to comment.