@theia/playwright 1.34.3 → 1.34.4

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 (124) hide show
  1. package/LICENSE +641 -641
  2. package/README.md +54 -54
  3. package/lib/index.d.ts +25 -25
  4. package/lib/index.js +52 -52
  5. package/lib/tests/fixtures/theia-fixture.d.ts +3 -3
  6. package/lib/tests/fixtures/theia-fixture.js +23 -23
  7. package/lib/tests/theia-app.test.d.ts +1 -1
  8. package/lib/tests/theia-app.test.js +29 -29
  9. package/lib/tests/theia-explorer-view.test.d.ts +1 -1
  10. package/lib/tests/theia-explorer-view.test.js +109 -109
  11. package/lib/tests/theia-main-menu.test.d.ts +1 -1
  12. package/lib/tests/theia-main-menu.test.js +73 -73
  13. package/lib/tests/theia-preference-view.test.d.ts +1 -1
  14. package/lib/tests/theia-preference-view.test.js +99 -99
  15. package/lib/tests/theia-problems-view.test.d.ts +1 -1
  16. package/lib/tests/theia-problems-view.test.js +52 -52
  17. package/lib/tests/theia-quick-command.test.d.ts +1 -1
  18. package/lib/tests/theia-quick-command.test.js +53 -53
  19. package/lib/tests/theia-sample-app.test.d.ts +1 -1
  20. package/lib/tests/theia-sample-app.test.js +80 -80
  21. package/lib/tests/theia-status-bar.test.d.ts +1 -1
  22. package/lib/tests/theia-status-bar.test.js +41 -41
  23. package/lib/tests/theia-text-editor.test.d.ts +1 -1
  24. package/lib/tests/theia-text-editor.test.js +152 -152
  25. package/lib/tests/theia-workspace.test.d.ts +1 -1
  26. package/lib/tests/theia-workspace.test.js +47 -47
  27. package/lib/theia-about-dialog.d.ts +4 -4
  28. package/lib/theia-about-dialog.js +26 -26
  29. package/lib/theia-app.d.ts +43 -43
  30. package/lib/theia-app.js +135 -135
  31. package/lib/theia-context-menu.d.ts +8 -8
  32. package/lib/theia-context-menu.js +37 -37
  33. package/lib/theia-dialog.d.ts +27 -27
  34. package/lib/theia-dialog.js +98 -98
  35. package/lib/theia-editor.d.ts +9 -9
  36. package/lib/theia-editor.js +68 -68
  37. package/lib/theia-explorer-view.d.ts +38 -38
  38. package/lib/theia-explorer-view.js +209 -209
  39. package/lib/theia-main-menu.d.ts +12 -12
  40. package/lib/theia-main-menu.js +53 -53
  41. package/lib/theia-menu-item.d.ts +14 -14
  42. package/lib/theia-menu-item.js +66 -66
  43. package/lib/theia-menu.d.ts +16 -16
  44. package/lib/theia-menu.js +86 -86
  45. package/lib/theia-notification-indicator.d.ts +7 -7
  46. package/lib/theia-notification-indicator.js +44 -44
  47. package/lib/theia-notification-overlay.d.ts +22 -22
  48. package/lib/theia-notification-overlay.js +79 -79
  49. package/lib/theia-page-object.d.ts +7 -7
  50. package/lib/theia-page-object.js +27 -27
  51. package/lib/theia-preference-view.d.ts +76 -76
  52. package/lib/theia-preference-view.js +201 -201
  53. package/lib/theia-problem-indicator.d.ts +8 -8
  54. package/lib/theia-problem-indicator.js +38 -38
  55. package/lib/theia-problem-view.d.ts +5 -5
  56. package/lib/theia-problem-view.js +30 -30
  57. package/lib/theia-quick-command-palette.d.ts +11 -11
  58. package/lib/theia-quick-command-palette.js +73 -73
  59. package/lib/theia-rename-dialog.d.ts +5 -5
  60. package/lib/theia-rename-dialog.js +35 -35
  61. package/lib/theia-status-bar.d.ts +13 -13
  62. package/lib/theia-status-bar.js +39 -39
  63. package/lib/theia-status-indicator.d.ts +10 -10
  64. package/lib/theia-status-indicator.js +48 -48
  65. package/lib/theia-text-editor.d.ts +27 -27
  66. package/lib/theia-text-editor.js +149 -149
  67. package/lib/theia-toggle-bottom-indicator.d.ts +4 -4
  68. package/lib/theia-toggle-bottom-indicator.js +26 -26
  69. package/lib/theia-tree-node.d.ts +16 -16
  70. package/lib/theia-tree-node.js +53 -53
  71. package/lib/theia-view.d.ts +32 -32
  72. package/lib/theia-view.js +151 -151
  73. package/lib/theia-workspace.d.ts +18 -18
  74. package/lib/theia-workspace.js +69 -69
  75. package/lib/util.d.ts +19 -19
  76. package/lib/util.js +93 -93
  77. package/package.json +2 -2
  78. package/src/index.ts +41 -41
  79. package/src/tests/fixtures/theia-fixture.ts +25 -25
  80. package/src/tests/resources/sample-files1/sample.txt +4 -4
  81. package/src/tests/resources/sample-files1/sampleFolder/sampleFolder1/sampleFolder1-1/sampleFile1-1-1.txt +1 -1
  82. package/src/tests/resources/sample-files1/sampleFolder/sampleFolder1/sampleFolder1-1/sampleFile1-1-2.txt +1 -1
  83. package/src/tests/resources/sample-files1/sampleFolder/sampleFolder1/sampleFolder1-2/sampleFile1-2-1.txt +1 -1
  84. package/src/tests/resources/sample-files1/sampleFolder/sampleFolder1/sampleFolder1-2/sampleFile1-2-2.txt +1 -1
  85. package/src/tests/resources/sample-files1/sampleFolder/sampleFolder2/sampleFolder2-1/sampleFile2-1-1.txt +1 -1
  86. package/src/tests/resources/sample-files1/sampleFolder/sampleFolder2/sampleFolder2-1/sampleFile2-1-2.txt +1 -1
  87. package/src/tests/resources/sample-files1/sampleFolder/sampleFolder2/sampleFolder2-2/sampleFile2-2-1.txt +1 -1
  88. package/src/tests/resources/sample-files1/sampleFolder/sampleFolder2/sampleFolder2-2/sampleFile2-2-2.txt +1 -1
  89. package/src/tests/resources/sample-files2/another-sample.txt +1 -1
  90. package/src/tests/theia-app.test.ts +34 -34
  91. package/src/tests/theia-explorer-view.test.ts +124 -124
  92. package/src/tests/theia-main-menu.test.ts +89 -89
  93. package/src/tests/theia-preference-view.test.ts +118 -118
  94. package/src/tests/theia-problems-view.test.ts +60 -60
  95. package/src/tests/theia-quick-command.test.ts +61 -61
  96. package/src/tests/theia-sample-app.test.ts +92 -92
  97. package/src/tests/theia-status-bar.test.ts +47 -47
  98. package/src/tests/theia-text-editor.test.ts +182 -182
  99. package/src/tests/theia-workspace.test.ts +51 -51
  100. package/src/theia-about-dialog.ts +26 -26
  101. package/src/theia-app.ts +154 -154
  102. package/src/theia-context-menu.ts +42 -42
  103. package/src/theia-dialog.ts +113 -113
  104. package/src/theia-editor.ts +73 -73
  105. package/src/theia-explorer-view.ts +234 -234
  106. package/src/theia-main-menu.ts +54 -54
  107. package/src/theia-menu-item.ts +75 -75
  108. package/src/theia-menu.ts +96 -96
  109. package/src/theia-notification-indicator.ts +44 -44
  110. package/src/theia-notification-overlay.ts +94 -94
  111. package/src/theia-page-object.ts +29 -29
  112. package/src/theia-preference-view.ts +232 -232
  113. package/src/theia-problem-indicator.ts +37 -37
  114. package/src/theia-problem-view.ts +30 -30
  115. package/src/theia-quick-command-palette.ts +75 -75
  116. package/src/theia-rename-dialog.ts +36 -36
  117. package/src/theia-status-bar.ts +44 -44
  118. package/src/theia-status-indicator.ts +50 -50
  119. package/src/theia-text-editor.ts +172 -172
  120. package/src/theia-toggle-bottom-indicator.ts +21 -21
  121. package/src/theia-tree-node.ts +60 -60
  122. package/src/theia-view.ts +178 -178
  123. package/src/theia-workspace.ts +76 -76
  124. package/src/util.ts +91 -91
