@theia/playwright 1.77.0-next.1 → 1.77.0-next.108

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.
Files changed (46) hide show
  1. package/lib/tests/theia-app-loader.test.d.ts +2 -0
  2. package/lib/tests/theia-app-loader.test.d.ts.map +1 -0
  3. package/lib/tests/theia-app-loader.test.js +93 -0
  4. package/lib/tests/theia-app-loader.test.js.map +1 -0
  5. package/lib/tests/theia-application-shell.test.js +21 -1
  6. package/lib/tests/theia-application-shell.test.js.map +1 -1
  7. package/lib/tests/theia-explorer-view.test.js +2 -1
  8. package/lib/tests/theia-explorer-view.test.js.map +1 -1
  9. package/lib/tests/theia-notebook-editor.test.js +6 -5
  10. package/lib/tests/theia-notebook-editor.test.js.map +1 -1
  11. package/lib/tests/theia-quick-command.test.js +12 -0
  12. package/lib/tests/theia-quick-command.test.js.map +1 -1
  13. package/lib/tests/theia-terminal-view.test.js +2 -1
  14. package/lib/tests/theia-terminal-view.test.js.map +1 -1
  15. package/lib/tests/theia-text-editor.test.js +2 -1
  16. package/lib/tests/theia-text-editor.test.js.map +1 -1
  17. package/lib/tests/theia-toolbar.test.js +1 -0
  18. package/lib/tests/theia-toolbar.test.js.map +1 -1
  19. package/lib/tests/theia-workspace.test.js +2 -1
  20. package/lib/tests/theia-workspace.test.js.map +1 -1
  21. package/lib/theia-app-loader.d.ts +15 -1
  22. package/lib/theia-app-loader.d.ts.map +1 -1
  23. package/lib/theia-app-loader.js +23 -2
  24. package/lib/theia-app-loader.js.map +1 -1
  25. package/lib/theia-explorer-view.js +1 -1
  26. package/lib/theia-explorer-view.js.map +1 -1
  27. package/lib/theia-quick-command-palette.d.ts +8 -0
  28. package/lib/theia-quick-command-palette.d.ts.map +1 -1
  29. package/lib/theia-quick-command-palette.js +29 -12
  30. package/lib/theia-quick-command-palette.js.map +1 -1
  31. package/lib/theia-workspace.js +2 -1
  32. package/lib/theia-workspace.js.map +1 -1
  33. package/lib/util.d.ts +1 -0
  34. package/lib/util.d.ts.map +1 -1
  35. package/lib/util.js +6 -2
  36. package/lib/util.js.map +1 -1
  37. package/package.json +6 -6
  38. package/src/tests/theia-app-loader.test.ts +103 -0
  39. package/src/tests/theia-application-shell.test.ts +26 -1
  40. package/src/tests/theia-notebook-editor.test.ts +4 -4
  41. package/src/tests/theia-quick-command.test.ts +14 -0
  42. package/src/tests/theia-toolbar.test.ts +1 -0
  43. package/src/theia-app-loader.ts +30 -3
  44. package/src/theia-explorer-view.ts +2 -2
  45. package/src/theia-quick-command-palette.ts +33 -12
  46. package/src/util.ts +6 -2
@@ -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, expect } from '@playwright/test';
18
18
  import { TheiaPageObject } from './theia-page-object';
19
19
  import { OSUtil, USER_KEY_TYPING_DELAY } from './util';
20
20
 
@@ -32,36 +32,57 @@ export class TheiaQuickCommandPalette extends TheiaPageObject {
32
32
  await this.page.waitForSelector(this.selector, { state: 'hidden' });
33
33
  }
34
34
 
35
+ async waitForVisible(): Promise<void> {
36
+ await this.page.waitForSelector(this.selector, { state: 'visible' });
37
+ }
38
+
35
39
  async isOpen(): Promise<boolean> {
36
- try {
37
- await this.page.waitForSelector(this.selector, { timeout: 5000 });
38
- } catch (err) {
39
- return false;
40
- }
41
- return true;
40
+ return this.page.locator(this.selector).isVisible();
42
41
  }
43
42
 
43
+ /**
44
+ * Triggers one or more commands sequentially.
45
+ * When passing multiple command names, subsequent commands expect the previous command
46
+ * to have opened a sub-quick-pick (e.g. `View: Open View...`).
47
+ *
48
+ * @param commandName The command name(s) to trigger.
49
+ */
44
50
  async trigger(...commandName: string[]): Promise<void> {
45
- for (const command of commandName) {
46
- await this.triggerSingleCommand(command);
51
+ for (let i = 0; i < commandName.length; i++) {
52
+ await this.triggerSingleCommand(commandName[i]);
53
+ if (i < commandName.length - 1) {
54
+ await this.page.waitForSelector(this.selector, { state: 'visible' });
55
+ }
47
56
  }
48
57
  }
49
58
 
50
59
  protected async triggerSingleCommand(commandName: string): Promise<void> {
51
60
  if (!await this.isOpen()) {
52
- this.open();
61
+ await this.open();
62
+ }
63
+ const input = this.page.locator(`${this.selector} .monaco-inputbox .input`);
64
+ const query = (await input.inputValue()).replace(/^(>|view\s+)/, '').trim();
65
+ const hasMatchingFilter = query.length > 0 && commandName.toLowerCase().includes(query.toLowerCase());
66
+
67
+ if (!hasMatchingFilter) {
68
+ await this.type(commandName);
53
69
  }
70
+
54
71
  let selected = await this.selectedCommand();
55
- while (!(await selected?.innerText() === commandName)) {
72
+ let attempts = 0;
73
+ while (selected && await selected.innerText() !== commandName && attempts < 10) {
56
74
  await this.page.keyboard.press('ArrowDown');
57
75
  selected = await this.selectedCommand();
76
+ attempts++;
58
77
  }
78
+
79
+ await expect(this.page.locator(`${this.selector} .monaco-list-row.focused .monaco-highlighted-label`).first()).toHaveText(commandName, { timeout: 5000 });
59
80
  await this.page.keyboard.press('Enter');
60
81
  }
61
82
 
62
83
  async type(value: string, confirm = false): Promise<void> {
63
84
  if (!await this.isOpen()) {
64
- this.open();
85
+ await this.open();
65
86
  }
66
87
  const input = this.page.locator(`${this.selector} .monaco-inputbox .input`);
67
88
  await input.focus();
package/src/util.ts CHANGED
@@ -21,8 +21,12 @@ import { sep } from 'path';
21
21
  export const USER_KEY_TYPING_DELAY = 80;
22
22
 
23
23
  export function normalizeId(nodeId: string): string {
24
- // Special characters (i.e. in our case '.',':','/','%', and '\\') in CSS IDs have to be escaped
25
- return nodeId.replace(/[.:,%/\\]/g, matchedChar => '\\' + matchedChar);
24
+ // Special characters (i.e. in our case '.',':','/','%', '\\' and '~') in CSS IDs have to be escaped
25
+ return nodeId.replace(/[.:,%/\\~]/g, matchedChar => '\\' + matchedChar);
26
+ }
27
+
28
+ export function escapeDoubleQuotes(nodeId: string): string {
29
+ return nodeId.replace(/["\\]/g, matchedChar => '\\' + matchedChar);
26
30
  }
27
31
 
28
32
  export async function toTextContentArray(items: ElementHandle<SVGElement | HTMLElement>[]): Promise<string[]> {