@theia/playwright 1.62.0-next.3 → 1.62.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,7 +14,7 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
- import { ElementHandle } from '@playwright/test';
17
+ import { ElementHandle, Locator } from '@playwright/test';
18
18
  import { join } from 'path';
19
19
 
20
20
  import { TheiaApp } from './theia-app';
@@ -33,7 +33,7 @@ export class TheiaTextEditor extends TheiaEditor {
33
33
  tabSelector: normalizeId(`#shell-tab-code-editor-opener:file://${urlEncodePath(join(app.workspace.escapedPath, OSUtil.fileSeparator, filePath))}:1`),
34
34
  viewSelector: normalizeId(`#code-editor-opener:file://${urlEncodePath(join(app.workspace.escapedPath, OSUtil.fileSeparator, filePath))}:1`) + '.theia-editor'
35
35
  }, app);
36
- this.monacoEditor = new TheiaMonacoEditor(this.viewSelector, app);
36
+ this.monacoEditor = new TheiaMonacoEditor(this.page.locator(this.data.viewSelector), app);
37
37
  }
38
38
 
39
39
  async numberOfLines(): Promise<number | undefined> {
@@ -57,16 +57,16 @@ export class TheiaTextEditor extends TheiaEditor {
57
57
 
58
58
  async selectLineWithLineNumber(lineNumber: number): Promise<ElementHandle<SVGElement | HTMLElement> | undefined> {
59
59
  await this.activate();
60
- const lineElement = await this.monacoEditor.lineByLineNumber(lineNumber);
60
+ const lineElement = await this.monacoEditor.line(lineNumber);
61
61
  await this.selectLine(lineElement);
62
- return lineElement;
62
+ return await lineElement.elementHandle() ?? undefined;
63
63
  }
64
64
 
65
65
  async placeCursorInLineWithLineNumber(lineNumber: number): Promise<ElementHandle<SVGElement | HTMLElement> | undefined> {
66
66
  await this.activate();
67
- const lineElement = await this.monacoEditor.lineByLineNumber(lineNumber);
67
+ const lineElement = await this.monacoEditor.line(lineNumber);
68
68
  await this.placeCursorInLine(lineElement);
69
- return lineElement;
69
+ return await lineElement.elementHandle() ?? undefined;
70
70
  }
71
71
 
72
72
  async deleteLineByLineNumber(lineNumber: number): Promise<void> {
@@ -86,16 +86,16 @@ export class TheiaTextEditor extends TheiaEditor {
86
86
 
87
87
  async selectLineContainingText(text: string): Promise<ElementHandle<SVGElement | HTMLElement> | undefined> {
88
88
  await this.activate();
89
- const lineElement = await this.monacoEditor.lineContainingText(text);
89
+ const lineElement = await this.monacoEditor.lineWithText(text);
90
90
  await this.selectLine(lineElement);
91
- return lineElement;
91
+ return await lineElement?.elementHandle() ?? undefined;
92
92
  }
93
93
 
94
94
  async placeCursorInLineContainingText(text: string): Promise<ElementHandle<SVGElement | HTMLElement> | undefined> {
95
95
  await this.activate();
96
- const lineElement = await this.monacoEditor.lineContainingText(text);
96
+ const lineElement = await this.monacoEditor.lineWithText(text);
97
97
  await this.placeCursorInLine(lineElement);
98
- return lineElement;
98
+ return await lineElement?.elementHandle() ?? undefined;
99
99
  }
100
100
 
101
101
  async deleteLineContainingText(text: string): Promise<void> {
@@ -104,7 +104,7 @@ export class TheiaTextEditor extends TheiaEditor {
104
104
  }
105
105
 
106
106
  async addTextToNewLineAfterLineContainingText(textContainedByExistingLine: string, newText: string): Promise<void> {
107
- const existingLine = await this.monacoEditor.lineContainingText(textContainedByExistingLine);
107
+ const existingLine = await this.monacoEditor.lineWithText(textContainedByExistingLine);
108
108
  await this.placeCursorInLine(existingLine);
109
109
  await this.page.keyboard.press('End');
110
110
  await this.page.keyboard.press('Enter');
@@ -112,19 +112,19 @@ export class TheiaTextEditor extends TheiaEditor {
112
112
  }
113
113
 
114
114
  async addTextToNewLineAfterLineByLineNumber(lineNumber: number, newText: string): Promise<void> {
115
- const existingLine = await this.monacoEditor.lineByLineNumber(lineNumber);
115
+ const existingLine = await this.monacoEditor.line(lineNumber);
116
116
  await this.placeCursorInLine(existingLine);
117
117
  await this.page.keyboard.press('End');
118
118
  await this.page.keyboard.press('Enter');
119
119
  await this.page.keyboard.type(newText);
120
120
  }
121
121
 
122
- protected async selectLine(lineElement: ElementHandle<SVGElement | HTMLElement> | undefined): Promise<void> {
123
- await lineElement?.click({ clickCount: 3 });
122
+ protected async selectLine(lineLocator: Locator | undefined): Promise<void> {
123
+ await lineLocator?.click({ clickCount: 3 });
124
124
  }
125
125
 
126
- protected async placeCursorInLine(lineElement: ElementHandle<SVGElement | HTMLElement> | undefined): Promise<void> {
127
- await lineElement?.click();
126
+ protected async placeCursorInLine(lineLocator: Locator | undefined): Promise<void> {
127
+ await lineLocator?.click();
128
128
  }
129
129
 
130
130
  protected async selectedSuggestion(): Promise<ElementHandle<SVGElement | HTMLElement>> {
@@ -28,7 +28,8 @@ export class TheiaToolbarItem extends TheiaPageObject {
28
28
  }
29
29
 
30
30
  async isEnabled(): Promise<boolean> {
31
- const classAttribute = await this.element.getAttribute('class');
31
+ const child = await this.element.$(':first-child');
32
+ const classAttribute = child && await child.getAttribute('class');
32
33
  if (classAttribute === undefined || classAttribute === null) {
33
34
  return false;
34
35
  }