@@ -1,124 +1,124 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2021 logi.cals GmbH, EclipseSource and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { expect } from '@playwright/test';
18
- import { TheiaApp } from '../theia-app';
19
- import { DOT_FILES_FILTER, TheiaExplorerView } from '../theia-explorer-view';
20
- import { TheiaWorkspace } from '../theia-workspace';
21
- import test, { page } from './fixtures/theia-fixture';
22
-
23
- let app: TheiaApp;
24
- let explorer: TheiaExplorerView;
25
-
26
- test.describe('Theia Explorer View', () => {
27
-
28
- test.beforeAll(async () => {
29
- const ws = new TheiaWorkspace(['src/tests/resources/sample-files1']);
30
- app = await TheiaApp.load(page, ws);
31
- explorer = await app.openView(TheiaExplorerView);
32
- });
33
-
34
- test('should be visible and active after being opened', async () => {
35
- expect(await explorer.isTabVisible()).toBe(true);
36
- expect(await explorer.isDisplayed()).toBe(true);
37
- expect(await explorer.isActive()).toBe(true);
38
- });
39
-
40
- test("should be opened at the left and have the title 'Explorer'", async () => {
41
- expect(await explorer.isInSidePanel()).toBe(true);
42
- expect(await explorer.side()).toBe('left');
43
- expect(await explorer.title()).toBe('Explorer');
44
- });
45
-
46
- test('should be possible to close and reopen it', async () => {
47
- await explorer.close();
48
- expect(await explorer.isTabVisible()).toBe(false);
49
-
50
- explorer = await app.openView(TheiaExplorerView);
51
- expect(await explorer.isTabVisible()).toBe(true);
52
- expect(await explorer.isDisplayed()).toBe(true);
53
- expect(await explorer.isActive()).toBe(true);
54
- });
55
-
56
- test('should show one folder named "sampleFolder" and one file named "sample.txt"', async () => {
57
- await explorer.selectTreeNode('sampleFolder');
58
- expect(await explorer.isTreeNodeSelected('sampleFolder')).toBe(true);
59
- const fileStatElements = await explorer.visibleFileStatNodes(DOT_FILES_FILTER);
60
- expect(fileStatElements.length).toBe(2);
61
-
62
- let file; let folder;
63
- if (await fileStatElements[0].isFolder()) {
64
- folder = fileStatElements[0];
65
- file = fileStatElements[1];
66
- } else {
67
- folder = fileStatElements[1];
68
- file = fileStatElements[0];
69
- }
70
-
71
- expect(await folder.label()).toBe('sampleFolder');
72
- expect(await folder.isFile()).toBe(false);
73
- expect(await folder.isFolder()).toBe(true);
74
- expect(await file.label()).toBe('sample.txt');
75
- expect(await file.isFolder()).toBe(false);
76
- expect(await file.isFile()).toBe(true);
77
- });
78
-
79
- test('should provide file stat node by single path fragment "sample.txt"', async () => {
80
- const file = await explorer.getFileStatNodeByLabel('sample.txt');
81
- expect(await file.label()).toBe('sample.txt');
82
- expect(await file.isFolder()).toBe(false);
83
- expect(await file.isFile()).toBe(true);
84
- });
85
-
86
- test('should provide file stat nodes that can define whether they are collapsed or not and that can be expanded', async () => {
87
- const file = await explorer.getFileStatNodeByLabel('sample.txt');
88
- expect(await file.isCollapsed()).toBe(false);
89
-
90
- const folder = await explorer.getFileStatNodeByLabel('sampleFolder');
91
- expect(await folder.isCollapsed()).toBe(true);
92
-
93
- await folder.expand();
94
- expect(await folder.isCollapsed()).toBe(false);
95
- });
96
-
97
- test('should provide file stat node by path "sampleFolder/sampleFolder1/sampleFolder1-1/sampleFile1-1-1.txt"', async () => {
98
- const file = await explorer.fileStatNode('sampleFolder/sampleFolder1/sampleFolder1-1/sampleFile1-1-1.txt');
99
- if (!file) { throw Error('File stat node could not be retrieved by path'); }
100
- expect(await file.label()).toBe('sampleFile1-1-1.txt');
101
- });
102
-
103
- test('should open context menu on "sample.txt"', async () => {
104
- const file = await explorer.getFileStatNodeByLabel('sample.txt');
105
- const menu = await file.openContextMenu();
106
- expect(await menu.isOpen()).toBe(true);
107
-
108
- const menuItems = await menu.visibleMenuItems();
109
- expect(menuItems).toContain('Open');
110
- expect(menuItems).toContain('Delete');
111
- expect(menuItems).toContain('Download');
112
-
113
- await menu.close();
114
- expect(await menu.isOpen()).toBe(false);
115
- });
116
-
117
- test('should rename "sample.txt"', async () => {
118
- await explorer.renameNode('sample.txt', 'sample-new.txt');
119
- expect(await explorer.existsFileNode('sample-new.txt')).toBe(true);
120
- await explorer.renameNode('sample-new.txt', 'sample.txt');
121
- expect(await explorer.existsFileNode('sample.txt')).toBe(true);
122
- });
123
-
124
- });
1
+ // *****************************************************************************
2
+ // Copyright (C) 2021 logi.cals GmbH, EclipseSource and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { expect } from '@playwright/test';
18
+ import { TheiaApp } from '../theia-app';
19
+ import { DOT_FILES_FILTER, TheiaExplorerView } from '../theia-explorer-view';
20
+ import { TheiaWorkspace } from '../theia-workspace';
21
+ import test, { page } from './fixtures/theia-fixture';
22
+
23
+ let app: TheiaApp;
24
+ let explorer: TheiaExplorerView;
25
+
26
+ test.describe('Theia Explorer View', () => {
27
+
28
+ test.beforeAll(async () => {
29
+ const ws = new TheiaWorkspace(['src/tests/resources/sample-files1']);
30
+ app = await TheiaApp.load(page, ws);
31
+ explorer = await app.openView(TheiaExplorerView);
32
+ });
33
+
34
+ test('should be visible and active after being opened', async () => {
35
+ expect(await explorer.isTabVisible()).toBe(true);
36
+ expect(await explorer.isDisplayed()).toBe(true);
37
+ expect(await explorer.isActive()).toBe(true);
38
+ });
39
+
40
+ test("should be opened at the left and have the title 'Explorer'", async () => {
41
+ expect(await explorer.isInSidePanel()).toBe(true);
42
+ expect(await explorer.side()).toBe('left');
43
+ expect(await explorer.title()).toBe('Explorer');
44
+ });
45
+
46
+ test('should be possible to close and reopen it', async () => {
47
+ await explorer.close();
48
+ expect(await explorer.isTabVisible()).toBe(false);
49
+
50
+ explorer = await app.openView(TheiaExplorerView);
51
+ expect(await explorer.isTabVisible()).toBe(true);
52
+ expect(await explorer.isDisplayed()).toBe(true);
53
+ expect(await explorer.isActive()).toBe(true);
54
+ });
55
+
56
+ test('should show one folder named "sampleFolder" and one file named "sample.txt"', async () => {
57
+ await explorer.selectTreeNode('sampleFolder');
58
+ expect(await explorer.isTreeNodeSelected('sampleFolder')).toBe(true);
59
+ const fileStatElements = await explorer.visibleFileStatNodes(DOT_FILES_FILTER);
60
+ expect(fileStatElements.length).toBe(2);
61
+
62
+ let file; let folder;
63
+ if (await fileStatElements[0].isFolder()) {
64
+ folder = fileStatElements[0];
65
+ file = fileStatElements[1];
66
+ } else {
67
+ folder = fileStatElements[1];
68
+ file = fileStatElements[0];
69
+ }
70
+
71
+ expect(await folder.label()).toBe('sampleFolder');
72
+ expect(await folder.isFile()).toBe(false);
73
+ expect(await folder.isFolder()).toBe(true);
74
+ expect(await file.label()).toBe('sample.txt');
75
+ expect(await file.isFolder()).toBe(false);
76
+ expect(await file.isFile()).toBe(true);
77
+ });
78
+
79
+ test('should provide file stat node by single path fragment "sample.txt"', async () => {
80
+ const file = await explorer.getFileStatNodeByLabel('sample.txt');
81
+ expect(await file.label()).toBe('sample.txt');
82
+ expect(await file.isFolder()).toBe(false);
83
+ expect(await file.isFile()).toBe(true);
84
+ });
85
+
86
+ test('should provide file stat nodes that can define whether they are collapsed or not and that can be expanded', async () => {
87
+ const file = await explorer.getFileStatNodeByLabel('sample.txt');
88
+ expect(await file.isCollapsed()).toBe(false);
89
+
90
+ const folder = await explorer.getFileStatNodeByLabel('sampleFolder');
91
+ expect(await folder.isCollapsed()).toBe(true);
92
+
93
+ await folder.expand();
94
+ expect(await folder.isCollapsed()).toBe(false);
95
+ });
96
+
97
+ test('should provide file stat node by path "sampleFolder/sampleFolder1/sampleFolder1-1/sampleFile1-1-1.txt"', async () => {
98
+ const file = await explorer.fileStatNode('sampleFolder/sampleFolder1/sampleFolder1-1/sampleFile1-1-1.txt');
99
+ if (!file) { throw Error('File stat node could not be retrieved by path'); }
100
+ expect(await file.label()).toBe('sampleFile1-1-1.txt');
101
+ });
102
+
103
+ test('should open context menu on "sample.txt"', async () => {
104
+ const file = await explorer.getFileStatNodeByLabel('sample.txt');
105
+ const menu = await file.openContextMenu();
106
+ expect(await menu.isOpen()).toBe(true);
107
+
108
+ const menuItems = await menu.visibleMenuItems();
109
+ expect(menuItems).toContain('Open');
110
+ expect(menuItems).toContain('Delete');
111
+ expect(menuItems).toContain('Download');
112
+
113
+ await menu.close();
114
+ expect(await menu.isOpen()).toBe(false);
115
+ });
116
+
117
+ test('should rename "sample.txt"', async () => {
118
+ await explorer.renameNode('sample.txt', 'sample-new.txt');
119
+ expect(await explorer.existsFileNode('sample-new.txt')).toBe(true);
120
+ await explorer.renameNode('sample-new.txt', 'sample.txt');
121
+ expect(await explorer.existsFileNode('sample.txt')).toBe(true);
122
+ });
123
+
124
+ });
@@ -1,89 +1,89 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2021 logi.cals GmbH, EclipseSource and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { expect } from '@playwright/test';
18
- import { OSUtil } from '../util';
19
- import { TheiaApp } from '../theia-app';
20
- import { TheiaMenuBar } from '../theia-main-menu';
21
- import test, { page } from './fixtures/theia-fixture';
22
-
23
- let menuBar: TheiaMenuBar;
24
-
25
- test.describe('Theia Main Menu', () => {
26
-
27
- test.beforeAll(async () => {
28
- const app = await TheiaApp.load(page);
29
- menuBar = app.menuBar;
30
- });
31
-
32
- test('should show the main menu bar', async () => {
33
- const menuBarItems = await menuBar.visibleMenuBarItems();
34
- expect(menuBarItems).toContain('File');
35
- expect(menuBarItems).toContain('Edit');
36
- expect(menuBarItems).toContain('Help');
37
- });
38
-
39
- test("should open main menu 'File'", async () => {
40
- const mainMenu = await menuBar.openMenu('File');
41
- expect(await mainMenu.isOpen()).toBe(true);
42
- });
43
-
44
- test("should show the menu items 'New File' and 'New Folder'", async () => {
45
- const mainMenu = await menuBar.openMenu('File');
46
- const menuItems = await mainMenu.visibleMenuItems();
47
- expect(menuItems).toContain('New File');
48
- expect(menuItems).toContain('New Folder');
49
- });
50
-
51
- test("should return menu item by name 'New File'", async () => {
52
- const mainMenu = await menuBar.openMenu('File');
53
- const menuItem = await mainMenu.menuItemByName('New File');
54
- expect(menuItem).toBeDefined();
55
-
56
- const label = await menuItem?.label();
57
- expect(label).toBe('New File');
58
-
59
- const shortCut = await menuItem?.shortCut();
60
- expect(shortCut).toBe(OSUtil.isMacOS ? '⌥ N' : 'Alt+N');
61
-
62
- const hasSubmenu = await menuItem?.hasSubmenu();
63
- expect(hasSubmenu).toBe(false);
64
- });
65
-
66
- test('should detect whether menu item has submenu', async () => {
67
- const mainMenu = await menuBar.openMenu('File');
68
- const newFileItem = await mainMenu.menuItemByName('New File');
69
- const settingsItem = await mainMenu.menuItemByName('Preferences');
70
-
71
- expect(await newFileItem?.hasSubmenu()).toBe(false);
72
- expect(await settingsItem?.hasSubmenu()).toBe(true);
73
- });
74
-
75
- test('should be able to show menu item in submenu by path', async () => {
76
- const mainMenu = await menuBar.openMenu('File');
77
- const openPreferencesItem = await mainMenu.menuItemByNamePath('Preferences', 'Open Settings (UI)');
78
-
79
- const label = await openPreferencesItem?.label();
80
- expect(label).toBe('Open Settings (UI)');
81
- });
82
-
83
- test('should close main menu', async () => {
84
- const mainMenu = await menuBar.openMenu('File');
85
- await mainMenu.close();
86
- expect(await mainMenu.isOpen()).toBe(false);
87
- });
88
-
89
- });
1
+ // *****************************************************************************
2
+ // Copyright (C) 2021 logi.cals GmbH, EclipseSource and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { expect } from '@playwright/test';
18
+ import { OSUtil } from '../util';
19
+ import { TheiaApp } from '../theia-app';
20
+ import { TheiaMenuBar } from '../theia-main-menu';
21
+ import test, { page } from './fixtures/theia-fixture';
22
+
23
+ let menuBar: TheiaMenuBar;
24
+
25
+ test.describe('Theia Main Menu', () => {
26
+
27
+ test.beforeAll(async () => {
28
+ const app = await TheiaApp.load(page);
29
+ menuBar = app.menuBar;
30
+ });
31
+
32
+ test('should show the main menu bar', async () => {
33
+ const menuBarItems = await menuBar.visibleMenuBarItems();
34
+ expect(menuBarItems).toContain('File');
35
+ expect(menuBarItems).toContain('Edit');
36
+ expect(menuBarItems).toContain('Help');
37
+ });
38
+
39
+ test("should open main menu 'File'", async () => {
40
+ const mainMenu = await menuBar.openMenu('File');
41
+ expect(await mainMenu.isOpen()).toBe(true);
42
+ });
43
+
44
+ test("should show the menu items 'New File' and 'New Folder'", async () => {
45
+ const mainMenu = await menuBar.openMenu('File');
46
+ const menuItems = await mainMenu.visibleMenuItems();
47
+ expect(menuItems).toContain('New File');
48
+ expect(menuItems).toContain('New Folder');
49
+ });
50
+
51
+ test("should return menu item by name 'New File'", async () => {
52
+ const mainMenu = await menuBar.openMenu('File');
53
+ const menuItem = await mainMenu.menuItemByName('New File');
54
+ expect(menuItem).toBeDefined();
55
+
56
+ const label = await menuItem?.label();
57
+ expect(label).toBe('New File');
58
+
59
+ const shortCut = await menuItem?.shortCut();
60
+ expect(shortCut).toBe(OSUtil.isMacOS ? '⌥ N' : 'Alt+N');
61
+
62
+ const hasSubmenu = await menuItem?.hasSubmenu();
63
+ expect(hasSubmenu).toBe(false);
64
+ });
65
+
66
+ test('should detect whether menu item has submenu', async () => {
67
+ const mainMenu = await menuBar.openMenu('File');
68
+ const newFileItem = await mainMenu.menuItemByName('New File');
69
+ const settingsItem = await mainMenu.menuItemByName('Preferences');
70
+
71
+ expect(await newFileItem?.hasSubmenu()).toBe(false);
72
+ expect(await settingsItem?.hasSubmenu()).toBe(true);
73
+ });
74
+
75
+ test('should be able to show menu item in submenu by path', async () => {
76
+ const mainMenu = await menuBar.openMenu('File');
77
+ const openPreferencesItem = await mainMenu.menuItemByNamePath('Preferences', 'Open Settings (UI)');
78
+
79
+ const label = await openPreferencesItem?.label();
80
+ expect(label).toBe('Open Settings (UI)');
81
+ });
82
+
83
+ test('should close main menu', async () => {
84
+ const mainMenu = await menuBar.openMenu('File');
85
+ await mainMenu.close();
86
+ expect(await mainMenu.isOpen()).toBe(false);
87
+ });
88
+
89
+ });