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 d78c414
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
16 changes: 10 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 @@ -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;
Expand Down Expand Up @@ -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]}`);
Expand All @@ -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;
Expand Down Expand Up @@ -498,8 +504,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 +515,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
18 changes: 14 additions & 4 deletions tests/test-project/src/test/editor/textEditor.test.ts
Original file line number Diff line number Diff line change
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 Expand Up @@ -240,7 +250,7 @@ describe('TextEditor', function () {
});
});

describe('find widget', function () {
describe.skip('find widget', function () {
let widget: FindWidget;

before(async function () {
Expand Down Expand Up @@ -313,7 +323,7 @@ describe('TextEditor', function () {
});
});

describe('CodeLens', function () {
describe.skip('CodeLens', function () {

before(async function () {
await new Workbench().executeCommand('enable codelens');
Expand Down

0 comments on commit d78c414

Please sign in to comment.