From 436098539f11651c3584b51623d8cda065243a3f Mon Sep 17 00:00:00 2001 From: Dennis Huebner Date: Fri, 30 Aug 2024 14:03:31 +0200 Subject: [PATCH] Fixed linting errors --- .../src/tests/theia-notebook-editor.test.ts | 19 +++++++++---------- .../playwright/src/theia-notebook-cell.ts | 10 +++------- .../playwright/src/theia-notebook-editor.ts | 5 ++--- .../playwright/src/theia-notebook-toolbar.ts | 2 -- 4 files changed, 14 insertions(+), 22 deletions(-) diff --git a/examples/playwright/src/tests/theia-notebook-editor.test.ts b/examples/playwright/src/tests/theia-notebook-editor.test.ts index 0417e9babe471..4cffc4ea1ebe7 100644 --- a/examples/playwright/src/tests/theia-notebook-editor.test.ts +++ b/examples/playwright/src/tests/theia-notebook-editor.test.ts @@ -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'; @@ -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 () => { @@ -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 () => { @@ -88,7 +88,7 @@ test.describe('Theia Notebook Cell interaction', () => { if (selectedKernel?.match(/^Python 3/) === null) { await editor.selectKernel('Python 3'); } - }) + }); test.afterEach(async () => { if (editor) { @@ -96,7 +96,6 @@ test.describe('Theia Notebook Cell interaction', () => { } }); - test('should write text in a code cell', async () => { const cell = (await editor.cells())[0]; // assume the first cell is a code cell @@ -126,9 +125,9 @@ test.describe('Theia Notebook Cell interaction', () => { }); -async function loadApp(playwright: any, browser: any): Promise { +async function loadApp(args: TheiaPlaywrightTestConfig & PlaywrightWorkerArgs): Promise { 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); diff --git a/examples/playwright/src/theia-notebook-cell.ts b/examples/playwright/src/theia-notebook-cell.ts index 5afcbebcca1c7..a6fc5162f6687 100644 --- a/examples/playwright/src/theia-notebook-cell.ts +++ b/examples/playwright/src/theia-notebook-cell.ts @@ -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. */ @@ -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 { @@ -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. */ @@ -94,7 +92,6 @@ export class TheiaNotebookCell extends TheiaPageObject { await this.page.keyboard.type(text); } - async execute(): Promise { const execButton = this.locator.locator('[id="notebook.cell.execute-cell"]'); await execButton.waitFor({ state: 'visible' }); @@ -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) { diff --git a/examples/playwright/src/theia-notebook-editor.ts b/examples/playwright/src/theia-notebook-editor.ts index 4dc6860350798..97894c4ca1fb8 100644 --- a/examples/playwright/src/theia-notebook-editor.ts +++ b/examples/playwright/src/theia-notebook-editor.ts @@ -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 { @@ -98,7 +97,7 @@ export class TheiaNotebookEditor extends TheiaEditor { await this.waitForCellCountChanged(currentCellsCount); } - protected async waitForCellCountChanged(prevCount: number) { + protected async waitForCellCountChanged(prevCount: number): Promise { await this.viewLocator().locator('li.theia-notebook-cell').evaluateAll( (elements, currentCount) => elements.length > currentCount, prevCount ); diff --git a/examples/playwright/src/theia-notebook-toolbar.ts b/examples/playwright/src/theia-notebook-toolbar.ts index 33318f422d1ea..3349e2267b6e4 100644 --- a/examples/playwright/src/theia-notebook-toolbar.ts +++ b/examples/playwright/src/theia-notebook-toolbar.ts @@ -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' }); } - - }