Skip to content

Commit

Permalink
Fixed linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dhuebner committed Aug 30, 2024
1 parent aed1cfc commit 4360985
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 22 deletions.
19 changes: 9 additions & 10 deletions examples/playwright/src/tests/theia-notebook-editor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************

import { expect, test } from '@playwright/test';
import { PlaywrightWorkerArgs, expect, test } from '@playwright/test';
import { TheiaApp } from '../theia-app';
import { TheiaAppLoader } from '../theia-app-loader';
import { TheiaAppLoader, TheiaPlaywrightTestConfig } from '../theia-app-loader';
import { TheiaNotebookEditor } from '../theia-notebook-editor';
import { DefaultPreferences, PreferenceIds, TheiaPreferenceView } from '../theia-preference-view';
import { TheiaWorkspace } from '../theia-workspace';
Expand All @@ -26,8 +26,8 @@ test.describe('Theia Notebook Editor interaction', () => {
let app: TheiaApp;
let editor: TheiaNotebookEditor;

test.beforeAll(async ({ playwright, browser }) => {
app = await loadApp(playwright, browser);
test.beforeAll(async args => {
app = await loadApp(args);
});

test.afterAll(async () => {
Expand Down Expand Up @@ -74,8 +74,8 @@ test.describe('Theia Notebook Cell interaction', () => {
let app: TheiaApp;
let editor: TheiaNotebookEditor;

test.beforeAll(async ({ playwright, browser }) => {
app = await loadApp(playwright, browser);
test.beforeAll(async args => {
app = await loadApp(args);
});

test.afterAll(async () => {
Expand All @@ -88,15 +88,14 @@ test.describe('Theia Notebook Cell interaction', () => {
if (selectedKernel?.match(/^Python 3/) === null) {
await editor.selectKernel('Python 3');
}
})
});

test.afterEach(async () => {
if (editor) {
await editor.closeWithoutSave();
}
});


test('should write text in a code cell', async () => {
const cell = (await editor.cells())[0];
// assume the first cell is a code cell
Expand Down Expand Up @@ -126,9 +125,9 @@ test.describe('Theia Notebook Cell interaction', () => {

});

async function loadApp(playwright: any, browser: any): Promise<TheiaApp> {
async function loadApp(args: TheiaPlaywrightTestConfig & PlaywrightWorkerArgs): Promise<TheiaApp> {
const ws = new TheiaWorkspace(['../src/tests/resources/notebook-files']);
const app = await TheiaAppLoader.load({ playwright, browser }, ws);
const app = await TheiaAppLoader.load(args, ws);
// set auto-save preference to off
const preferenceView = await app.openPreferences(TheiaPreferenceView);
await preferenceView.setOptionsPreferenceById(PreferenceIds.Editor.AutoSave, DefaultPreferences.Editor.AutoSave.Off);
Expand Down
10 changes: 3 additions & 7 deletions examples/playwright/src/theia-notebook-cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { TheiaApp } from './theia-app';
import { TheiaMonacoEditor } from './theia-monaco-editor';
import { TheiaPageObject } from './theia-page-object';


/**
* Page object for a Theia notebook cell.
*/
Expand All @@ -39,7 +38,7 @@ export class TheiaNotebookCell extends TheiaPageObject {
return this.monacoEditor;
}

/**
/**
* @returns `true` id the cell is a code cell, `false` otherwise.
*/
async isCodeCell(): Promise<boolean> {
Expand Down Expand Up @@ -84,7 +83,6 @@ export class TheiaNotebookCell extends TheiaPageObject {

/**
* Adds text to the editor of the cell.
*
* @param text The text to add to the editor.
* @param lineNumber The line number where to add the text. Default is 1.
*/
Expand All @@ -94,7 +92,6 @@ export class TheiaNotebookCell extends TheiaPageObject {
await this.page.keyboard.type(text);
}


async execute(): Promise<void> {
const execButton = this.locator.locator('[id="notebook.cell.execute-cell"]');
await execButton.waitFor({ state: 'visible' });
Expand All @@ -117,14 +114,13 @@ export class TheiaNotebookCell extends TheiaPageObject {
const outputContainer = await this.outputContainer();
await outputContainer.waitFor({ state: 'visible' });
// By default just collect all spans text.
const spans: Locator = outputContainer.locator('span:not(:has(*))');// ignore nested spans
const spanTexts = await spans.evaluateAll(spans => spans.map(span => span.textContent?.trim())
const spansLocator: Locator = outputContainer.locator('span:not(:has(*))'); // ignore nested spans
const spanTexts = await spansLocator.evaluateAll(spans => spans.map(span => span.textContent?.trim())
.filter(text => text !== undefined && text.length > 0));
return spanTexts.join('');
}
}


export class TheiaEmbeddedMonacoEditor extends TheiaMonacoEditor {

constructor(public readonly locator: Locator, app: TheiaApp) {
Expand Down
5 changes: 2 additions & 3 deletions examples/playwright/src/theia-notebook-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,11 @@ export class TheiaNotebookEditor extends TheiaEditor {
if (!kernelItem) {
throw new Error('Select kernel toolbar item not found.');
}
return await this.notebookToolbar().locator.locator('#kernel-text').innerText();
return this.notebookToolbar().locator.locator('#kernel-text').innerText();
}

/**
* Allows to select a kernel using toolbar item.
*
* @param kernelName The name of the kernel to select.
*/
async selectKernel(kernelName: string): Promise<void> {
Expand Down Expand Up @@ -98,7 +97,7 @@ export class TheiaNotebookEditor extends TheiaEditor {
await this.waitForCellCountChanged(currentCellsCount);
}

protected async waitForCellCountChanged(prevCount: number) {
protected async waitForCellCountChanged(prevCount: number): Promise<void> {
await this.viewLocator().locator('li.theia-notebook-cell').evaluateAll(
(elements, currentCount) => elements.length > currentCount, prevCount
);
Expand Down
2 changes: 0 additions & 2 deletions examples/playwright/src/theia-notebook-toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,4 @@ export class TheiaNotebookToolbar extends TheiaToolbar {
// Use locator instead of page to find the toolbar element.
await this.locator.waitFor({ state: 'visible' });
}


}

0 comments on commit 4360985

Please sign in to comment.