@theia/playwright 1.25.0-next.7 → 1.25.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.
Files changed (173) hide show
  1. package/lib/index.d.ts +26 -0
  2. package/lib/index.d.ts.map +1 -0
  3. package/lib/index.js +53 -0
  4. package/lib/index.js.map +1 -0
  5. package/lib/tests/fixtures/theia-fixture.d.ts +4 -0
  6. package/lib/tests/fixtures/theia-fixture.d.ts.map +1 -0
  7. package/lib/tests/fixtures/theia-fixture.js +24 -0
  8. package/lib/tests/fixtures/theia-fixture.js.map +1 -0
  9. package/lib/tests/theia-app.test.d.ts +2 -0
  10. package/lib/tests/theia-app.test.d.ts.map +1 -0
  11. package/lib/tests/theia-app.test.js +30 -0
  12. package/lib/tests/theia-app.test.js.map +1 -0
  13. package/lib/tests/theia-explorer-view.test.d.ts +2 -0
  14. package/lib/tests/theia-explorer-view.test.d.ts.map +1 -0
  15. package/lib/tests/theia-explorer-view.test.js +110 -0
  16. package/lib/tests/theia-explorer-view.test.js.map +1 -0
  17. package/lib/tests/theia-main-menu.test.d.ts +2 -0
  18. package/lib/tests/theia-main-menu.test.d.ts.map +1 -0
  19. package/lib/tests/theia-main-menu.test.js +74 -0
  20. package/lib/tests/theia-main-menu.test.js.map +1 -0
  21. package/lib/tests/theia-preference-view.test.d.ts +2 -0
  22. package/lib/tests/theia-preference-view.test.d.ts.map +1 -0
  23. package/lib/tests/theia-preference-view.test.js +79 -0
  24. package/lib/tests/theia-preference-view.test.js.map +1 -0
  25. package/lib/tests/theia-problems-view.test.d.ts +2 -0
  26. package/lib/tests/theia-problems-view.test.d.ts.map +1 -0
  27. package/lib/tests/theia-problems-view.test.js +53 -0
  28. package/lib/tests/theia-problems-view.test.js.map +1 -0
  29. package/lib/tests/theia-quick-command.test.d.ts +2 -0
  30. package/lib/tests/theia-quick-command.test.d.ts.map +1 -0
  31. package/lib/tests/theia-quick-command.test.js +54 -0
  32. package/lib/tests/theia-quick-command.test.js.map +1 -0
  33. package/lib/tests/theia-sample-app.test.d.ts +2 -0
  34. package/lib/tests/theia-sample-app.test.d.ts.map +1 -0
  35. package/lib/tests/theia-sample-app.test.js +81 -0
  36. package/lib/tests/theia-sample-app.test.js.map +1 -0
  37. package/lib/tests/theia-status-bar.test.d.ts +2 -0
  38. package/lib/tests/theia-status-bar.test.d.ts.map +1 -0
  39. package/lib/tests/theia-status-bar.test.js +42 -0
  40. package/lib/tests/theia-status-bar.test.js.map +1 -0
  41. package/lib/tests/theia-text-editor.test.d.ts +2 -0
  42. package/lib/tests/theia-text-editor.test.d.ts.map +1 -0
  43. package/lib/tests/theia-text-editor.test.js +148 -0
  44. package/lib/tests/theia-text-editor.test.js.map +1 -0
  45. package/lib/tests/theia-workspace.test.d.ts +2 -0
  46. package/lib/tests/theia-workspace.test.d.ts.map +1 -0
  47. package/lib/tests/theia-workspace.test.js +48 -0
  48. package/lib/tests/theia-workspace.test.js.map +1 -0
  49. package/lib/theia-about-dialog.d.ts +5 -0
  50. package/lib/theia-about-dialog.d.ts.map +1 -0
  51. package/lib/theia-about-dialog.js +27 -0
  52. package/lib/theia-about-dialog.js.map +1 -0
  53. package/lib/theia-app.d.ts +44 -0
  54. package/lib/theia-app.d.ts.map +1 -0
  55. package/lib/theia-app.js +136 -0
  56. package/lib/theia-app.js.map +1 -0
  57. package/lib/theia-context-menu.d.ts +9 -0
  58. package/lib/theia-context-menu.d.ts.map +1 -0
  59. package/lib/theia-context-menu.js +38 -0
  60. package/lib/theia-context-menu.js.map +1 -0
  61. package/lib/theia-dialog.d.ts +28 -0
  62. package/lib/theia-dialog.d.ts.map +1 -0
  63. package/lib/theia-dialog.js +99 -0
  64. package/lib/theia-dialog.js.map +1 -0
  65. package/lib/theia-editor.d.ts +10 -0
  66. package/lib/theia-editor.d.ts.map +1 -0
  67. package/lib/theia-editor.js +69 -0
  68. package/lib/theia-editor.js.map +1 -0
  69. package/lib/theia-explorer-view.d.ts +39 -0
  70. package/lib/theia-explorer-view.d.ts.map +1 -0
  71. package/lib/theia-explorer-view.js +210 -0
  72. package/lib/theia-explorer-view.js.map +1 -0
  73. package/lib/theia-main-menu.d.ts +13 -0
  74. package/lib/theia-main-menu.d.ts.map +1 -0
  75. package/lib/theia-main-menu.js +54 -0
  76. package/lib/theia-main-menu.js.map +1 -0
  77. package/lib/theia-menu-item.d.ts +14 -0
  78. package/lib/theia-menu-item.d.ts.map +1 -0
  79. package/lib/theia-menu-item.js +55 -0
  80. package/lib/theia-menu-item.js.map +1 -0
  81. package/lib/theia-menu.d.ts +17 -0
  82. package/lib/theia-menu.d.ts.map +1 -0
  83. package/lib/theia-menu.js +87 -0
  84. package/lib/theia-menu.js.map +1 -0
  85. package/lib/theia-notification-indicator.d.ts +9 -0
  86. package/lib/theia-notification-indicator.d.ts.map +1 -0
  87. package/lib/theia-notification-indicator.js +45 -0
  88. package/lib/theia-notification-indicator.js.map +1 -0
  89. package/lib/theia-notification-overlay.d.ts +23 -0
  90. package/lib/theia-notification-overlay.d.ts.map +1 -0
  91. package/lib/theia-notification-overlay.js +80 -0
  92. package/lib/theia-notification-overlay.js.map +1 -0
  93. package/lib/theia-page-object.d.ts +8 -0
  94. package/lib/theia-page-object.d.ts.map +1 -0
  95. package/lib/theia-page-object.js +28 -0
  96. package/lib/theia-page-object.js.map +1 -0
  97. package/lib/theia-preference-view.d.ts +51 -0
  98. package/lib/theia-preference-view.d.ts.map +1 -0
  99. package/lib/theia-preference-view.js +197 -0
  100. package/lib/theia-preference-view.js.map +1 -0
  101. package/lib/theia-problem-indicator.d.ts +9 -0
  102. package/lib/theia-problem-indicator.d.ts.map +1 -0
  103. package/lib/theia-problem-indicator.js +40 -0
  104. package/lib/theia-problem-indicator.js.map +1 -0
  105. package/lib/theia-problem-view.d.ts +6 -0
  106. package/lib/theia-problem-view.d.ts.map +1 -0
  107. package/lib/theia-problem-view.js +31 -0
  108. package/lib/theia-problem-view.js.map +1 -0
  109. package/lib/theia-quick-command-palette.d.ts +12 -0
  110. package/lib/theia-quick-command-palette.d.ts.map +1 -0
  111. package/lib/theia-quick-command-palette.js +74 -0
  112. package/lib/theia-quick-command-palette.js.map +1 -0
  113. package/lib/theia-rename-dialog.d.ts +6 -0
  114. package/lib/theia-rename-dialog.d.ts.map +1 -0
  115. package/lib/theia-rename-dialog.js +36 -0
  116. package/lib/theia-rename-dialog.js.map +1 -0
  117. package/lib/theia-status-bar.d.ts +14 -0
  118. package/lib/theia-status-bar.d.ts.map +1 -0
  119. package/lib/theia-status-bar.js +40 -0
  120. package/lib/theia-status-bar.js.map +1 -0
  121. package/lib/theia-status-indicator.d.ts +15 -0
  122. package/lib/theia-status-indicator.d.ts.map +1 -0
  123. package/lib/theia-status-indicator.js +77 -0
  124. package/lib/theia-status-indicator.js.map +1 -0
  125. package/lib/theia-text-editor.d.ts +28 -0
  126. package/lib/theia-text-editor.d.ts.map +1 -0
  127. package/lib/theia-text-editor.js +149 -0
  128. package/lib/theia-text-editor.js.map +1 -0
  129. package/lib/theia-toggle-bottom-indicator.d.ts +5 -0
  130. package/lib/theia-toggle-bottom-indicator.d.ts.map +1 -0
  131. package/lib/theia-toggle-bottom-indicator.js +27 -0
  132. package/lib/theia-toggle-bottom-indicator.js.map +1 -0
  133. package/lib/theia-tree-node.d.ts +17 -0
  134. package/lib/theia-tree-node.d.ts.map +1 -0
  135. package/lib/theia-tree-node.js +54 -0
  136. package/lib/theia-tree-node.js.map +1 -0
  137. package/lib/theia-view.d.ts +33 -0
  138. package/lib/theia-view.d.ts.map +1 -0
  139. package/lib/theia-view.js +152 -0
  140. package/lib/theia-view.js.map +1 -0
  141. package/lib/theia-workspace.d.ts +19 -0
  142. package/lib/theia-workspace.d.ts.map +1 -0
  143. package/lib/theia-workspace.js +70 -0
  144. package/lib/theia-workspace.js.map +1 -0
  145. package/lib/util.d.ts +20 -0
  146. package/lib/util.d.ts.map +1 -0
  147. package/lib/util.js +94 -0
  148. package/lib/util.js.map +1 -0
  149. package/package.json +8 -6
  150. package/src/index.ts +41 -0
  151. package/src/tests/fixtures/theia-fixture.ts +25 -0
  152. package/src/tests/resources/sample-files1/sample.txt +4 -0
  153. package/src/tests/resources/sample-files1/sampleFolder/sampleFolder1/sampleFolder1-1/sampleFile1-1-1.txt +1 -0
  154. package/src/tests/resources/sample-files1/sampleFolder/sampleFolder1/sampleFolder1-1/sampleFile1-1-2.txt +1 -0
  155. package/src/tests/resources/sample-files1/sampleFolder/sampleFolder1/sampleFolder1-2/sampleFile1-2-1.txt +1 -0
  156. package/src/tests/resources/sample-files1/sampleFolder/sampleFolder1/sampleFolder1-2/sampleFile1-2-2.txt +1 -0
  157. package/src/tests/resources/sample-files1/sampleFolder/sampleFolder2/sampleFolder2-1/sampleFile2-1-1.txt +1 -0
  158. package/src/tests/resources/sample-files1/sampleFolder/sampleFolder2/sampleFolder2-1/sampleFile2-1-2.txt +1 -0
  159. package/src/tests/resources/sample-files1/sampleFolder/sampleFolder2/sampleFolder2-2/sampleFile2-2-1.txt +1 -0
  160. package/src/tests/resources/sample-files1/sampleFolder/sampleFolder2/sampleFolder2-2/sampleFile2-2-2.txt +1 -0
  161. package/src/tests/resources/sample-files2/another-sample.txt +1 -0
  162. package/src/tests/theia-app.test.ts +34 -0
  163. package/src/tests/theia-explorer-view.test.ts +124 -0
  164. package/src/tests/theia-main-menu.test.ts +89 -0
  165. package/src/tests/theia-preference-view.test.ts +93 -0
  166. package/src/tests/theia-problems-view.test.ts +60 -0
  167. package/src/tests/theia-quick-command.test.ts +61 -0
  168. package/src/tests/theia-sample-app.test.ts +92 -0
  169. package/src/tests/theia-status-bar.test.ts +47 -0
  170. package/src/tests/theia-text-editor.test.ts +176 -0
  171. package/src/tests/theia-workspace.test.ts +51 -0
  172. package/src/theia-app.ts +32 -14
  173. package/src/theia-workspace.ts +4 -0
