Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
Signed-off-by: Dominik Jelinek <[email protected]>
  • Loading branch information
djelinek committed Apr 10, 2024
1 parent 4898c2f commit 9eef75f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
12 changes: 6 additions & 6 deletions packages/page-objects/src/components/editor/TextEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -389,6 +389,7 @@ export class TextEditor extends Editor {
await this.waitForCursorPositionAtLine(nextLine);
} catch (error) {
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;
Expand Down Expand Up @@ -418,7 +419,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]}`);
Expand All @@ -437,6 +438,7 @@ export class TextEditor extends Editor {
await this.waitForCursorPositionAtColumn(nextCol);
} catch (error) {
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;
Expand Down Expand Up @@ -498,8 +500,7 @@ export class TextEditor extends Editor {
*/
private async waitForCursorPositionAtLine(line: number, timeout: number = 1_500): Promise<boolean> {
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}`);
}

Expand All @@ -510,8 +511,7 @@ export class TextEditor extends Editor {
*/
private async waitForCursorPositionAtColumn(column: number, timeout: number = 1_500): Promise<boolean> {
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}`);
}

Expand Down
16 changes: 13 additions & 3 deletions tests/test-project/src/test/editor/textEditor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as path from 'path';
import { expect } from 'chai';
import { TextEditor, EditorView, StatusBar, InputBox, ContentAssist, Workbench, FindWidget, VSBrowser, after, before, afterEach, beforeEach } from "vscode-extension-tester";

describe('ContentAssist', async function () {
describe.only('ContentAssist', async function () {
let assist: ContentAssist;
let editor: TextEditor;

Expand Down Expand Up @@ -65,14 +65,23 @@ describe('ContentAssist', async function () {
}).timeout(15000);
});

describe('TextEditor', function () {
describe.only('TextEditor', function () {
let editor: TextEditor;
let view: EditorView;

const testText = process.platform === 'win32' ? `line1\r\nline2\r\nline3` : `line1\nline2\nline3`;

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); });
Expand Down Expand Up @@ -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 () {
Expand Down

0 comments on commit 9eef75f

Please sign in to comment.