From d78c4143ed3ce33b7894408cfa46c7d47b30890a Mon Sep 17 00:00:00 2001 From: Dominik Jelinek Date: Wed, 10 Apr 2024 22:55:48 +0200 Subject: [PATCH] tmp Signed-off-by: Dominik Jelinek --- .../src/components/editor/TextEditor.ts | 16 ++++++++++------ .../src/test/editor/textEditor.test.ts | 18 ++++++++++++++---- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/packages/page-objects/src/components/editor/TextEditor.ts b/packages/page-objects/src/components/editor/TextEditor.ts index 545d273f9..a8b572870 100644 --- a/packages/page-objects/src/components/editor/TextEditor.ts +++ b/packages/page-objects/src/components/editor/TextEditor.ts @@ -373,7 +373,7 @@ export class TextEditor extends Editor { for (let i = 0; i < Math.abs(lineGap); i++) { if(await this.isLine(line)) break; await inputArea.sendKeys(lineKey); - await inputArea.getDriver().sleep(150); + await inputArea.getDriver().sleep(250); if(await this.isLine(line)) break; switch (lineKey) { @@ -388,7 +388,10 @@ export class TextEditor extends Editor { try { await this.waitForCursorPositionAtLine(nextLine); } catch (error) { + console.log('Line ERROR!... retrying...'); + if(await this.isLine(line)) break; + await inputArea.getDriver().actions().clear(); await inputArea.sendKeys(lineKey); await inputArea.getDriver().sleep(250); if(await this.isLine(line)) break; @@ -418,7 +421,7 @@ export class TextEditor extends Editor { for (let i = 0; i < Math.abs(columnGap); i++) { if(await this.isColumn(column)) break; await inputArea.sendKeys(columnKey); - await inputArea.getDriver().sleep(150); + await inputArea.getDriver().sleep(250); if(await this.isColumn(column)) break; if ((await this.getCoordinates())[0] != coordinates[0]) { throw new Error(`Column number ${column} is not accessible on line ${coordinates[0]}`); @@ -436,7 +439,10 @@ export class TextEditor extends Editor { try { await this.waitForCursorPositionAtColumn(nextCol); } catch (error) { + console.log('Column ERROR!... retrying...'); + if(await this.isColumn(column)) break; + await inputArea.getDriver().actions().clear(); await inputArea.sendKeys(columnKey); await inputArea.getDriver().sleep(250); if(await this.isColumn(column)) break; @@ -498,8 +504,7 @@ export class TextEditor extends Editor { */ private async waitForCursorPositionAtLine(line: number, timeout: number = 1_500): Promise { return await this.getDriver().wait(async () => { - const coor = await this.getCoordinates(); - return coor[0] === line; + return await this.isLine(line); }, timeout, `Unable to set cursor at line ${line}`); } @@ -510,8 +515,7 @@ export class TextEditor extends Editor { */ private async waitForCursorPositionAtColumn(column: number, timeout: number = 1_500): Promise { return await this.getDriver().wait(async () => { - const coor = await this.getCoordinates(); - return coor[1] === column; + return await this.isColumn(column); }, timeout, `Unable to set cursor at column ${column}`); } diff --git a/tests/test-project/src/test/editor/textEditor.test.ts b/tests/test-project/src/test/editor/textEditor.test.ts index f28ccf7d1..ff844f740 100644 --- a/tests/test-project/src/test/editor/textEditor.test.ts +++ b/tests/test-project/src/test/editor/textEditor.test.ts @@ -65,7 +65,7 @@ describe('ContentAssist', async function () { }).timeout(15000); }); -describe('TextEditor', function () { +describe.only('TextEditor', function () { let editor: TextEditor; let view: EditorView; @@ -73,6 +73,15 @@ describe('TextEditor', function () { before(async function () { this.timeout(15000); + await VSBrowser.instance.waitForWorkbench(); + await new Promise(res => setTimeout(res, 2000)); + const ew = new EditorView(); + try { + await ew.closeEditor('Welcome'); + } catch (error) { + // continue - Welcome page is not displayed + } + await new Workbench().executeCommand('Create: New File...'); await (await InputBox.create()).selectQuickPick('Text File'); await new Promise((res) => { setTimeout(res, 1000); }); @@ -166,7 +175,8 @@ describe('TextEditor', function () { }); afterEach(async function() { - await new EditorView().closeEditor(param.file); + await editor.setCursor(1, 1); + await ew.closeEditor(param.file); }); [[2, 5], [3, 9]].forEach(coor => it(`move cursor to position [Ln ${coor[0]}, Col ${coor[1]}]`, async function () { @@ -240,7 +250,7 @@ describe('TextEditor', function () { }); }); - describe('find widget', function () { + describe.skip('find widget', function () { let widget: FindWidget; before(async function () { @@ -313,7 +323,7 @@ describe('TextEditor', function () { }); }); - describe('CodeLens', function () { + describe.skip('CodeLens', function () { before(async function () { await new Workbench().executeCommand('enable codelens');