@@ -0,0 +1,176 @@
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 { TheiaTextEditor } from '../theia-text-editor';
20
+ import { TheiaWorkspace } from '../theia-workspace';
21
+ import test, { page } from './fixtures/theia-fixture';
22
+
23
+ let app: TheiaApp;
24
+
25
+ test.describe('Theia Text Editor', () => {
26
+
27
+ test.beforeAll(async () => {
28
+ const ws = new TheiaWorkspace(['src/tests/resources/sample-files1']);
29
+ app = await TheiaApp.load(page, ws);
30
+ });
31
+
32
+ test('should be visible and active after opening "sample.txt"', async () => {
33
+ const sampleTextEditor = await app.openEditor('sample.txt', TheiaTextEditor);
34
+ expect(await sampleTextEditor.isTabVisible()).toBe(true);
35
+ expect(await sampleTextEditor.isDisplayed()).toBe(true);
36
+ expect(await sampleTextEditor.isActive()).toBe(true);
37
+ });
38
+
39
+ test('should be possible to open "sample.txt" when already opened and then close it', async () => {
40
+ const sampleTextEditor = await app.openEditor('sample.txt', TheiaTextEditor);
41
+ expect(await sampleTextEditor.isTabVisible()).toBe(true);
42
+
43
+ await sampleTextEditor.close();
44
+ expect(await sampleTextEditor.isTabVisible()).toBe(false);
45
+ });
46
+
47
+ test('should be possible to open four text editors, switch among them, and close them', async () => {
48
+ const textEditor1_1_1 = await app.openEditor('sampleFolder/sampleFolder1/sampleFolder1-1/sampleFile1-1-1.txt', TheiaTextEditor);
49
+ const textEditor1_1_2 = await app.openEditor('sampleFolder/sampleFolder1/sampleFolder1-1/sampleFile1-1-2.txt', TheiaTextEditor);
50
+ const textEditor1_2_1 = await app.openEditor('sampleFolder/sampleFolder1/sampleFolder1-2/sampleFile1-2-1.txt', TheiaTextEditor);
51
+ const textEditor1_2_2 = await app.openEditor('sampleFolder/sampleFolder1/sampleFolder1-2/sampleFile1-2-2.txt', TheiaTextEditor);
52
+ const allEditors = [textEditor1_1_1, textEditor1_1_2, textEditor1_2_1, textEditor1_2_2];
53
+
54
+ // all editor tabs should be visible
55
+ for (const editor of allEditors) {
56
+ expect(await editor.isTabVisible()).toBe(true);
57
+ }
58
+
59
+ // activate one editor after the other and check that only this editor is active
60
+ for (const editor of allEditors) {
61
+ await editor.activate();
62
+ expect(await textEditor1_1_1.isActive()).toBe(textEditor1_1_1 === editor);
63
+ expect(await textEditor1_1_2.isActive()).toBe(textEditor1_1_2 === editor);
64
+ expect(await textEditor1_2_1.isActive()).toBe(textEditor1_2_1 === editor);
65
+ expect(await textEditor1_2_2.isActive()).toBe(textEditor1_2_2 === editor);
66
+ }
67
+
68
+ // close all editors
69
+ for (const editor of allEditors) {
70
+ await editor.close();
71
+ }
72
+
73
+ // check that all editors are closed
74
+ for (const editor of allEditors) {
75
+ expect(await editor.isTabVisible()).toBe(false);
76
+ }
77
+ });
78
+
79
+ test('should return the contents of lines by line number', async () => {
80
+ const sampleTextEditor = await app.openEditor('sample.txt', TheiaTextEditor);
81
+ expect(await sampleTextEditor.textContentOfLineByLineNumber(2)).toBe('content line 2');
82
+ expect(await sampleTextEditor.textContentOfLineByLineNumber(3)).toBe('content line 3');
83
+ expect(await sampleTextEditor.textContentOfLineByLineNumber(4)).toBe('content line 4');
84
+ await sampleTextEditor.close();
85
+ });
86
+
87
+ test('should return the contents of lines containing text', async () => {
88
+ const sampleTextEditor = await app.openEditor('sample.txt', TheiaTextEditor);
89
+ expect(await sampleTextEditor.textContentOfLineContainingText('line 2')).toBe('content line 2');
90
+ expect(await sampleTextEditor.textContentOfLineContainingText('line 3')).toBe('content line 3');
91
+ expect(await sampleTextEditor.textContentOfLineContainingText('line 4')).toBe('content line 4');
92
+ await sampleTextEditor.close();
93
+ });
94
+
95
+ test('should be dirty after changing the file contents and clean after save', async () => {
96
+ const sampleTextEditor = await app.openEditor('sample.txt', TheiaTextEditor);
97
+ await sampleTextEditor.replaceLineWithLineNumber('this is just a sample file', 1);
98
+ expect(await sampleTextEditor.isDirty()).toBe(true);
99
+
100
+ await sampleTextEditor.save();
101
+ expect(await sampleTextEditor.isDirty()).toBe(false);
102
+ await sampleTextEditor.close();
103
+ });
104
+
105
+ test('should replace the line with line number 2 with new text "new -- content line 2 -- new"', async () => {
106
+ const sampleTextEditor = await app.openEditor('sample.txt', TheiaTextEditor);
107
+ await sampleTextEditor.replaceLineWithLineNumber('new -- content line 2 -- new', 2);
108
+ expect(await sampleTextEditor.textContentOfLineByLineNumber(2)).toBe('new -- content line 2 -- new');
109
+ expect(await sampleTextEditor.isDirty()).toBe(true);
110
+
111
+ await sampleTextEditor.save();
112
+ expect(await sampleTextEditor.isDirty()).toBe(false);
113
+ await sampleTextEditor.close();
114
+ });
115
+
116
+ test('should replace the line with containing text "content line 2" with "even newer -- content line 2 -- even newer"', async () => {
117
+ const sampleTextEditor = await app.openEditor('sample.txt', TheiaTextEditor);
118
+ await sampleTextEditor.replaceLineContainingText('even newer -- content line 2 -- even newer', 'content line 2');
119
+ expect(await sampleTextEditor.textContentOfLineByLineNumber(2)).toBe('even newer -- content line 2 -- even newer');
120
+ await sampleTextEditor.saveAndClose();
121
+ });
122
+
123
+ test('should delete the line with containing text "content line 2"', async () => {
124
+ const sampleTextEditor = await app.openEditor('sample.txt', TheiaTextEditor);
125
+ await sampleTextEditor.deleteLineContainingText('content line 2');
126
+ expect(await sampleTextEditor.textContentOfLineByLineNumber(2)).toBe('content line 3');
127
+ await sampleTextEditor.saveAndClose();
128
+ });
129
+
130
+ test('should delete the line with line number 2', async () => {
131
+ const sampleTextEditor = await app.openEditor('sample.txt', TheiaTextEditor);
132
+ await sampleTextEditor.deleteLineByLineNumber(2);
133
+ expect(await sampleTextEditor.textContentOfLineByLineNumber(2)).toBe('content line 4');
134
+ await sampleTextEditor.saveAndClose();
135
+ });
136
+
137
+ test('should have more lines after adding text in new line after line containing text "sample file"', async () => {
138
+ const sampleTextEditor = await app.openEditor('sample.txt', TheiaTextEditor);
139
+ const numberOfLinesBefore = await sampleTextEditor.numberOfLines();
140
+
141
+ await sampleTextEditor.addTextToNewLineAfterLineContainingText('sample file', 'new content for line 2');
142
+ const numberOfLinesAfter = await sampleTextEditor.numberOfLines();
143
+ expect(numberOfLinesBefore).not.toBeUndefined();
144
+ expect(numberOfLinesAfter).not.toBeUndefined();
145
+ expect(numberOfLinesAfter).toBeGreaterThan(numberOfLinesBefore!);
146
+
147
+ await sampleTextEditor.saveAndClose();
148
+ });
149
+
150
+ test('should undo and redo text changes with correctly updated dirty states', async () => {
151
+ const sampleTextEditor = await app.openEditor('sample.txt', TheiaTextEditor);
152
+ await sampleTextEditor.replaceLineWithLineNumber('change', 1);
153
+ expect(await sampleTextEditor.textContentOfLineByLineNumber(1)).toBe('change');
154
+ expect(await sampleTextEditor.isDirty()).toBe(true);
155
+
156
+ await sampleTextEditor.undo(2);
157
+ expect(await sampleTextEditor.textContentOfLineByLineNumber(1)).toBe('this is just a sample file');
158
+ expect(await sampleTextEditor.isDirty()).toBe(false);
159
+
160
+ await sampleTextEditor.redo(2);
161
+ expect(await sampleTextEditor.textContentOfLineByLineNumber(1)).toBe('change');
162
+ expect(await sampleTextEditor.isDirty()).toBe(true);
163
+
164
+ await sampleTextEditor.saveAndClose();
165
+ });
166
+
167
+ test.skip('should close without saving', async () => {
168
+ const sampleTextEditor = await app.openEditor('sample.txt', TheiaTextEditor);
169
+ await sampleTextEditor.replaceLineWithLineNumber('change again', 1);
170
+ expect(await sampleTextEditor.isDirty()).toBe(true);
171
+
172
+ await sampleTextEditor.closeWithoutSave();
173
+ expect(await sampleTextEditor.isTabVisible()).toBe(false);
174
+ });
175
+
176
+ });
@@ -0,0 +1,51 @@
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 { TheiaApp } from '../theia-app';
18
+ import { DOT_FILES_FILTER, TheiaExplorerView } from '../theia-explorer-view';
19
+ import { TheiaWorkspace } from '../theia-workspace';
20
+ import { expect } from '@playwright/test';
21
+ import test, { page } from './fixtures/theia-fixture';
22
+
23
+ test.describe('Theia Workspace', () => {
24
+
25
+ test('should be initialized empty by default', async () => {
26
+ const app = await TheiaApp.load(page);
27
+ const explorer = await app.openView(TheiaExplorerView);
28
+ const fileStatElements = await explorer.visibleFileStatNodes(DOT_FILES_FILTER);
29
+ expect(fileStatElements.length).toBe(0);
30
+ });
31
+
32
+ test('should be initialized with the contents of a file location', async () => {
33
+ const ws = new TheiaWorkspace(['src/tests/resources/sample-files1']);
34
+ const app = await TheiaApp.load(page, ws);
35
+ const explorer = await app.openView(TheiaExplorerView);
36
+ const fileStatElements = await explorer.visibleFileStatNodes(DOT_FILES_FILTER);
37
+ // resources/sample-files1 contains one folder and one file
38
+ expect(fileStatElements.length).toBe(2);
39
+ });
40
+
41
+ test('should be initialized with the contents of multiple file locations', async () => {
42
+ const ws = new TheiaWorkspace(['src/tests/resources/sample-files1', 'src/tests/resources/sample-files2']);
43
+ const app = await TheiaApp.load(page, ws);
44
+ const explorer = await app.openView(TheiaExplorerView);
45
+ const fileStatElements = await explorer.visibleFileStatNodes(DOT_FILES_FILTER);
46
+ // resources/sample-files1 contains one folder and one file
47
+ // resources/sample-files2 contains one file
48
+ expect(fileStatElements.length).toBe(3);
49
+ });
50
+
51
+ });
package/src/theia-app.ts CHANGED
@@ -24,6 +24,16 @@ import { TheiaStatusBar } from './theia-status-bar';
24
24
  import { TheiaView } from './theia-view';
25
25
  import { TheiaWorkspace } from './theia-workspace';
26
26
 
27
+ export interface TheiaAppData {
28
+ loadingSelector: string;
29
+ shellSelector: string;
30
+ };
31
+
32
+ export const DefaultTheiaAppData: TheiaAppData = {
33
+ loadingSelector: '.theia-preload',
34
+ shellSelector: '.theia-ApplicationShell'
35
+ };
36
+
27
37
  export class TheiaApp {
28
38
 
29
39
  readonly statusBar = new TheiaStatusBar(this);
@@ -31,20 +41,33 @@ export class TheiaApp {
31
41
  readonly menuBar = new TheiaMenuBar(this);
32
42
  public workspace: TheiaWorkspace;
33
43
 
34
- public static async load(page: Page, initialWorkspace?: TheiaWorkspace): Promise<TheiaApp> {
35
- const app = new TheiaApp(page, initialWorkspace);
36
- await TheiaApp.loadOrReload(page, '/#' + app.workspace.urlEncodedPath);
37
- await page.waitForSelector('.theia-preload', { state: 'detached' });
38
- await page.waitForSelector('.theia-ApplicationShell');
39
- await app.waitForInitialized();
40
- return Promise.resolve(app);
44
+ static async load(page: Page, initialWorkspace?: TheiaWorkspace): Promise<TheiaApp> {
45
+ return this.loadApp(page, TheiaApp, initialWorkspace);
46
+ }
47
+
48
+ static async loadApp<T extends TheiaApp>(page: Page, appFactory: { new(page: Page, initialWorkspace?: TheiaWorkspace): T }, initialWorkspace?: TheiaWorkspace): Promise<T> {
49
+ const app = new appFactory(page, initialWorkspace);
50
+ await app.load();
51
+ return app;
52
+ }
53
+
54
+ public constructor(public page: Page, initialWorkspace?: TheiaWorkspace, protected appData = DefaultTheiaAppData) {
55
+ this.workspace = initialWorkspace ? initialWorkspace : new TheiaWorkspace();
56
+ this.workspace.initialize();
57
+ }
58
+
59
+ protected async load(): Promise<void> {
60
+ await this.loadOrReload(this.page, '/#' + this.workspace.urlEncodedPath);
61
+ await this.page.waitForSelector(this.appData.loadingSelector, { state: 'detached' });
62
+ await this.page.waitForSelector(this.appData.shellSelector);
63
+ await this.waitForInitialized();
41
64
  }
42
65
 
43
- protected static async loadOrReload(page: Page, url: string): Promise<void> {
66
+ protected async loadOrReload(page: Page, url: string): Promise<void> {
44
67
  if (page.url() === url) {
45
68
  await page.reload();
46
69
  } else {
47
- const wasLoadedAlready = await page.isVisible('.theia-ApplicationShell');
70
+ const wasLoadedAlready = await page.isVisible(this.appData.shellSelector);
48
71
  await page.goto(url);
49
72
  if (wasLoadedAlready) {
50
73
  // Theia doesn't refresh on URL change only
@@ -54,11 +77,6 @@ export class TheiaApp {
54
77
  }
55
78
  }
56
79
 
57
- protected constructor(public page: Page, initialWorkspace?: TheiaWorkspace) {
58
- this.workspace = initialWorkspace ? initialWorkspace : new TheiaWorkspace();
59
- this.workspace.initialize();
60
- }
61
-
62
80
  async isMainContentPanelVisible(): Promise<boolean> {
63
81
  const contentPanel = await this.page.$('#theia-main-content-panel');
64
82
  return !!contentPanel && contentPanel.isVisible();
@@ -69,4 +69,8 @@ export class TheiaWorkspace {
69
69
  fs.emptyDirSync(this.workspacePath);
70
70
  }
71
71
 
72
+ remove(): void {
73
+ fs.removeSync(this.workspacePath);
74
+ }
75
+
72
76
  }